aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/ThemeToggle/ThemeToggle.tsx
blob: 015201b57de0b6aeaaac53654e30823fd65ce500 (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
import { Form } from '@components/Form';
import { MoonIcon, SunIcon } from '@components/Icons';
import { t } from '@lingui/macro';
import { FormEvent, useState } from 'react';
import styles from './ThemeToggle.module.scss';

const ThemeToggle = () => {
  const [isDarkTheme, setIsDarkTheme] = useState<boolean>(false);

  const onSubmit = (e: FormEvent) => {
    e.preventDefault();
  };

  return (
    <Form modifier="theme" submitHandler={onSubmit}>
      <input
        className={styles.checkbox}
        type="checkbox"
        id="dark-theme"
        name="dark-theme"
        checked={isDarkTheme}
        onChange={() => setIsDarkTheme(!isDarkTheme)}
      />
      <label htmlFor="dark-theme" className={styles.label}>
        <span className="screen-reader-text">{t`Activate dark theme`}</span>
        <SunIcon />
        <span className={styles.toggle}></span>
        <MoonIcon />
      </label>
    </Form>
  );
};

export default ThemeToggle;