Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { ThemeDarkIcon } from '@root/graphics/ThemeDarkIcon/index'
import { ThemeLightIcon } from '@root/graphics/ThemeLightIcon/index'
import { ChevronUpDownIcon } from '@root/icons/ChevronUpDownIcon/index'
import { useAuth } from '@root/providers/Auth/index'
import { useHeaderObserver } from '@root/providers/HeaderIntersectionObserver/index'
import { useThemePreference } from '@root/providers/Theme/index'
import { getImplicitPreference, themeLocalStorageKey } from '@root/providers/Theme/shared'
import Link from 'next/link'
Expand All @@ -22,19 +21,16 @@ export const CloudFooter = () => {
const selectRef = React.useRef<HTMLSelectElement>(null)
const themeId = useId()
const { setTheme } = useThemePreference()
const { setHeaderTheme } = useHeaderObserver()

const onThemeChange = (themeToSet: 'auto' & Theme) => {
if (themeToSet === 'auto') {
const implicitPreference = getImplicitPreference() ?? 'light'
setHeaderTheme(implicitPreference)
setTheme(implicitPreference)
if (selectRef.current) {
selectRef.current.value = 'auto'
}
} else {
setTheme(themeToSet)
setHeaderTheme(themeToSet)
}
}

Expand Down
4 changes: 0 additions & 4 deletions src/components/Footer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import { ThemeLightIcon } from '@root/graphics/ThemeLightIcon/index'
import { TwitterIconAlt } from '@root/graphics/TwitterIconAlt/index'
import { YoutubeIcon } from '@root/graphics/YoutubeIcon/index'
import { ChevronUpDownIcon } from '@root/icons/ChevronUpDownIcon/index'
import { useHeaderObserver } from '@root/providers/HeaderIntersectionObserver/index'
import { useThemePreference } from '@root/providers/Theme/index'
import { getImplicitPreference, themeLocalStorageKey } from '@root/providers/Theme/shared'
import { usePathname, useRouter } from 'next/navigation'
Expand All @@ -33,21 +32,18 @@ export const Footer: React.FC<FooterType> = (props) => {
const { columns } = props
const [products, developers, company] = columns ?? []
const { setTheme } = useThemePreference()
const { setHeaderTheme } = useHeaderObserver()
const wrapperRef = React.useRef<HTMLElement>(null)
const selectRef = React.useRef<HTMLSelectElement>(null)

const onThemeChange = (themeToSet: 'auto' & Theme) => {
if (themeToSet === 'auto') {
const implicitPreference = getImplicitPreference() ?? 'light'
setHeaderTheme(implicitPreference)
setTheme(implicitPreference)
if (selectRef.current) {
selectRef.current.value = 'auto'
}
} else {
setTheme(themeToSet)
setHeaderTheme(themeToSet)
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/providers/HeaderIntersectionObserver/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export const HeaderIntersectionObserver: React.FC<HeaderIntersectionObserverProp

React.useEffect(() => {
setHeaderTheme(theme)
}, [pathname])
}, [pathname, theme])

return (
<Context
Expand Down