Skip to content

add: update dependency added #60

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 8 commits into from
Closed
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
17 changes: 15 additions & 2 deletions custom-implementation/src/components/theme-switch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,26 @@ import React, { useEffect } from 'react'
import * as DropdownMenu from '@radix-ui/react-dropdown-menu'

export const ThemeSwitch = () => {
const [path, setPath] = React.useState(window.location.pathname)
const [selected, setSelected] = React.useState('public')

useEffect(() => {
const beta = window.location.pathname.split('/').includes('beta')
setSelected(beta ? 'beta' : 'public')
const listenToPopstate = () => {
const winPath = window.location.pathname
console.log('listenToPopstate called', winPath)
setPath(winPath)
}

console.log('listenToPopstate added')
window.addEventListener('popstate', listenToPopstate)
}, [])

useEffect(() => {
const beta = path.split('/').includes('beta')
console.log('path changed', path, beta)
setSelected(beta ? 'beta' : 'public')
}, [path])

return (
<div className="mt-2">
<DropdownMenu.Root>
Expand Down
Loading