Skip to content

Commit

Permalink
Set default system mode as initial state
Browse files Browse the repository at this point in the history
  • Loading branch information
vivek-harness committed Nov 26, 2024
1 parent 8dd515a commit b7a4a4b
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions apps/gitness/src/framework/context/ThemeContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,9 @@ export function ThemeProvider({ children }: { children: React.ReactNode }) {
setTheme: state.setTheme
}))

const [systemMode, setSystemMode] = useState<ModeType>(ModeType.Dark)
const mediaQuery = window.matchMedia('(prefers-color-scheme: dark)')
const [systemMode, setSystemMode] = useState<ModeType>(mediaQuery.matches ? ModeType.Dark : ModeType.Light)
useEffect(() => {
const mediaQuery = window.matchMedia('(prefers-color-scheme: dark)')
setSystemMode(mediaQuery.matches ? ModeType.Dark : ModeType.Light)

const updateSystemTheme = () => {
setSystemMode(mediaQuery.matches ? ModeType.Dark : ModeType.Light)
}
Expand Down

0 comments on commit b7a4a4b

Please sign in to comment.