Skip to content

Commit

Permalink
docs: fix TS lint error in ModeToggle.tsx
Browse files Browse the repository at this point in the history
  • Loading branch information
@casey_baggz_omni committed Oct 2, 2024
1 parent 3b45af3 commit 527976e
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions docs/app/components/ModeToggle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,28 @@ import { AnimatingMoonIcon } from './icons/AnimatingMoonIcon'
import { AnimatingSunIcon } from './icons/AnimatingSunIcon'
import { Show, useThemeContext } from '@cerberus-design/react'
import { focusStates } from '@cerberus-design/panda-preset'
import { useMemo } from 'react'
import { useCallback, useMemo, type MouseEvent } from 'react'

export function ModeToggle() {
const { mode, updateMode } = useThemeContext()
const ariaLabel = useMemo(() => {
return mode === 'light' ? 'Switch to dark mode' : 'Switch to light mode'
}, [mode])

const handleUpdateMode = useCallback((e: MouseEvent<HTMLButtonElement>) => {
const currentMode = e.currentTarget.value
updateMode(currentMode === 'light' ? 'dark' : 'light')
}, [])

return (
<button
className={css({
rounded: 'sm',
_focusVisible: focusStates._focusVisible,
})}
aria-label={ariaLabel}
onClick={updateMode}
onClick={handleUpdateMode}
value={mode}
>
<Show when={mode === 'light'} fallback={<AnimatingMoonIcon />}>
<AnimatingSunIcon />
Expand Down

0 comments on commit 527976e

Please sign in to comment.