diff --git a/interface/src/App.tsx b/interface/src/App.tsx index 5b93feee..907dcb39 100644 --- a/interface/src/App.tsx +++ b/interface/src/App.tsx @@ -37,7 +37,6 @@ const App: React.FC = () => { } ]; - {/*
*/} return (
diff --git a/interface/src/components/Switch.css b/interface/src/components/Switch.css index d7e84449..6be68af7 100644 --- a/interface/src/components/Switch.css +++ b/interface/src/components/Switch.css @@ -1,3 +1,4 @@ +.dark .switch[data-ison="true"], .switch[data-ison="true"] { background-color: #30D259; } \ No newline at end of file diff --git a/interface/src/components/TabbedContainer.tsx b/interface/src/components/TabbedContainer.tsx index df35d6b0..9d55daf8 100644 --- a/interface/src/components/TabbedContainer.tsx +++ b/interface/src/components/TabbedContainer.tsx @@ -35,30 +35,31 @@ const TabbedContainer: React.FC = ({ tabs, themeColor }) = }; return ( -
-
-
- - {tabs.map((tab, index) => ( - - ))} -
+ <> +
+
+ + {tabs.map((tab, index) => ( + + ))}
-
+
+
+
= ({ tabs, themeColor }) =
+ ); }; diff --git a/interface/src/hooks/settingsState.ts b/interface/src/hooks/settingsState.ts index 8045ac6e..79babb2f 100644 --- a/interface/src/hooks/settingsState.ts +++ b/interface/src/hooks/settingsState.ts @@ -4,9 +4,6 @@ import { SettingsProps } from "../types/SettingsProps"; import { MainConfig, SettingsState } from "../types/AppProps"; let RanOnce = false; -type StorageKeyToStateKeyMap = { - [key in keyof MainConfig]?: keyof SettingsState; -}; let previousSettingsState: SettingsState const useSettingsState = ({ settingsState, setSettingsState }: SettingsProps) => { @@ -25,6 +22,10 @@ const useSettingsState = ({ settingsState, setSettingsState }: SettingsProps) => customThemeColor: result.selectedColor, betterSEQTAPlus: result.onoff }); + + if (result.DarkMode) { + document.body.classList.add('dark'); + } }); }); @@ -38,13 +39,24 @@ const useSettingsState = ({ settingsState, setSettingsState }: SettingsProps) => }), []); const storageChangeListener = (changes: chrome.storage.StorageChange) => { + console.log(changes); for (const [key, { newValue }] of Object.entries(changes)) { + if (key === "DarkMode") { + if (key === "DarkMode" && newValue) { + document.body.classList.add('dark'); + } else { + document.body.classList.remove('dark'); + } + } + + // @ts-expect-error - TODO: Fix this const stateKey = keyToStateMap[key as keyof MainConfig]; if (stateKey) { setSettingsState((prevState: SettingsState) => ({ ...prevState, [stateKey]: newValue })); + } } }; @@ -63,7 +75,9 @@ const useSettingsState = ({ settingsState, setSettingsState }: SettingsProps) => useEffect(() => { if (previousSettingsState) { for (const [key, value] of Object.entries(settingsState)) { + // @ts-expect-error - TODO: Fix this const storageKey = Object.keys(keyToStateMap).find(k => keyToStateMap[k] === key); + // @ts-expect-error - TODO: Fix this if (storageKey && value !== previousSettingsState[key]) { setStorage(storageKey as keyof MainConfig, value); }