feat(ui): add light theme toggle
This commit is contained in:
parent
bbc81cea0d
commit
cdb269e505
17 changed files with 415 additions and 24 deletions
30
src/lib/ui/components/ThemeToggle.tsx
Normal file
30
src/lib/ui/components/ThemeToggle.tsx
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
import type { UiTheme } from "../theme";
|
||||
import { getNextUiTheme } from "../theme";
|
||||
import { IconGlyph } from "./IconGlyph";
|
||||
|
||||
export interface ThemeToggleProps {
|
||||
theme: UiTheme;
|
||||
onThemeChange: (theme: UiTheme) => void;
|
||||
}
|
||||
|
||||
export function ThemeToggle({ theme, onThemeChange }: ThemeToggleProps) {
|
||||
const nextTheme = getNextUiTheme(theme);
|
||||
const label = `Switch to ${nextTheme} theme`;
|
||||
|
||||
return (
|
||||
<button
|
||||
aria-label={label}
|
||||
aria-pressed={theme === "dark"}
|
||||
className="theme-toggle"
|
||||
data-ui-theme-toggle="true"
|
||||
onClick={() => onThemeChange(nextTheme)}
|
||||
type="button"
|
||||
>
|
||||
<IconGlyph
|
||||
name={theme === "dark" ? "mdi:weather-night" : "mdi:white-balance-sunny"}
|
||||
size="sm"
|
||||
/>
|
||||
<span>{theme === "dark" ? "Dark" : "Light"}</span>
|
||||
</button>
|
||||
);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue