diff options
| author | Armand Philippot <git@armandphilippot.com> | 2021-12-20 19:03:17 +0100 |
|---|---|---|
| committer | Armand Philippot <git@armandphilippot.com> | 2021-12-20 19:05:02 +0100 |
| commit | f9df5cbce7db38ce83cc8b40346c9cabde5debc4 (patch) | |
| tree | a05ae5a5ef477f3554385a1bec78f625a6ed768c /src/components/Buttons/ButtonSearch | |
| parent | f7b08ee862e62b9f8764303f1fef733f210a7138 (diff) | |
chore: add a button to open/close search in toolbar
Diffstat (limited to 'src/components/Buttons/ButtonSearch')
| -rw-r--r-- | src/components/Buttons/ButtonSearch/ButtonSearch.tsx | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/components/Buttons/ButtonSearch/ButtonSearch.tsx b/src/components/Buttons/ButtonSearch/ButtonSearch.tsx new file mode 100644 index 0000000..a2635aa --- /dev/null +++ b/src/components/Buttons/ButtonSearch/ButtonSearch.tsx @@ -0,0 +1,41 @@ +import CloseIcon from '@assets/images/icon-close.svg'; +import SearchIcon from '@assets/images/icon-search.svg'; +import { t } from '@lingui/macro'; +import { SetStateAction } from 'react'; +import styles from '../Buttons.module.scss'; + +const ButtonSearch = ({ + isActivated, + setIsActivated, +}: { + isActivated: boolean; + setIsActivated: (value: SetStateAction<boolean>) => void; +}) => { + const btnClasses = isActivated + ? `${styles.search} ${styles['search--opened']}` + : styles.search; + + return ( + <button + className={btnClasses} + type="button" + onClick={() => setIsActivated(!isActivated)} + > + <span className={styles.icon}> + <span className={styles.front}> + <SearchIcon /> + </span> + <span className={styles.back}> + <CloseIcon /> + </span> + </span> + {isActivated ? ( + <span className="screen-reader-text">{t`Close search`}</span> + ) : ( + <span className="screen-reader-text">{t`Open search`}</span> + )} + </button> + ); +}; + +export default ButtonSearch; |
