From 2657469964e24ffbeb905024532120395f6e797c Mon Sep 17 00:00:00 2001
From: Mo Tarbin <mhed.t91@gmail.com>
Date: Sun, 30 Jun 2024 18:55:39 -0400
Subject: move to Donetick Org, First commit frontend

---
 src/views/Settings/ThemeToggle.jsx | 62 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 62 insertions(+)
 create mode 100644 src/views/Settings/ThemeToggle.jsx

(limited to 'src/views/Settings/ThemeToggle.jsx')

diff --git a/src/views/Settings/ThemeToggle.jsx b/src/views/Settings/ThemeToggle.jsx
new file mode 100644
index 0000000..6ff33f1
--- /dev/null
+++ b/src/views/Settings/ThemeToggle.jsx
@@ -0,0 +1,62 @@
+import useStickyState from '@/hooks/useStickyState'
+import {
+  DarkModeOutlined,
+  LaptopOutlined,
+  LightModeOutlined,
+} from '@mui/icons-material'
+import {
+  Button,
+  FormControl,
+  FormLabel,
+  ToggleButtonGroup,
+  useColorScheme,
+} from '@mui/joy'
+
+const ELEMENTID = 'select-theme-mode'
+
+const ThemeToggle = () => {
+  const { mode, setMode } = useColorScheme()
+  const [themeMode, setThemeMode] = useStickyState(mode, 'themeMode')
+
+  const handleThemeModeChange = (_, newThemeMode) => {
+    if (!newThemeMode) return
+    setThemeMode(newThemeMode)
+    setMode(newThemeMode)
+  }
+
+  const FormThemeModeToggleLabel = () => (
+    <FormLabel
+      level='title-md'
+      id={`${ELEMENTID}-label`}
+      htmlFor='select-theme-mode'
+    >
+      Theme mode
+    </FormLabel>
+  )
+
+  return (
+    <FormControl>
+      <FormThemeModeToggleLabel />
+      <div className='flex items-center gap-4'>
+        <ToggleButtonGroup
+          id={ELEMENTID}
+          variant='outlined'
+          value={themeMode}
+          onChange={handleThemeModeChange}
+        >
+          <Button startDecorator={<LightModeOutlined />} value='light'>
+            Light
+          </Button>
+          <Button startDecorator={<DarkModeOutlined />} value='dark'>
+            Dark
+          </Button>
+          <Button startDecorator={<LaptopOutlined />} value='system'>
+            System
+          </Button>
+        </ToggleButtonGroup>
+      </div>
+    </FormControl>
+  )
+}
+
+export default ThemeToggle
-- 
cgit 

