Skip to content

Commit 23f68a8

Browse files
committed
disable system color mode
1 parent 4802eab commit 23f68a8

File tree

3 files changed

+6
-18
lines changed

3 files changed

+6
-18
lines changed

src/@chakra-ui/theme.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import semanticTokens from "./semanticTokens"
66

77
const config: ThemeConfig = {
88
cssVarPrefix: "eth",
9-
initialColorMode: "system",
9+
initialColorMode: "light",
1010
/**
1111
* Disable Chakra's system color subscription, as it works differently from
1212
* `next-themes` and causes a desync with it.

src/components/Nav/useNav.ts

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { useEffect } from "react"
21
import { useTranslation } from "next-i18next"
32
import { useTheme } from "next-themes"
43
import {
@@ -29,7 +28,7 @@ import type { NavSections } from "./types"
2928

3029
export const useNav = () => {
3130
const { t } = useTranslation("common")
32-
const { setTheme, resolvedTheme, systemTheme } = useTheme()
31+
const { setTheme, resolvedTheme } = useTheme()
3332
const { setColorMode } = useColorMode()
3433

3534
const linkSections: NavSections = {
@@ -462,23 +461,12 @@ export const useNav = () => {
462461
},
463462
}
464463

465-
// Listen for changes to systemTheme and update theme accordingly
466-
// Important if the user has not engaged the color mode toggle yet, and
467-
// toggles system color preferences
468-
useEffect(() => {
469-
setTheme("system")
470-
setColorMode(systemTheme)
471-
// eslint-disable-next-line react-hooks/exhaustive-deps
472-
}, [systemTheme])
473-
474464
const toggleColorMode = () => {
475-
// resolvedTheme: "light" | "dark" = Current resolved color mode from useTheme
476465
const targetTheme = resolvedTheme === "dark" ? "light" : "dark"
477-
// If target theme matches the users system pref, set ls theme to "system"
478-
const lsTheme = targetTheme === systemTheme ? "system" : targetTheme
479466

480-
setTheme(lsTheme)
467+
setTheme(targetTheme)
481468
setColorMode(targetTheme)
469+
482470
trackCustomEvent({
483471
eventCategory: "nav bar",
484472
eventAction: "click",

src/components/ThemeProvider.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ const ThemeProvider = ({ children }: Pick<ThemeProviderProps, "children">) => {
2828
return (
2929
<NextThemesProvider
3030
attribute="class"
31-
defaultTheme="system"
32-
enableSystem
31+
defaultTheme="light"
32+
enableSystem={false}
3333
disableTransitionOnChange
3434
storageKey={COLOR_MODE_STORAGE_KEY}
3535
>

0 commit comments

Comments
 (0)