import { Listbox, Transition } from '@headlessui/react'; import { ComputerDesktopIcon, MoonIcon, SunIcon, } from '@heroicons/react/24/outline'; import cx from 'classnames'; import { ElementType, Fragment } from 'react'; import { Theme, useTheme } from './theme.provider'; export function ThemeSwitcher(): JSX.Element { const [theme, setTheme] = useTheme(); const themeMap = { dark: { className: 'group-hover:text-white', icon: , }, light: { className: 'group-hover:text-yellow-500', icon: , }, system: { className: 'group-hover:text-blue-500', icon: , }, }; const availableThemes: { label: string; value: Theme; icon: ElementType }[] = [ { label: 'Light', value: 'light', icon: SunIcon, }, { label: 'Dark', value: 'dark', icon: MoonIcon, }, { label: 'System', value: 'system', icon: ComputerDesktopIcon, }, ]; return (
Theme {themeMap[theme].icon} {availableThemes.map((t) => ( {({ active, selected }) => (
  • )}
    ))}
    ); }