|
1 |
| -import { useEffect } from "react" |
2 | 1 | import { useTranslation } from "next-i18next"
|
3 | 2 | import { useTheme } from "next-themes"
|
4 | 3 | import {
|
@@ -29,7 +28,7 @@ import type { NavSections } from "./types"
|
29 | 28 |
|
30 | 29 | export const useNav = () => {
|
31 | 30 | const { t } = useTranslation("common")
|
32 |
| - const { setTheme, resolvedTheme, systemTheme } = useTheme() |
| 31 | + const { setTheme, resolvedTheme } = useTheme() |
33 | 32 | const { setColorMode } = useColorMode()
|
34 | 33 |
|
35 | 34 | const linkSections: NavSections = {
|
@@ -462,23 +461,12 @@ export const useNav = () => {
|
462 | 461 | },
|
463 | 462 | }
|
464 | 463 |
|
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 |
| - |
474 | 464 | const toggleColorMode = () => {
|
475 |
| - // resolvedTheme: "light" | "dark" = Current resolved color mode from useTheme |
476 | 465 | 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 |
479 | 466 |
|
480 |
| - setTheme(lsTheme) |
| 467 | + setTheme(targetTheme) |
481 | 468 | setColorMode(targetTheme)
|
| 469 | + |
482 | 470 | trackCustomEvent({
|
483 | 471 | eventCategory: "nav bar",
|
484 | 472 | eventAction: "click",
|
|
0 commit comments