SearchHelp.tsx 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import React, { useState } from 'react';
  2. import { useTranslation } from 'next-i18next';
  3. import { Collapse } from 'reactstrap';
  4. export const SearchHelp = (): JSX.Element => {
  5. const { t } = useTranslation();
  6. const [isOpen, setIsOpen] = useState(false);
  7. return (
  8. <>
  9. <button type="button" className="btn border-0 text-muted d-flex justify-content-center align-items-center ms-1 p-0" onClick={() => setIsOpen(!isOpen)}>
  10. <span className="material-symbols-outlined me-2">help</span>
  11. { t('search_help.title') }
  12. <span className="material-symbols-outlined ms-2">{isOpen ? 'expand_less' : 'expand_more'}</span>
  13. </button>
  14. <Collapse isOpen={isOpen}>
  15. <table className="table m-0">
  16. <tbody>
  17. <tr>
  18. <th className="py-2">
  19. <code>word1</code> <code>word2</code><br />
  20. <small className="text-muted">({ t('search_help.and.syntax help') })</small>
  21. </th>
  22. <td><h6 className="m-0 text-muted">{ t('search_help.and.desc', { word1: 'word1', word2: 'word2' }) }</h6></td>
  23. </tr>
  24. <tr>
  25. <th className="py-2">
  26. <code>&quot;This is GROWI&quot;</code><br />
  27. <small className="text-muted">({ t('search_help.phrase.syntax help') })</small>
  28. </th>
  29. <td><h6 className="m-0 text-muted">{ t('search_help.phrase.desc', { phrase: 'This is GROWI' }) }</h6></td>
  30. </tr>
  31. <tr>
  32. <th className="py-2"><code>-keyword</code></th>
  33. <td><h6 className="m-0 text-muted">{ t('search_help.exclude.desc', { word: 'keyword' }) }</h6></td>
  34. </tr>
  35. <tr>
  36. <th className="py-2"><code>prefix:/user/</code></th>
  37. <td><h6 className="m-0 text-muted">{ t('search_help.prefix.desc', { path: '/user/' }) }</h6></td>
  38. </tr>
  39. <tr>
  40. <th className="py-2"><code>-prefix:/user/</code></th>
  41. <td><h6 className="m-0 text-muted">{ t('search_help.exclude_prefix.desc', { path: '/user/' }) }</h6></td>
  42. </tr>
  43. <tr>
  44. <th className="py-2"><code>tag:wiki</code></th>
  45. <td><h6 className="m-0 text-muted">{ t('search_help.tag.desc', { tag: 'wiki' }) }</h6></td>
  46. </tr>
  47. <tr>
  48. <th className="py-2"><code>-tag:wiki</code></th>
  49. <td><h6 className="m-0 text-muted">{ t('search_help.exclude_tag.desc', { tag: 'wiki' }) }</h6></td>
  50. </tr>
  51. </tbody>
  52. </table>
  53. </Collapse>
  54. </>
  55. );
  56. };