Skip to content

Commit c47a8ef

Browse files
authored
Merge pull request #13915 from ethereum/hotfix-color-mode
Hotfix color mode
2 parents 4802eab + b8b5c1d commit c47a8ef

File tree

6 files changed

+11
-23
lines changed

6 files changed

+11
-23
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: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ const ThemeProvider = ({ children }: Pick<ThemeProviderProps, "children">) => {
2727
const theme = useMemo(() => merge(customTheme, { direction }), [direction])
2828
return (
2929
<NextThemesProvider
30-
attribute="class"
31-
defaultTheme="system"
32-
enableSystem
30+
attribute="data-theme"
31+
defaultTheme="light"
32+
enableSystem={false}
3333
disableTransitionOnChange
3434
storageKey={COLOR_MODE_STORAGE_KEY}
3535
>

src/styles/docsearch.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
}
88

99
.DocSearch-Button-Container svg {
10-
@apply size-3.5 group-hover:rotate-12 transition-transform duration-500 group-hover:transition-transform group-hover:duration-500;
10+
@apply size-3.5 transition-transform duration-500 group-hover:rotate-12 group-hover:transition-transform group-hover:duration-500;
1111
}
1212

1313
.DocSearch-Search-Icon,
@@ -39,7 +39,7 @@
3939
--docsearch-hit-height: fit-content;
4040
}
4141

42-
.dark {
42+
[data-theme="dark"] {
4343
--docsearch-modal-background: theme(backgroundColor.background.DEFAULT);
4444
--docsearch-highlight-color: theme(colors.primary.hover);
4545
}

src/styles/global.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
--search-background: var(--background);
5252
}
5353

54-
.dark {
54+
[data-theme="dark"] {
5555
/* Semantic Colors: Dark mode */
5656
/* ! Deprecating primary-light */
5757
--primary-light: hsla(var(--orange-100));

src/styles/semantic-tokens.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@
122122
}
123123

124124
/* Dark mode token declarations */
125-
.dark {
125+
[data-theme="dark"] {
126126
--body: var(--gray-100);
127127
--body-medium: var(--gray-400);
128128
--body-light: var(--gray-600);

0 commit comments

Comments
 (0)