Skip to content

Commit

Permalink
Merge pull request #65 from FRC2713/fix-disapearing
Browse files Browse the repository at this point in the history
Fix entire page disapearing when theme buttons double-clicked
  • Loading branch information
Owen-Morgan825 authored Jan 18, 2025
2 parents 66f16bb + 34fc887 commit 6ef0912
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/components/ThemeProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -46,7 +46,6 @@ export function ThemeProvider({

useEffect(() => {
const root = window.document.documentElement;

root.classList.remove('light', 'dark');

if (theme === 'system') {
Expand All @@ -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 = {
Expand Down

0 comments on commit 6ef0912

Please sign in to comment.