From 0f349e174949c8d986df73dd9ec0d1b8b8c3d757 Mon Sep 17 00:00:00 2001 From: Owen-Morgan825 Date: Tue, 14 Jan 2025 20:26:07 -0500 Subject: [PATCH 1/2] Temp fix entire page disapearing when theme buttons double-clicked --- src/components/ThemeProvider.tsx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/components/ThemeProvider.tsx b/src/components/ThemeProvider.tsx index feffa65..fa3c50b 100644 --- a/src/components/ThemeProvider.tsx +++ b/src/components/ThemeProvider.tsx @@ -46,7 +46,6 @@ export function ThemeProvider({ useEffect(() => { const root = window.document.documentElement; - root.classList.remove('light', 'dark'); if (theme === 'system') { @@ -58,8 +57,13 @@ export function ThemeProvider({ root.classList.add(systemTheme); return; } - setResolvedTheme(theme); - root.classList.add(theme); + + if(theme !== '') { + setResolvedTheme(theme); + root.classList.add(theme); + } + + }, [theme]); const value = { From 34fc887849ecf93df9b1c07c8d938e02a47bae45 Mon Sep 17 00:00:00 2001 From: Owen-Morgan825 Date: Thu, 16 Jan 2025 18:04:37 -0500 Subject: [PATCH 2/2] Make "" a valid value of things of type Theme --- src/components/ThemeProvider.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/ThemeProvider.tsx b/src/components/ThemeProvider.tsx index fa3c50b..7e21efa 100644 --- a/src/components/ThemeProvider.tsx +++ b/src/components/ThemeProvider.tsx @@ -2,7 +2,7 @@ import { useQRScoutState } from '@/store/store'; import { setColorScheme } from '@/util/theme'; import { createContext, useContext, useEffect, useState } from 'react'; -type Theme = 'dark' | 'light' | 'system'; +type Theme = 'dark' | 'light' | 'system' | ''; type ThemeProviderProps = { children: React.ReactNode;