()
| 4 | import { useTheme } from "./ThemeProvider"; |
| 5 | |
| 6 | export function ThemeModeToggler() { |
| 7 | const [theme, setTheme] = useTheme(); |
| 8 | |
| 9 | const toggleTheme = () => { |
| 10 | setTheme((prevTheme) => (prevTheme === "light" ? "dark" : "light")); |
| 11 | }; |
| 12 | const SwitchIcon = theme === "light" ? MoonIcon : SunIcon; |
| 13 | |
| 14 | useHotkeys("alt+t", () => toggleTheme(), [toggleTheme]); |
| 15 | |
| 16 | return ( |
| 17 | <button |
| 18 | className={`flex text-xl items-center px-2 py-1.5 transition ${ |
| 19 | theme === "light" |
| 20 | ? "text-slate-800 hover:bg-slate-300" |
| 21 | : "text-white hover:bg-slate-700" |
| 22 | }`} |
| 23 | onClick={toggleTheme} |
| 24 | > |
| 25 | <SwitchIcon /> |
| 26 | </button> |
| 27 | ); |
| 28 | } |
nothing calls this directly
no test coverage detected