Skip to content

Commit

Permalink
Merge pull request #13921 from ethereum/master
Browse files Browse the repository at this point in the history
Master -> staging
  • Loading branch information
corwintines authored Sep 20, 2024
2 parents b93c5cb + 0effb97 commit 8b89842
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 24 deletions.
2 changes: 1 addition & 1 deletion src/@chakra-ui/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import semanticTokens from "./semanticTokens"

const config: ThemeConfig = {
cssVarPrefix: "eth",
initialColorMode: "system",
initialColorMode: "light",
/**
* Disable Chakra's system color subscription, as it works differently from
* `next-themes` and causes a desync with it.
Expand Down
18 changes: 3 additions & 15 deletions src/components/Nav/useNav.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { useEffect } from "react"
import { useTranslation } from "next-i18next"
import { useTheme } from "next-themes"
import {
Expand Down Expand Up @@ -29,7 +28,7 @@ import type { NavSections } from "./types"

export const useNav = () => {
const { t } = useTranslation("common")
const { setTheme, resolvedTheme, systemTheme } = useTheme()
const { setTheme, resolvedTheme } = useTheme()
const { setColorMode } = useColorMode()

const linkSections: NavSections = {
Expand Down Expand Up @@ -462,23 +461,12 @@ export const useNav = () => {
},
}

// Listen for changes to systemTheme and update theme accordingly
// Important if the user has not engaged the color mode toggle yet, and
// toggles system color preferences
useEffect(() => {
setTheme("system")
setColorMode(systemTheme)
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [systemTheme])

const toggleColorMode = () => {
// resolvedTheme: "light" | "dark" = Current resolved color mode from useTheme
const targetTheme = resolvedTheme === "dark" ? "light" : "dark"
// If target theme matches the users system pref, set ls theme to "system"
const lsTheme = targetTheme === systemTheme ? "system" : targetTheme

setTheme(lsTheme)
setTheme(targetTheme)
setColorMode(targetTheme)

trackCustomEvent({
eventCategory: "nav bar",
eventAction: "click",
Expand Down
6 changes: 3 additions & 3 deletions src/components/ThemeProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ const ThemeProvider = ({ children }: Pick<ThemeProviderProps, "children">) => {
const theme = useMemo(() => merge(customTheme, { direction }), [direction])
return (
<NextThemesProvider
attribute="class"
defaultTheme="system"
enableSystem
attribute="data-theme"
defaultTheme="light"
enableSystem={false}
disableTransitionOnChange
storageKey={COLOR_MODE_STORAGE_KEY}
>
Expand Down
2 changes: 1 addition & 1 deletion src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ const HomePage = ({
}
return (
<div
key={title}
key={title + date}
className="flex flex-col justify-between gap-6 border-t px-6 py-4 xl:flex-row"
>
<div className="flex flex-col gap-y-0.5 text-center text-base sm:text-start">
Expand Down
4 changes: 2 additions & 2 deletions src/styles/docsearch.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
}

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

.DocSearch-Search-Icon,
Expand Down Expand Up @@ -39,7 +39,7 @@
--docsearch-hit-height: fit-content;
}

.dark {
[data-theme="dark"] {
--docsearch-modal-background: theme(backgroundColor.background.DEFAULT);
--docsearch-highlight-color: theme(colors.primary.hover);
}
Expand Down
2 changes: 1 addition & 1 deletion src/styles/global.css
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
--search-background: var(--background);
}

.dark {
[data-theme="dark"] {
/* Semantic Colors: Dark mode */
/* ! Deprecating primary-light */
--primary-light: hsla(var(--orange-100));
Expand Down
2 changes: 1 addition & 1 deletion src/styles/semantic-tokens.css
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
}

/* Dark mode token declarations */
.dark {
[data-theme="dark"] {
--body: var(--gray-100);
--body-medium: var(--gray-400);
--body-light: var(--gray-600);
Expand Down

0 comments on commit 8b89842

Please sign in to comment.