diff options
| author | Armand Philippot <git@armandphilippot.com> | 2022-01-05 12:00:43 +0100 |
|---|---|---|
| committer | Armand Philippot <git@armandphilippot.com> | 2022-01-05 12:00:43 +0100 |
| commit | 0a954547b2bb8136c97f3a697274319751e046ed (patch) | |
| tree | c45e59bebc2b3fdebec8be4f5778ddf5cb6ce2f4 /src/components/Buttons | |
| parent | 71d133bb1c73031abbf4869bdd938e583b397773 (diff) | |
chore: replace theme button with settings
I plan to add more user settings so theme options should be inside
settings.
Diffstat (limited to 'src/components/Buttons')
| -rw-r--r-- | src/components/Buttons/ButtonTheme/ButtonTheme.tsx | 40 | ||||
| -rw-r--r-- | src/components/Buttons/ButtonToolbar/ButtonToolbar.tsx (renamed from src/components/Buttons/ButtonSearch/ButtonSearch.tsx) | 21 | ||||
| -rw-r--r-- | src/components/Buttons/Buttons.module.scss | 4 | ||||
| -rw-r--r-- | src/components/Buttons/index.tsx | 5 |
4 files changed, 17 insertions, 53 deletions
diff --git a/src/components/Buttons/ButtonTheme/ButtonTheme.tsx b/src/components/Buttons/ButtonTheme/ButtonTheme.tsx deleted file mode 100644 index afbac89..0000000 --- a/src/components/Buttons/ButtonTheme/ButtonTheme.tsx +++ /dev/null @@ -1,40 +0,0 @@ -import { CloseIcon, ThemeIcon } from '@components/Icons'; -import { t } from '@lingui/macro'; -import { SetStateAction } from 'react'; -import styles from '../Buttons.module.scss'; - -const ButtonTheme = ({ - isActivated, - setIsActivated, -}: { - isActivated: boolean; - setIsActivated: (value: SetStateAction<boolean>) => void; -}) => { - const btnClasses = isActivated - ? `${styles.theme} ${styles['theme--opened']}` - : styles.theme; - - return ( - <button - className={btnClasses} - type="button" - onClick={() => setIsActivated(!isActivated)} - > - <span className={styles.icon}> - <span className={styles.front}> - <ThemeIcon /> - </span> - <span className={styles.back}> - <CloseIcon /> - </span> - </span> - {isActivated ? ( - <span className="screen-reader-text">{t`Close theme options`}</span> - ) : ( - <span className="screen-reader-text">{t`Open theme options`}</span> - )} - </button> - ); -}; - -export default ButtonTheme; diff --git a/src/components/Buttons/ButtonSearch/ButtonSearch.tsx b/src/components/Buttons/ButtonToolbar/ButtonToolbar.tsx index be5a9bc..22da133 100644 --- a/src/components/Buttons/ButtonSearch/ButtonSearch.tsx +++ b/src/components/Buttons/ButtonToolbar/ButtonToolbar.tsx @@ -1,18 +1,23 @@ -import { CloseIcon, SearchIcon } from '@components/Icons'; +import { CloseIcon, CogIcon, SearchIcon } from '@components/Icons'; import { t } from '@lingui/macro'; import { SetStateAction } from 'react'; import styles from '../Buttons.module.scss'; -const ButtonSearch = ({ +type ButtonType = 'search' | 'settings'; + +const ButtonToolbar = ({ + type, isActivated, setIsActivated, }: { + type: ButtonType; isActivated: boolean; setIsActivated: (value: SetStateAction<boolean>) => void; }) => { + const ButtonIcon = () => (type === 'search' ? <SearchIcon /> : <CogIcon />); const btnClasses = isActivated - ? `${styles.search} ${styles['search--opened']}` - : styles.search; + ? `${styles.toolbar} ${styles['toolbar--activated']}` + : styles.toolbar; return ( <button @@ -22,19 +27,19 @@ const ButtonSearch = ({ > <span className={styles.icon}> <span className={styles.front}> - <SearchIcon /> + <ButtonIcon /> </span> <span className={styles.back}> <CloseIcon /> </span> </span> {isActivated ? ( - <span className="screen-reader-text">{t`Close search`}</span> + <span className="screen-reader-text">{t`Close ${type}`}</span> ) : ( - <span className="screen-reader-text">{t`Open search`}</span> + <span className="screen-reader-text">{t`Open ${type}`}</span> )} </button> ); }; -export default ButtonSearch; +export default ButtonToolbar; diff --git a/src/components/Buttons/Buttons.module.scss b/src/components/Buttons/Buttons.module.scss index f46de82..1a0d73a 100644 --- a/src/components/Buttons/Buttons.module.scss +++ b/src/components/Buttons/Buttons.module.scss @@ -167,7 +167,7 @@ } } -.search, +.toolbar, .theme { display: block; width: var(--btn-size); @@ -212,7 +212,7 @@ z-index: 10; } -.search--opened, +.toolbar--activated, .theme--opened { .icon { transform: rotateY(180deg); diff --git a/src/components/Buttons/index.tsx b/src/components/Buttons/index.tsx index 74060f7..5c034ad 100644 --- a/src/components/Buttons/index.tsx +++ b/src/components/Buttons/index.tsx @@ -1,7 +1,6 @@ import Button from './Button/Button'; import ButtonLink from './ButtonLink/ButtonLink'; -import ButtonSearch from './ButtonSearch/ButtonSearch'; +import ButtonToolbar from './ButtonToolbar/ButtonToolbar'; import ButtonSubmit from './ButtonSubmit/ButtonSubmit'; -import ButtonTheme from './ButtonTheme/ButtonTheme'; -export { Button, ButtonLink, ButtonSearch, ButtonSubmit, ButtonTheme }; +export { Button, ButtonLink, ButtonToolbar, ButtonSubmit }; |
