From a6233863da4203bec781e817963ac3733279cab5 Mon Sep 17 00:00:00 2001
From: Armand Philippot <git@armandphilippot.com>
Date: Mon, 17 Jan 2022 22:26:16 +0100
Subject: refactor(settings): make toggle reusable

Toggle will be used for others settings so I extract the functionnality
from ThemeToggle.
---
 src/components/ThemeToggle/ThemeToggle.tsx | 45 ------------------------------
 1 file changed, 45 deletions(-)
 delete mode 100644 src/components/ThemeToggle/ThemeToggle.tsx

(limited to 'src/components/ThemeToggle/ThemeToggle.tsx')

diff --git a/src/components/ThemeToggle/ThemeToggle.tsx b/src/components/ThemeToggle/ThemeToggle.tsx
deleted file mode 100644
index c44f6df..0000000
--- a/src/components/ThemeToggle/ThemeToggle.tsx
+++ /dev/null
@@ -1,45 +0,0 @@
-import { Form } from '@components/Form';
-import { MoonIcon, SunIcon } from '@components/Icons';
-import Spinner from '@components/Spinner/Spinner';
-import { t } from '@lingui/macro';
-import { useTheme } from 'next-themes';
-import { FormEvent, useEffect, useState } from 'react';
-import styles from './ThemeToggle.module.scss';
-
-const ThemeToggle = () => {
-  const [isMounted, setIsMounted] = useState<boolean>(false);
-  const { resolvedTheme, setTheme } = useTheme();
-
-  useEffect(() => {
-    setIsMounted(true);
-  }, []);
-
-  const onSubmit = (e: FormEvent) => {
-    e.preventDefault();
-  };
-
-  if (!isMounted) return <Spinner />;
-
-  const isDarkTheme = resolvedTheme === 'dark';
-
-  return (
-    <Form modifier="theme" submitHandler={onSubmit}>
-      <input
-        className={styles.checkbox}
-        type="checkbox"
-        id="dark-theme"
-        name="dark-theme"
-        checked={isDarkTheme}
-        onChange={() => setTheme(isDarkTheme ? 'light' : 'dark')}
-      />
-      <label htmlFor="dark-theme" className={styles.label}>
-        <span className={styles.title}>{t`Theme:`}</span>
-        <SunIcon />
-        <span className={styles.toggle}></span>
-        <MoonIcon />
-      </label>
-    </Form>
-  );
-};
-
-export default ThemeToggle;
-- 
cgit v1.2.3

