summaryrefslogtreecommitdiffstats
path: root/src/components/Buttons/ButtonTheme
diff options
context:
space:
mode:
authorArmand Philippot <git@armandphilippot.com>2021-12-27 11:20:26 +0100
committerArmand Philippot <git@armandphilippot.com>2021-12-27 11:20:26 +0100
commit395571bd89498fce46d37f3853cf718387fd0d9a (patch)
tree0b1a405fb82484e31f62f72485feac18ebd29ae2 /src/components/Buttons/ButtonTheme
parent7deed83dbb8835727c743662bee776794d460e74 (diff)
chore: add a theme toggle
Dark theme is not implemented yet.
Diffstat (limited to 'src/components/Buttons/ButtonTheme')
-rw-r--r--src/components/Buttons/ButtonTheme/ButtonTheme.tsx40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/components/Buttons/ButtonTheme/ButtonTheme.tsx b/src/components/Buttons/ButtonTheme/ButtonTheme.tsx
new file mode 100644
index 0000000..afbac89
--- /dev/null
+++ b/src/components/Buttons/ButtonTheme/ButtonTheme.tsx
@@ -0,0 +1,40 @@
+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;