mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-04-03 00:05:01 -05:00
25 lines
641 B
TypeScript
25 lines
641 B
TypeScript
import { Theme, useTheme } from "~/modules/theme";
|
|
import { MoonIcon } from "../icons/Moon";
|
|
import { SunIcon } from "../icons/Sun";
|
|
|
|
export function ColorModeToggle() {
|
|
const [, setTheme] = useTheme();
|
|
|
|
const toggleTheme = () => {
|
|
setTheme((prevTheme) =>
|
|
prevTheme === Theme.LIGHT ? Theme.DARK : Theme.LIGHT
|
|
);
|
|
};
|
|
|
|
return (
|
|
<button
|
|
className="layout__header__button"
|
|
onClick={toggleTheme}
|
|
data-cy="theme-switch-button"
|
|
>
|
|
<SunIcon className="light-mode-only layout__header__button__icon" />
|
|
<MoonIcon className="dark-mode-only layout__header__button__icon" />
|
|
</button>
|
|
);
|
|
}
|