aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/Buttons/ButtonTheme/ButtonTheme.tsx
blob: afbac89f8473ec4d3988a3b4462d3b743f2307ad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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;