'use client'
import { cn } from '../../utils'
import { useSidebarContext } from '../Navigation'
import { DarkMode, LightMode, SystemMode } from './icons'
type Mode = 'system' | 'light' | 'dark'
export type DarkModeToggleProps = {
/** Current theme mode. When undefined, the toggle does not render. */
theme: string | undefined
/** Updates the active theme mode. Usually provided by `next-themes`. */
setTheme: (theme: Mode) => void
}
const Modes: { mode: Mode; icon: React.ReactElement }[] = [
{ mode: 'system', icon: },
{ mode: 'light', icon: },
{ mode: 'dark', icon: },
]
export type ThemeToggleProps = {
/** Theme state and setter used to switch between system, light, and dark modes. */
darkModeToggle: DarkModeToggleProps
}
/**
* Compact control for switching between system, light, and dark theme modes.
* Intended for use inside navigation surfaces such as the Shell sidebar.
*/
export const ThemeToggle = ({ darkModeToggle }: ThemeToggleProps) => {
const { theme, setTheme } = darkModeToggle
const sidebarContext = useSidebarContext()
if (!theme) {
return null
}
return (
{Modes.map(({ mode, icon }) => (
))}
)
}