rizzo-css 0.0.11 → 0.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env.example +12 -0
- package/LICENSE +21 -0
- package/README.md +17 -3
- package/bin/rizzo-css.js +98 -42
- package/dist/rizzo.min.css +3 -2
- package/package.json +5 -3
- package/scaffold/astro-app/README.md +13 -2
- package/scaffold/astro-app/src/components/Accordion.astro +178 -0
- package/scaffold/astro-app/src/components/Alert.astro +131 -0
- package/scaffold/astro-app/src/components/Avatar.astro +59 -0
- package/scaffold/astro-app/src/components/Badge.astro +24 -0
- package/scaffold/astro-app/src/components/Breadcrumb.astro +61 -0
- package/scaffold/astro-app/src/components/Button.astro +3 -0
- package/scaffold/astro-app/src/components/Card.astro +18 -0
- package/scaffold/astro-app/src/components/Checkbox.astro +38 -0
- package/scaffold/astro-app/src/components/CodeBlock.astro +393 -0
- package/scaffold/astro-app/src/components/CopyToClipboard.astro +219 -0
- package/scaffold/astro-app/src/components/Divider.astro +37 -0
- package/scaffold/astro-app/src/components/Dropdown.astro +807 -0
- package/scaffold/astro-app/src/components/FormGroup.astro +59 -0
- package/scaffold/astro-app/src/components/FrameworkSwitcher.astro +72 -0
- package/scaffold/astro-app/src/components/Input.astro +59 -0
- package/scaffold/astro-app/src/components/Modal.astro +212 -0
- package/scaffold/astro-app/src/components/Navbar.astro +701 -0
- package/scaffold/astro-app/src/components/Pagination.astro +240 -0
- package/scaffold/astro-app/src/components/ProgressBar.astro +65 -0
- package/scaffold/astro-app/src/components/Radio.astro +38 -0
- package/scaffold/astro-app/src/components/Search.astro +1259 -0
- package/scaffold/astro-app/src/components/Select.astro +49 -0
- package/scaffold/astro-app/src/components/Settings.astro +382 -0
- package/scaffold/astro-app/src/components/Spinner.astro +30 -0
- package/scaffold/astro-app/src/components/Table.astro +181 -0
- package/scaffold/astro-app/src/components/Tabs.astro +223 -0
- package/scaffold/astro-app/src/components/Textarea.astro +58 -0
- package/scaffold/astro-app/src/components/ThemeSwitcher.astro +504 -0
- package/scaffold/astro-app/src/components/Toast.astro +30 -0
- package/scaffold/astro-app/src/components/Tooltip.astro +32 -0
- package/scaffold/astro-app/src/components/icons/Brush.astro +10 -0
- package/scaffold/astro-app/src/components/icons/Cake.astro +11 -0
- package/scaffold/astro-app/src/components/icons/Check.astro +29 -0
- package/scaffold/astro-app/src/components/icons/Cherry.astro +11 -0
- package/scaffold/astro-app/src/components/icons/ChevronDown.astro +29 -0
- package/scaffold/astro-app/src/components/icons/Circle.astro +29 -0
- package/scaffold/astro-app/src/components/icons/Close.astro +30 -0
- package/scaffold/astro-app/src/components/icons/Cmd.astro +26 -0
- package/scaffold/astro-app/src/components/icons/Copy.astro +30 -0
- package/scaffold/astro-app/src/components/icons/Eye.astro +30 -0
- package/scaffold/astro-app/src/components/icons/Filter.astro +29 -0
- package/scaffold/astro-app/src/components/icons/Flame.astro +28 -0
- package/scaffold/astro-app/src/components/icons/Flower.astro +11 -0
- package/scaffold/astro-app/src/components/icons/Gear.astro +30 -0
- package/scaffold/astro-app/src/components/icons/Heart.astro +28 -0
- package/scaffold/astro-app/src/components/icons/IceCream.astro +31 -0
- package/scaffold/astro-app/src/components/icons/Leaf.astro +29 -0
- package/scaffold/astro-app/src/components/icons/Lemon.astro +11 -0
- package/scaffold/astro-app/src/components/icons/Moon.astro +29 -0
- package/scaffold/astro-app/src/components/icons/Owl.astro +34 -0
- package/scaffold/astro-app/src/components/icons/Palette.astro +33 -0
- package/scaffold/astro-app/src/components/icons/Rainbow.astro +31 -0
- package/scaffold/astro-app/src/components/icons/Search.astro +30 -0
- package/scaffold/astro-app/src/components/icons/Shield.astro +28 -0
- package/scaffold/astro-app/src/components/icons/Snowflake.astro +34 -0
- package/scaffold/astro-app/src/components/icons/Sort.astro +30 -0
- package/scaffold/astro-app/src/components/icons/Sun.astro +29 -0
- package/scaffold/astro-app/src/components/icons/Sunset.astro +10 -0
- package/scaffold/astro-app/src/components/icons/Zap.astro +9 -0
- package/scaffold/astro-app/src/components/icons/devicons/Astro.astro +53 -0
- package/scaffold/astro-app/src/components/icons/devicons/Bash.astro +34 -0
- package/scaffold/astro-app/src/components/icons/devicons/Css3.astro +29 -0
- package/scaffold/astro-app/src/components/icons/devicons/Git.astro +24 -0
- package/scaffold/astro-app/src/components/icons/devicons/Html5.astro +27 -0
- package/scaffold/astro-app/src/components/icons/devicons/Javascript.astro +25 -0
- package/scaffold/astro-app/src/components/icons/devicons/Nodejs.astro +47 -0
- package/scaffold/astro-app/src/components/icons/devicons/Plaintext.astro +33 -0
- package/scaffold/astro-app/src/components/icons/devicons/React.astro +27 -0
- package/scaffold/astro-app/src/components/icons/devicons/Svelte.astro +25 -0
- package/scaffold/astro-app/src/components/icons/devicons/Vue.astro +26 -0
- package/scaffold/astro-app/src/config/frameworks.ts +26 -0
- package/scaffold/astro-app/src/config/themes.ts +54 -0
- package/scaffold/astro-app/src/layouts/DocsLayout.astro +204 -0
- package/scaffold/astro-app/src/layouts/Layout.astro +11 -2
- package/scaffold/astro-app/src/pages/components/accordion.astro +172 -0
- package/scaffold/astro-app/src/pages/components/alert.astro +250 -0
- package/scaffold/astro-app/src/pages/components/avatar.astro +102 -0
- package/scaffold/astro-app/src/pages/components/badge.astro +119 -0
- package/scaffold/astro-app/src/pages/components/breadcrumb.astro +124 -0
- package/scaffold/astro-app/src/pages/components/button.astro +74 -0
- package/scaffold/astro-app/src/pages/components/cards.astro +247 -0
- package/scaffold/astro-app/src/pages/components/copy-to-clipboard.astro +49 -0
- package/scaffold/astro-app/src/pages/components/divider.astro +74 -0
- package/scaffold/astro-app/src/pages/components/dropdown.astro +394 -0
- package/scaffold/astro-app/src/pages/components/forms.astro +367 -0
- package/scaffold/astro-app/src/pages/components/icons.astro +246 -0
- package/scaffold/astro-app/src/pages/components/modal.astro +152 -0
- package/scaffold/astro-app/src/pages/components/navbar.astro +80 -0
- package/scaffold/astro-app/src/pages/components/pagination.astro +126 -0
- package/scaffold/astro-app/src/pages/components/progress-bar.astro +94 -0
- package/scaffold/astro-app/src/pages/components/search.astro +155 -0
- package/scaffold/astro-app/src/pages/components/settings.astro +78 -0
- package/scaffold/astro-app/src/pages/components/spinner.astro +81 -0
- package/scaffold/astro-app/src/pages/components/table.astro +144 -0
- package/scaffold/astro-app/src/pages/components/tabs.astro +220 -0
- package/scaffold/astro-app/src/pages/components/theme-switcher.astro +67 -0
- package/scaffold/astro-app/src/pages/components/toast.astro +157 -0
- package/scaffold/astro-app/src/pages/components/tooltip.astro +209 -0
- package/scaffold/astro-app/src/pages/components.astro +290 -0
- package/scaffold/astro-app/src/pages/docs/accessibility.astro +9 -0
- package/scaffold/astro-app/src/pages/docs/colors.astro +9 -0
- package/scaffold/astro-app/src/pages/docs/design-system.astro +9 -0
- package/scaffold/astro-app/src/pages/docs/getting-started.astro +9 -0
- package/scaffold/astro-app/src/pages/docs/index.astro +15 -0
- package/scaffold/astro-app/src/pages/docs/themes/[theme].astro +14 -0
- package/scaffold/astro-app/src/pages/docs/theming.astro +10 -0
- package/scaffold/astro-app/src/pages/index.astro +5 -11
- package/scaffold/svelte/Table.svelte +6 -5
- package/scaffold/svelte/Tabs.svelte +3 -1
- package/scaffold/svelte-app/README.md +9 -2
- package/scaffold/svelte-app/src/app.html +1 -1
- package/scaffold/svelte-app/src/lib/rizzo/Accordion.svelte +128 -0
- package/scaffold/svelte-app/src/lib/rizzo/Alert.svelte +85 -0
- package/scaffold/svelte-app/src/lib/rizzo/Avatar.svelte +39 -0
- package/scaffold/svelte-app/src/lib/rizzo/Badge.svelte +31 -0
- package/scaffold/svelte-app/src/lib/rizzo/Breadcrumb.svelte +49 -0
- package/scaffold/svelte-app/src/lib/rizzo/Button.svelte +27 -0
- package/scaffold/svelte-app/src/lib/rizzo/Card.svelte +17 -0
- package/scaffold/svelte-app/src/lib/rizzo/Checkbox.svelte +37 -0
- package/scaffold/svelte-app/src/lib/rizzo/CopyToClipboard.svelte +79 -0
- package/scaffold/svelte-app/src/lib/rizzo/Divider.svelte +28 -0
- package/scaffold/svelte-app/src/lib/rizzo/Dropdown.svelte +254 -0
- package/scaffold/svelte-app/src/lib/rizzo/FormGroup.svelte +51 -0
- package/scaffold/svelte-app/src/lib/rizzo/Input.svelte +59 -0
- package/scaffold/svelte-app/src/lib/rizzo/Modal.svelte +157 -0
- package/scaffold/svelte-app/src/lib/rizzo/Pagination.svelte +93 -0
- package/scaffold/svelte-app/src/lib/rizzo/ProgressBar.svelte +58 -0
- package/scaffold/svelte-app/src/lib/rizzo/Radio.svelte +38 -0
- package/scaffold/svelte-app/src/lib/rizzo/Select.svelte +51 -0
- package/scaffold/svelte-app/src/lib/rizzo/Spinner.svelte +14 -0
- package/scaffold/svelte-app/src/lib/rizzo/Table.svelte +158 -0
- package/scaffold/svelte-app/src/lib/rizzo/Tabs.svelte +117 -0
- package/scaffold/svelte-app/src/lib/rizzo/Textarea.svelte +59 -0
- package/scaffold/svelte-app/src/lib/rizzo/ThemeSwitcher.svelte +315 -0
- package/scaffold/svelte-app/src/lib/rizzo/Toast.svelte +33 -0
- package/scaffold/svelte-app/src/lib/rizzo/Tooltip.svelte +19 -0
- package/scaffold/svelte-app/src/lib/rizzo/icons/Check.svelte +29 -0
- package/scaffold/svelte-app/src/lib/rizzo/icons/ChevronDown.svelte +29 -0
- package/scaffold/svelte-app/src/lib/rizzo/icons/Circle.svelte +29 -0
- package/scaffold/svelte-app/src/lib/rizzo/icons/Close.svelte +30 -0
- package/scaffold/svelte-app/src/lib/rizzo/icons/Cmd.svelte +27 -0
- package/scaffold/svelte-app/src/lib/rizzo/icons/Copy.svelte +30 -0
- package/scaffold/svelte-app/src/lib/rizzo/icons/Eye.svelte +30 -0
- package/scaffold/svelte-app/src/lib/rizzo/icons/Filter.svelte +29 -0
- package/scaffold/svelte-app/src/lib/rizzo/icons/Gear.svelte +30 -0
- package/scaffold/svelte-app/src/lib/rizzo/icons/IceCream.svelte +31 -0
- package/scaffold/svelte-app/src/lib/rizzo/icons/Moon.svelte +29 -0
- package/scaffold/svelte-app/src/lib/rizzo/icons/Owl.svelte +34 -0
- package/scaffold/svelte-app/src/lib/rizzo/icons/Palette.svelte +33 -0
- package/scaffold/svelte-app/src/lib/rizzo/icons/Rainbow.svelte +31 -0
- package/scaffold/svelte-app/src/lib/rizzo/icons/Search.svelte +30 -0
- package/scaffold/svelte-app/src/lib/rizzo/icons/Snowflake.svelte +34 -0
- package/scaffold/svelte-app/src/lib/rizzo/icons/Sort.svelte +30 -0
- package/scaffold/svelte-app/src/lib/rizzo/icons/devicons/Astro.svelte +45 -0
- package/scaffold/svelte-app/src/lib/rizzo/icons/devicons/Bash.svelte +28 -0
- package/scaffold/svelte-app/src/lib/rizzo/icons/devicons/Css3.svelte +23 -0
- package/scaffold/svelte-app/src/lib/rizzo/icons/devicons/Git.svelte +18 -0
- package/scaffold/svelte-app/src/lib/rizzo/icons/devicons/Html5.svelte +21 -0
- package/scaffold/svelte-app/src/lib/rizzo/icons/devicons/Javascript.svelte +19 -0
- package/scaffold/svelte-app/src/lib/rizzo/icons/devicons/Nodejs.svelte +44 -0
- package/scaffold/svelte-app/src/lib/rizzo/icons/devicons/Plaintext.svelte +24 -0
- package/scaffold/svelte-app/src/lib/rizzo/icons/devicons/React.svelte +21 -0
- package/scaffold/svelte-app/src/lib/rizzo/icons/devicons/SvelteIcon.svelte +19 -0
- package/scaffold/svelte-app/src/lib/rizzo/icons/devicons/Vue.svelte +20 -0
- package/scaffold/svelte-app/src/lib/rizzo/index.ts +33 -0
- package/scaffold/svelte-app/src/lib/rizzo-docs/CodeBlock.svelte +239 -0
- package/scaffold/svelte-app/src/lib/rizzo-docs/SvelteDocPage.svelte +99 -0
- package/scaffold/svelte-app/src/lib/rizzo-docs/pages/AccordionDoc.svelte +53 -0
- package/scaffold/svelte-app/src/lib/rizzo-docs/pages/AlertDoc.svelte +114 -0
- package/scaffold/svelte-app/src/lib/rizzo-docs/pages/AvatarDoc.svelte +92 -0
- package/scaffold/svelte-app/src/lib/rizzo-docs/pages/BadgeDoc.svelte +60 -0
- package/scaffold/svelte-app/src/lib/rizzo-docs/pages/BreadcrumbDoc.svelte +55 -0
- package/scaffold/svelte-app/src/lib/rizzo-docs/pages/ButtonDoc.svelte +55 -0
- package/scaffold/svelte-app/src/lib/rizzo-docs/pages/CardsDoc.svelte +173 -0
- package/scaffold/svelte-app/src/lib/rizzo-docs/pages/ComingSoon.svelte +12 -0
- package/scaffold/svelte-app/src/lib/rizzo-docs/pages/ComponentsOverview.svelte +92 -0
- package/scaffold/svelte-app/src/lib/rizzo-docs/pages/CopyToClipboardDoc.svelte +26 -0
- package/scaffold/svelte-app/src/lib/rizzo-docs/pages/DividerDoc.svelte +105 -0
- package/scaffold/svelte-app/src/lib/rizzo-docs/pages/DropdownDoc.svelte +161 -0
- package/scaffold/svelte-app/src/lib/rizzo-docs/pages/FormsDoc.svelte +375 -0
- package/scaffold/svelte-app/src/lib/rizzo-docs/pages/IconsDoc.svelte +246 -0
- package/scaffold/svelte-app/src/lib/rizzo-docs/pages/Index.svelte +8 -0
- package/scaffold/svelte-app/src/lib/rizzo-docs/pages/ModalDoc.svelte +50 -0
- package/scaffold/svelte-app/src/lib/rizzo-docs/pages/NavbarDoc.svelte +79 -0
- package/scaffold/svelte-app/src/lib/rizzo-docs/pages/PaginationDoc.svelte +44 -0
- package/scaffold/svelte-app/src/lib/rizzo-docs/pages/ProgressBarDoc.svelte +95 -0
- package/scaffold/svelte-app/src/lib/rizzo-docs/pages/SearchDoc.svelte +147 -0
- package/scaffold/svelte-app/src/lib/rizzo-docs/pages/SettingsDoc.svelte +158 -0
- package/scaffold/svelte-app/src/lib/rizzo-docs/pages/SpinnerDoc.svelte +41 -0
- package/scaffold/svelte-app/src/lib/rizzo-docs/pages/TableDoc.svelte +116 -0
- package/scaffold/svelte-app/src/lib/rizzo-docs/pages/TabsDoc.svelte +152 -0
- package/scaffold/svelte-app/src/lib/rizzo-docs/pages/ThemeSwitcherDoc.svelte +181 -0
- package/scaffold/svelte-app/src/lib/rizzo-docs/pages/Theming.svelte +6 -0
- package/scaffold/svelte-app/src/lib/rizzo-docs/pages/ToastDoc.svelte +136 -0
- package/scaffold/svelte-app/src/lib/rizzo-docs/pages/TooltipDoc.svelte +57 -0
- package/scaffold/svelte-app/src/routes/+page.svelte +2 -2
- package/scaffold/svelte-app/src/routes/components/+page.svelte +4 -0
- package/scaffold/svelte-app/src/routes/components/[slug]/+page.svelte +7 -0
- package/scaffold/vanilla/README.md +20 -8
- package/scaffold/vanilla/components/accordion.html +187 -0
- package/scaffold/vanilla/components/alert.html +187 -0
- package/scaffold/vanilla/components/avatar.html +187 -0
- package/scaffold/vanilla/components/badge.html +187 -0
- package/scaffold/vanilla/components/breadcrumb.html +187 -0
- package/scaffold/vanilla/components/button.html +187 -0
- package/scaffold/vanilla/components/cards.html +187 -0
- package/scaffold/vanilla/components/copy-to-clipboard.html +187 -0
- package/scaffold/vanilla/components/divider.html +187 -0
- package/scaffold/vanilla/components/dropdown.html +187 -0
- package/scaffold/vanilla/components/forms.html +187 -0
- package/scaffold/vanilla/components/icons.html +187 -0
- package/scaffold/vanilla/components/index.html +212 -0
- package/scaffold/vanilla/components/modal.html +187 -0
- package/scaffold/vanilla/components/navbar.html +187 -0
- package/scaffold/vanilla/components/pagination.html +187 -0
- package/scaffold/vanilla/components/progress-bar.html +187 -0
- package/scaffold/vanilla/components/search.html +187 -0
- package/scaffold/vanilla/components/settings.html +187 -0
- package/scaffold/vanilla/components/spinner.html +187 -0
- package/scaffold/vanilla/components/table.html +187 -0
- package/scaffold/vanilla/components/tabs.html +187 -0
- package/scaffold/vanilla/components/theme-switcher.html +187 -0
- package/scaffold/vanilla/components/toast.html +187 -0
- package/scaffold/vanilla/components/tooltip.html +187 -0
- package/scaffold/vanilla/index.html +17 -283
- package/scaffold/vanilla/js/main.js +748 -0
|
@@ -0,0 +1,504 @@
|
|
|
1
|
+
---
|
|
2
|
+
import ChevronDown from './icons/ChevronDown.astro';
|
|
3
|
+
import Gear from './icons/Gear.astro';
|
|
4
|
+
import Palette from './icons/Palette.astro';
|
|
5
|
+
import Owl from './icons/Owl.astro';
|
|
6
|
+
import Sun from './icons/Sun.astro';
|
|
7
|
+
import Flame from './icons/Flame.astro';
|
|
8
|
+
import Heart from './icons/Heart.astro';
|
|
9
|
+
import Leaf from './icons/Leaf.astro';
|
|
10
|
+
import Shield from './icons/Shield.astro';
|
|
11
|
+
import Zap from './icons/Zap.astro';
|
|
12
|
+
import Cake from './icons/Cake.astro';
|
|
13
|
+
import Sunset from './icons/Sunset.astro';
|
|
14
|
+
import Cherry from './icons/Cherry.astro';
|
|
15
|
+
import Brush from './icons/Brush.astro';
|
|
16
|
+
import Lemon from './icons/Lemon.astro';
|
|
17
|
+
import Rainbow from './icons/Rainbow.astro';
|
|
18
|
+
import type { ThemeIconKey } from '../config/themes';
|
|
19
|
+
import { THEMES_DARK, THEMES_LIGHT } from '../config/themes';
|
|
20
|
+
|
|
21
|
+
const iconMap: Record<ThemeIconKey, typeof Owl> = {
|
|
22
|
+
gear: Gear,
|
|
23
|
+
owl: Owl,
|
|
24
|
+
palette: Palette,
|
|
25
|
+
flame: Flame,
|
|
26
|
+
sunset: Sunset,
|
|
27
|
+
zap: Zap,
|
|
28
|
+
shield: Shield,
|
|
29
|
+
heart: Heart,
|
|
30
|
+
sun: Sun,
|
|
31
|
+
cake: Cake,
|
|
32
|
+
lemon: Lemon,
|
|
33
|
+
rainbow: Rainbow,
|
|
34
|
+
leaf: Leaf,
|
|
35
|
+
cherry: Cherry,
|
|
36
|
+
brush: Brush,
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const themes = {
|
|
40
|
+
dark: THEMES_DARK.map((t) => ({ ...t, icon: iconMap[t.iconKey] })),
|
|
41
|
+
light: THEMES_LIGHT.map((t) => ({ ...t, icon: iconMap[t.iconKey] })),
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
// Get current theme from HTML data attribute or default
|
|
46
|
+
const getCurrentTheme = () => {
|
|
47
|
+
if (typeof document !== 'undefined') {
|
|
48
|
+
return document.documentElement.getAttribute('data-theme') || 'github-dark-classic';
|
|
49
|
+
}
|
|
50
|
+
return 'github-dark-classic';
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
// System preference theme id (stored in localStorage; data-theme gets resolved to dark/light default)
|
|
54
|
+
const THEME_SYSTEM = 'system';
|
|
55
|
+
const DEFAULT_THEME_DARK = 'github-dark-classic';
|
|
56
|
+
const DEFAULT_THEME_LIGHT = 'github-light';
|
|
57
|
+
|
|
58
|
+
// Get theme info helper
|
|
59
|
+
const getThemeInfo = (themeValue: string) => {
|
|
60
|
+
if (themeValue === THEME_SYSTEM) return { value: THEME_SYSTEM, label: 'System', icon: Gear };
|
|
61
|
+
const allThemes = [...themes.dark, ...themes.light];
|
|
62
|
+
return allThemes.find(t => t.value === themeValue) || null;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
// Get initial theme info (will be updated by script, but set initial value)
|
|
66
|
+
const currentTheme = getCurrentTheme();
|
|
67
|
+
const initialTheme = getThemeInfo(currentTheme);
|
|
68
|
+
const initialLabel = initialTheme ? initialTheme.label : 'Theme';
|
|
69
|
+
const InitialIcon = initialTheme ? initialTheme.icon : null;
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
<div class="theme-switcher" data-theme-switcher>
|
|
74
|
+
<button
|
|
75
|
+
class="theme-switcher__trigger"
|
|
76
|
+
type="button"
|
|
77
|
+
aria-expanded="false"
|
|
78
|
+
aria-haspopup="true"
|
|
79
|
+
aria-controls="theme-menu"
|
|
80
|
+
aria-label="Select theme"
|
|
81
|
+
id="theme-trigger"
|
|
82
|
+
>
|
|
83
|
+
<span class="theme-switcher__label-wrapper" data-theme-label-wrapper>
|
|
84
|
+
<span class="theme-switcher__label" data-theme-label>{initialLabel}</span>
|
|
85
|
+
</span>
|
|
86
|
+
<ChevronDown class="theme-switcher__icon" width={16} height={16} />
|
|
87
|
+
</button>
|
|
88
|
+
|
|
89
|
+
<div
|
|
90
|
+
class="theme-switcher__menu"
|
|
91
|
+
id="theme-menu"
|
|
92
|
+
role="menu"
|
|
93
|
+
aria-labelledby="theme-trigger"
|
|
94
|
+
aria-label="Theme selection menu"
|
|
95
|
+
aria-orientation="vertical"
|
|
96
|
+
aria-hidden="true"
|
|
97
|
+
tabindex="-1"
|
|
98
|
+
>
|
|
99
|
+
<div class="theme-switcher__menu-options">
|
|
100
|
+
<div class="theme-switcher__group" role="group" aria-label="Preference">
|
|
101
|
+
<div class="theme-switcher__group-label" role="presentation">Preference</div>
|
|
102
|
+
<div
|
|
103
|
+
class="theme-switcher__option"
|
|
104
|
+
role="menuitemradio"
|
|
105
|
+
aria-checked="false"
|
|
106
|
+
tabindex={-1}
|
|
107
|
+
data-theme-value="system"
|
|
108
|
+
data-theme-type="system"
|
|
109
|
+
data-theme-bg="oklch(55% 0.02 270deg)"
|
|
110
|
+
data-theme-accent=""
|
|
111
|
+
>
|
|
112
|
+
<Gear width={16} height={16} class="theme-switcher__option-icon" />
|
|
113
|
+
<span class="sr-only">Preference: </span>
|
|
114
|
+
System
|
|
115
|
+
</div>
|
|
116
|
+
</div>
|
|
117
|
+
<div class="theme-switcher__group" role="group" aria-label="Dark themes">
|
|
118
|
+
<div class="theme-switcher__group-label" role="presentation">Dark</div>
|
|
119
|
+
{themes.dark.map((theme) => {
|
|
120
|
+
const IconComponent = theme.icon;
|
|
121
|
+
return (
|
|
122
|
+
<div
|
|
123
|
+
class="theme-switcher__option"
|
|
124
|
+
role="menuitemradio"
|
|
125
|
+
aria-checked="false"
|
|
126
|
+
tabindex={-1}
|
|
127
|
+
data-theme-value={theme.value}
|
|
128
|
+
data-theme-type="dark"
|
|
129
|
+
data-theme-bg={theme.bg}
|
|
130
|
+
data-theme-accent={theme.accent}
|
|
131
|
+
data-theme-label={theme.label}
|
|
132
|
+
>
|
|
133
|
+
<IconComponent width={16} height={16} class="theme-switcher__option-icon" />
|
|
134
|
+
<span class="sr-only">Dark theme: </span>
|
|
135
|
+
{theme.label}
|
|
136
|
+
</div>
|
|
137
|
+
);
|
|
138
|
+
})}
|
|
139
|
+
</div>
|
|
140
|
+
|
|
141
|
+
<div class="theme-switcher__group" role="group" aria-label="Light themes">
|
|
142
|
+
<div class="theme-switcher__group-label" role="presentation">Light</div>
|
|
143
|
+
{themes.light.map((theme) => {
|
|
144
|
+
const IconComponent = theme.icon;
|
|
145
|
+
return (
|
|
146
|
+
<div
|
|
147
|
+
class="theme-switcher__option"
|
|
148
|
+
role="menuitemradio"
|
|
149
|
+
aria-checked="false"
|
|
150
|
+
tabindex={-1}
|
|
151
|
+
data-theme-value={theme.value}
|
|
152
|
+
data-theme-type="light"
|
|
153
|
+
data-theme-bg={theme.bg}
|
|
154
|
+
data-theme-accent={theme.accent}
|
|
155
|
+
data-theme-label={theme.label}
|
|
156
|
+
>
|
|
157
|
+
<IconComponent width={16} height={16} class="theme-switcher__option-icon" />
|
|
158
|
+
<span class="sr-only">Light theme: </span>
|
|
159
|
+
{theme.label}
|
|
160
|
+
</div>
|
|
161
|
+
);
|
|
162
|
+
})}
|
|
163
|
+
</div>
|
|
164
|
+
</div>
|
|
165
|
+
<div class="theme-switcher__preview" data-theme-preview aria-hidden="true">
|
|
166
|
+
<div class="theme-switcher__preview-title">Preview</div>
|
|
167
|
+
<div class="theme-switcher__preview-header" data-theme-preview-label></div>
|
|
168
|
+
<div class="theme-switcher__preview-swatch-wrap">
|
|
169
|
+
<div class="theme-switcher__preview-swatch" data-theme-preview-swatch></div>
|
|
170
|
+
</div>
|
|
171
|
+
<div class="theme-switcher__preview-accent" data-theme-preview-accent></div>
|
|
172
|
+
</div>
|
|
173
|
+
</div>
|
|
174
|
+
</div>
|
|
175
|
+
|
|
176
|
+
<script>
|
|
177
|
+
import {
|
|
178
|
+
applyTheme,
|
|
179
|
+
getStoredTheme,
|
|
180
|
+
getCurrentTheme,
|
|
181
|
+
resolveSystemTheme,
|
|
182
|
+
getThemeLabel,
|
|
183
|
+
THEME_SYSTEM,
|
|
184
|
+
} from '../utils/theme';
|
|
185
|
+
|
|
186
|
+
(function initThemeSwitcher() {
|
|
187
|
+
const getIconSVG = (themeValue: string) => {
|
|
188
|
+
const svgMap: Record<string, string> = {
|
|
189
|
+
'system': '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z" /><circle cx="12" cy="12" r="3" /></svg>',
|
|
190
|
+
'github-dark-classic': '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M16 7h.01" /><path d="M3.4 18H12a8 8 0 0 0 8-8V7a4 4 0 0 0-7.28-2.3L2 20" /><path d="m20 7 2 .5-2 .5" /><path d="M10 18v3" /><path d="M14 17.75V21" /><path d="M7 18a6 6 0 0 0 3.84-10.61" /></svg>',
|
|
191
|
+
'github-light': '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="4" /><path d="M12 2v2M12 20v2M4.93 4.93l1.41 1.41M17.66 17.66l1.41 1.41M2 12h2M20 12h2M6.34 17.66l-1.41 1.41M19.07 4.93l-1.41 1.41" /></svg>',
|
|
192
|
+
'red-velvet-cupcake': '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M20 21v-8a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v8" /><path d="M4 16s1-1 4-1 5 2 8 2 4-1 4-1V4" /><path d="M2 16v4M22 16v4M8 8h.01M16 8h.01M8 12h.01M16 12h.01" /></svg>',
|
|
193
|
+
'orangy-one-light': '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M15.5 6.5c.5-2.5 2.5-4 5-4 1.5 0 2.5.5 3 1" /><path d="M12 12c-2 2-3 4-3 6 0 3 2 5 5 5 2 0 4-1 6-3" /><path d="M18 12c2 2 3 4 3 6 0 3-2 5-5 5-2 0-4-1-6-3" /></svg>',
|
|
194
|
+
'sunflower': '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M22 17a10 10 0 0 0-20 0" /><path d="M6 17a6 6 0 0 1 12 0" /><path d="M10 17a2 2 0 0 1 4 0" /></svg>',
|
|
195
|
+
'shades-of-purple': '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M12 21a9 9 0 0 1 0 -18c4.97 0 9 3.582 9 8c0 1.06 -.474 2.078 -1.318 2.828c-.844 .75 -1.989 1.172 -3.182 1.172h-2.5a2 2 0 0 0 -1 3.75a1.3 1.3 0 0 1 -1 2.25"/><path d="M7.5 10.5a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"/><path d="M11.5 7.5a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"/><path d="M15.5 10.5a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"/></svg>',
|
|
196
|
+
'sandstorm-classic': '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M8.5 14.5A2.5 2.5 0 0 0 11 12c0-1.38-.5-2-1-3-1.072-2.143-.224-4.054 2-6 .5 2.5 2 4.9 4 6.5 2 1.6 3 3.5 3 5.5a7 7 0 1 1-14 0c0-1.153.433-2.294 1-3a2.5 2.5 0 0 0 2.5 2.5z" /></svg>',
|
|
197
|
+
'rocky-blood-orange': '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 10V2M4.93 10.93l1.41 1.41M2 18h2M20 18h2M17.66 10.93l1.41-1.41M22 22H2M8 6l4-4 4 4M16 18a4 4 0 0 0-8 0" /><path d="M12 22v-4" /></svg>',
|
|
198
|
+
'minimal-dark-neon-yellow': '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M13 2 3 14h9l-1 8 10-12h-9l1-8z" /></svg>',
|
|
199
|
+
'hack-the-box': '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z" /></svg>',
|
|
200
|
+
'green-breeze-light': '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M11 20A7 7 0 0 1 9.8 6.1C15.5 5 17 4.48 19 2c1 2 2 4.18 2 8 0 5.5-4.78 10-10 10Z" /><path d="M2 21c0-3 1.85-5.36 5.08-6C9.5 14.52 12 13 13 12" /></svg>',
|
|
201
|
+
'pink-cat-boo': '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M19.5 12.572l-7.5 7.428l-7.5 -7.428a5 5 0 1 1 7.5 -6.566a5 5 0 1 1 7.5 6.572" /></svg>',
|
|
202
|
+
'cute-pink': '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M9 18c0-2 1.5-4 4-4s4 2 4 4c0 2-1.5 4-4 4s-4-2-4-4Z" /><path d="M15 18c0-2 1.5-4 4-4s4 2 4 4c0 2-1.5 4-4 4s-4-2-4-4Z" /><path d="M12 8v4M10 10l-2 2M14 10l2 2" /></svg>',
|
|
203
|
+
'semi-light-purple': '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m9.06 11.9 8.07-8.06a2.85 2.85 0 1 1 4.03 4.03l-8.06 8.08" /><path d="M7.87 14.14c-.32.32-.67.68-1.06 1.06a5.04 5.04 0 0 1-2.17 1.22c-.47.15-.85.2-1.15.2-.16 0-.3-.02-.41-.03a1 1 0 0 1-.63-.97c-.01-.14.02-.31.07-.51.1-.41.3-.95.6-1.59.3-.64.67-1.33 1.08-2.05" /></svg>',
|
|
204
|
+
};
|
|
205
|
+
return svgMap[themeValue] || '';
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
// Update all switchers on the page
|
|
209
|
+
// When called from applyTheme, pass stored + currentTheme so we don't rely on DOM/localStorage being updated yet
|
|
210
|
+
const updateAllSwitchers = (overrideStored?: string | null, overrideCurrentTheme?: string | null) => {
|
|
211
|
+
const stored = (overrideStored != null ? String(overrideStored) : getStoredTheme() || '').trim();
|
|
212
|
+
const currentTheme = (overrideCurrentTheme != null ? String(overrideCurrentTheme) : getCurrentTheme() || '').trim();
|
|
213
|
+
document.querySelectorAll('[data-theme-switcher]').forEach((switcher) => {
|
|
214
|
+
const label = switcher.querySelector('[data-theme-label]');
|
|
215
|
+
const labelWrapper = switcher.querySelector('[data-theme-label-wrapper]');
|
|
216
|
+
const options = switcher.querySelectorAll('.theme-switcher__option');
|
|
217
|
+
|
|
218
|
+
if (label && labelWrapper) {
|
|
219
|
+
const themeLabel = stored === THEME_SYSTEM ? 'System' : getThemeLabel(currentTheme);
|
|
220
|
+
label.textContent = themeLabel;
|
|
221
|
+
|
|
222
|
+
// Update icon
|
|
223
|
+
const existingIcon = labelWrapper.querySelector('[data-theme-label-icon]');
|
|
224
|
+
if (existingIcon) {
|
|
225
|
+
existingIcon.remove();
|
|
226
|
+
}
|
|
227
|
+
const iconTheme = stored === THEME_SYSTEM ? THEME_SYSTEM : currentTheme;
|
|
228
|
+
const iconSvg = getIconSVG(iconTheme);
|
|
229
|
+
if (iconSvg) {
|
|
230
|
+
const iconElement = document.createElement('span');
|
|
231
|
+
iconElement.setAttribute('data-theme-label-icon', '');
|
|
232
|
+
iconElement.className = 'theme-switcher__label-icon';
|
|
233
|
+
iconElement.innerHTML = iconSvg;
|
|
234
|
+
labelWrapper.insertBefore(iconElement, label);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
// Update options: when System is selected, both System and the resolved theme show active styles
|
|
239
|
+
const resolvedThemeBg = stored === THEME_SYSTEM
|
|
240
|
+
? (Array.from(options).find((opt) => (opt.getAttribute('data-theme-value') || '').trim() === currentTheme)?.getAttribute('data-theme-bg') || null)
|
|
241
|
+
: null;
|
|
242
|
+
options.forEach((option) => {
|
|
243
|
+
const el = option as HTMLElement;
|
|
244
|
+
const optionValue = (el.getAttribute('data-theme-value') || '').trim();
|
|
245
|
+
const isStoredChoice = optionValue === stored;
|
|
246
|
+
const isResolvedTheme = stored === THEME_SYSTEM && optionValue === currentTheme;
|
|
247
|
+
const isActive = isStoredChoice || isResolvedTheme;
|
|
248
|
+
el.setAttribute('aria-checked', isStoredChoice.toString());
|
|
249
|
+
if (isActive) {
|
|
250
|
+
el.classList.add('theme-switcher__option--active');
|
|
251
|
+
const themeBg = optionValue === THEME_SYSTEM && resolvedThemeBg
|
|
252
|
+
? resolvedThemeBg
|
|
253
|
+
: el.getAttribute('data-theme-bg');
|
|
254
|
+
if (themeBg) {
|
|
255
|
+
el.style.setProperty('--theme-bg', themeBg);
|
|
256
|
+
}
|
|
257
|
+
} else {
|
|
258
|
+
el.classList.remove('theme-switcher__option--active');
|
|
259
|
+
el.style.removeProperty('--theme-bg');
|
|
260
|
+
}
|
|
261
|
+
});
|
|
262
|
+
});
|
|
263
|
+
};
|
|
264
|
+
|
|
265
|
+
// Sync UI when theme changes (from util or other tabs)
|
|
266
|
+
window.addEventListener('rizzo-theme-change', () => updateAllSwitchers());
|
|
267
|
+
|
|
268
|
+
// Initialize all theme switcher instances on the page
|
|
269
|
+
const switchers = document.querySelectorAll('[data-theme-switcher]');
|
|
270
|
+
if (!switchers.length) return;
|
|
271
|
+
|
|
272
|
+
switchers.forEach((switcher) => {
|
|
273
|
+
const trigger = switcher.querySelector('.theme-switcher__trigger') as HTMLButtonElement | null;
|
|
274
|
+
const menu = switcher.querySelector('.theme-switcher__menu') as HTMLElement | null;
|
|
275
|
+
const options = switcher.querySelectorAll('.theme-switcher__option') as NodeListOf<HTMLElement>;
|
|
276
|
+
|
|
277
|
+
if (!trigger || !menu) return;
|
|
278
|
+
|
|
279
|
+
// Toggle menu
|
|
280
|
+
const toggleMenu = (open?: boolean) => {
|
|
281
|
+
const isOpen = open !== undefined ? open : menu.classList.contains('theme-switcher__menu--open');
|
|
282
|
+
const willBeOpen = !isOpen;
|
|
283
|
+
|
|
284
|
+
menu.classList.toggle('theme-switcher__menu--open', willBeOpen);
|
|
285
|
+
trigger.setAttribute('aria-expanded', willBeOpen.toString());
|
|
286
|
+
menu.setAttribute('aria-hidden', (!willBeOpen).toString());
|
|
287
|
+
|
|
288
|
+
options.forEach((option) => {
|
|
289
|
+
option.setAttribute('tabindex', willBeOpen ? '0' : '-1');
|
|
290
|
+
});
|
|
291
|
+
|
|
292
|
+
if (!willBeOpen) {
|
|
293
|
+
trigger.focus();
|
|
294
|
+
} else {
|
|
295
|
+
updateAllSwitchers();
|
|
296
|
+
updatePreview(null);
|
|
297
|
+
const firstOption = options[0];
|
|
298
|
+
if (firstOption) {
|
|
299
|
+
setTimeout(() => (firstOption as HTMLElement).focus(), 0);
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
};
|
|
303
|
+
|
|
304
|
+
// Close menu
|
|
305
|
+
const closeMenu = () => {
|
|
306
|
+
menu.classList.remove('theme-switcher__menu--open');
|
|
307
|
+
trigger.setAttribute('aria-expanded', 'false');
|
|
308
|
+
menu.setAttribute('aria-hidden', 'true');
|
|
309
|
+
options.forEach((option) => {
|
|
310
|
+
option.setAttribute('tabindex', '-1');
|
|
311
|
+
});
|
|
312
|
+
};
|
|
313
|
+
|
|
314
|
+
// Close on outside click handler
|
|
315
|
+
const handleOutsideClick = (e: MouseEvent) => {
|
|
316
|
+
const target = e.target as Node | null;
|
|
317
|
+
if (target && !switcher.contains(target)) {
|
|
318
|
+
closeMenu();
|
|
319
|
+
document.removeEventListener('click', handleOutsideClick);
|
|
320
|
+
}
|
|
321
|
+
};
|
|
322
|
+
|
|
323
|
+
// Wrapped toggle menu that handles outside clicks
|
|
324
|
+
const wrappedToggleMenu = (open?: boolean) => {
|
|
325
|
+
const wasOpen = menu.classList.contains('theme-switcher__menu--open');
|
|
326
|
+
toggleMenu(open);
|
|
327
|
+
const isNowOpen = menu.classList.contains('theme-switcher__menu--open');
|
|
328
|
+
|
|
329
|
+
if (isNowOpen && !wasOpen) {
|
|
330
|
+
setTimeout(() => document.addEventListener('click', handleOutsideClick), 0);
|
|
331
|
+
} else if (!isNowOpen && wasOpen) {
|
|
332
|
+
document.removeEventListener('click', handleOutsideClick);
|
|
333
|
+
}
|
|
334
|
+
};
|
|
335
|
+
|
|
336
|
+
// Theme preview: show on hover/focus of an option that has accent
|
|
337
|
+
const preview = switcher.querySelector('[data-theme-preview]') as HTMLElement | null;
|
|
338
|
+
const previewSwatch = switcher.querySelector('[data-theme-preview-swatch]') as HTMLElement | null;
|
|
339
|
+
const previewAccent = switcher.querySelector('[data-theme-preview-accent]') as HTMLElement | null;
|
|
340
|
+
|
|
341
|
+
const previewLabel = switcher.querySelector('[data-theme-preview-label]') as HTMLElement | null;
|
|
342
|
+
const getActiveOption = (): HTMLElement | null => {
|
|
343
|
+
const active = Array.from(options).filter((opt) => (opt as HTMLElement).classList.contains('theme-switcher__option--active'));
|
|
344
|
+
const withTheme = active.find((opt) => (opt as HTMLElement).getAttribute('data-theme-value') !== THEME_SYSTEM) as HTMLElement | undefined;
|
|
345
|
+
return (withTheme ?? active[0] ?? null) as HTMLElement | null;
|
|
346
|
+
};
|
|
347
|
+
const getResolvedOption = (): HTMLElement | null => {
|
|
348
|
+
return (Array.from(options).find((opt) => (opt as HTMLElement).getAttribute('data-theme-value') !== THEME_SYSTEM && (opt as HTMLElement).classList.contains('theme-switcher__option--active')) as HTMLElement) ?? null;
|
|
349
|
+
};
|
|
350
|
+
const updatePreview = (option: HTMLElement | null) => {
|
|
351
|
+
if (!preview || !previewSwatch || !previewAccent) return;
|
|
352
|
+
const target = option ?? getActiveOption();
|
|
353
|
+
if (!target) {
|
|
354
|
+
preview.style.removeProperty('--preview-accent');
|
|
355
|
+
previewSwatch.style.backgroundColor = '';
|
|
356
|
+
if (previewLabel) previewLabel.textContent = '';
|
|
357
|
+
preview.setAttribute('aria-hidden', 'true');
|
|
358
|
+
return;
|
|
359
|
+
}
|
|
360
|
+
const value = target.getAttribute('data-theme-value') || '';
|
|
361
|
+
const isSystem = value === THEME_SYSTEM;
|
|
362
|
+
const resolved = getResolvedOption();
|
|
363
|
+
const bg = isSystem
|
|
364
|
+
? (getComputedStyle(target).getPropertyValue('--theme-bg').trim() || resolved?.getAttribute('data-theme-bg'))
|
|
365
|
+
: target.getAttribute('data-theme-bg');
|
|
366
|
+
const accent = isSystem ? (resolved?.getAttribute('data-theme-accent') || '') : (target.getAttribute('data-theme-accent') || '');
|
|
367
|
+
const label = isSystem ? 'System' : (target.getAttribute('data-theme-label') || '');
|
|
368
|
+
previewSwatch.style.backgroundColor = bg || '';
|
|
369
|
+
preview.style.setProperty('--preview-accent', accent);
|
|
370
|
+
if (previewLabel) previewLabel.textContent = label;
|
|
371
|
+
preview.setAttribute('aria-hidden', 'false');
|
|
372
|
+
};
|
|
373
|
+
|
|
374
|
+
options.forEach((option) => {
|
|
375
|
+
const el = option as HTMLElement;
|
|
376
|
+
el.addEventListener('mouseenter', () => updatePreview(el));
|
|
377
|
+
el.addEventListener('focus', () => updatePreview(el));
|
|
378
|
+
});
|
|
379
|
+
menu.addEventListener('mouseleave', () => {
|
|
380
|
+
const focused = menu.contains(document.activeElement);
|
|
381
|
+
if (!focused) updatePreview(null);
|
|
382
|
+
});
|
|
383
|
+
menu.addEventListener('focusout', (e) => {
|
|
384
|
+
const related = (e as FocusEvent).relatedTarget as Node | null;
|
|
385
|
+
if (!related || !menu.contains(related)) updatePreview(null);
|
|
386
|
+
});
|
|
387
|
+
|
|
388
|
+
// Event listeners
|
|
389
|
+
trigger.addEventListener('click', () => wrappedToggleMenu(undefined));
|
|
390
|
+
|
|
391
|
+
menu.addEventListener('click', (e) => {
|
|
392
|
+
const target = e.target as HTMLElement | null;
|
|
393
|
+
if (!target) return;
|
|
394
|
+
const option = target.closest('.theme-switcher__option');
|
|
395
|
+
if (option) {
|
|
396
|
+
const themeValue = (option as HTMLElement).getAttribute('data-theme-value');
|
|
397
|
+
if (themeValue) {
|
|
398
|
+
applyTheme(themeValue);
|
|
399
|
+
updateAllSwitchers();
|
|
400
|
+
closeMenu();
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
});
|
|
404
|
+
|
|
405
|
+
// Keyboard navigation
|
|
406
|
+
let currentIndex = -1;
|
|
407
|
+
|
|
408
|
+
const getVisibleOptions = () => {
|
|
409
|
+
return Array.from(options).filter(opt => {
|
|
410
|
+
return opt.offsetParent !== null || opt.closest('.theme-switcher__menu--open');
|
|
411
|
+
});
|
|
412
|
+
};
|
|
413
|
+
|
|
414
|
+
trigger.addEventListener('keydown', (e) => {
|
|
415
|
+
if (e.key === 'Enter' || e.key === ' ') {
|
|
416
|
+
e.preventDefault();
|
|
417
|
+
wrappedToggleMenu();
|
|
418
|
+
} else if (e.key === 'ArrowDown') {
|
|
419
|
+
e.preventDefault();
|
|
420
|
+
const visibleOptions = getVisibleOptions();
|
|
421
|
+
if (visibleOptions.length > 0) {
|
|
422
|
+
currentIndex = 0;
|
|
423
|
+
wrappedToggleMenu(true);
|
|
424
|
+
setTimeout(() => visibleOptions[0].focus(), 0);
|
|
425
|
+
}
|
|
426
|
+
} else if (e.key === 'ArrowUp') {
|
|
427
|
+
e.preventDefault();
|
|
428
|
+
const visibleOptions = getVisibleOptions();
|
|
429
|
+
if (visibleOptions.length > 0) {
|
|
430
|
+
currentIndex = visibleOptions.length - 1;
|
|
431
|
+
wrappedToggleMenu(true);
|
|
432
|
+
setTimeout(() => visibleOptions[currentIndex].focus(), 0);
|
|
433
|
+
}
|
|
434
|
+
} else if (e.key === 'Escape') {
|
|
435
|
+
e.preventDefault();
|
|
436
|
+
closeMenu();
|
|
437
|
+
}
|
|
438
|
+
});
|
|
439
|
+
|
|
440
|
+
menu.addEventListener('keydown', (e) => {
|
|
441
|
+
const visibleOptions = getVisibleOptions();
|
|
442
|
+
|
|
443
|
+
if (e.key === 'Escape') {
|
|
444
|
+
e.preventDefault();
|
|
445
|
+
closeMenu();
|
|
446
|
+
trigger.focus();
|
|
447
|
+
currentIndex = -1;
|
|
448
|
+
} else if (e.key === 'ArrowDown') {
|
|
449
|
+
e.preventDefault();
|
|
450
|
+
currentIndex = (currentIndex + 1) % visibleOptions.length;
|
|
451
|
+
visibleOptions[currentIndex].focus();
|
|
452
|
+
} else if (e.key === 'ArrowUp') {
|
|
453
|
+
e.preventDefault();
|
|
454
|
+
currentIndex = currentIndex <= 0 ? visibleOptions.length - 1 : currentIndex - 1;
|
|
455
|
+
visibleOptions[currentIndex].focus();
|
|
456
|
+
} else if (e.key === 'Home') {
|
|
457
|
+
e.preventDefault();
|
|
458
|
+
currentIndex = 0;
|
|
459
|
+
visibleOptions[0].focus();
|
|
460
|
+
} else if (e.key === 'End') {
|
|
461
|
+
e.preventDefault();
|
|
462
|
+
currentIndex = visibleOptions.length - 1;
|
|
463
|
+
visibleOptions[currentIndex].focus();
|
|
464
|
+
} else if (e.key === 'Enter' || e.key === ' ') {
|
|
465
|
+
e.preventDefault();
|
|
466
|
+
const target = e.target as HTMLElement | null;
|
|
467
|
+
if (!target) return;
|
|
468
|
+
const themeValue = target.getAttribute('data-theme-value');
|
|
469
|
+
if (themeValue) {
|
|
470
|
+
applyTheme(themeValue);
|
|
471
|
+
updateAllSwitchers();
|
|
472
|
+
closeMenu();
|
|
473
|
+
trigger.focus(); // Return focus to trigger after selection
|
|
474
|
+
}
|
|
475
|
+
} else if (e.key === 'Tab') {
|
|
476
|
+
// Close menu when Tab is pressed (allows natural tab flow)
|
|
477
|
+
closeMenu();
|
|
478
|
+
// Don't prevent default - allow Tab to continue naturally
|
|
479
|
+
}
|
|
480
|
+
});
|
|
481
|
+
|
|
482
|
+
});
|
|
483
|
+
|
|
484
|
+
// Initialize all switchers
|
|
485
|
+
setTimeout(() => {
|
|
486
|
+
const savedTheme = localStorage.getItem('theme');
|
|
487
|
+
if (savedTheme) {
|
|
488
|
+
applyTheme(savedTheme);
|
|
489
|
+
updateAllSwitchers();
|
|
490
|
+
} else {
|
|
491
|
+
updateAllSwitchers();
|
|
492
|
+
}
|
|
493
|
+
}, 0);
|
|
494
|
+
|
|
495
|
+
// When "System" is selected, update theme when OS preference changes
|
|
496
|
+
const systemMedia = window.matchMedia('(prefers-color-scheme: dark)');
|
|
497
|
+
systemMedia.addEventListener('change', () => {
|
|
498
|
+
if (getStoredTheme() === THEME_SYSTEM) {
|
|
499
|
+
applyTheme(THEME_SYSTEM);
|
|
500
|
+
updateAllSwitchers();
|
|
501
|
+
}
|
|
502
|
+
});
|
|
503
|
+
})();
|
|
504
|
+
</script>
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
---
|
|
2
|
+
import Alert from './Alert.astro';
|
|
3
|
+
|
|
4
|
+
interface Props {
|
|
5
|
+
variant?: 'success' | 'error' | 'warning' | 'info';
|
|
6
|
+
dismissible?: boolean;
|
|
7
|
+
autoDismiss?: number; // Duration in milliseconds (0 = disabled)
|
|
8
|
+
position?: 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left' | 'top-center' | 'bottom-center';
|
|
9
|
+
class?: string;
|
|
10
|
+
id?: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const {
|
|
14
|
+
variant = 'info',
|
|
15
|
+
dismissible = true,
|
|
16
|
+
autoDismiss = 5000, // Default 5 seconds for toasts
|
|
17
|
+
position = 'top-right',
|
|
18
|
+
class: className = '',
|
|
19
|
+
id,
|
|
20
|
+
} = Astro.props;
|
|
21
|
+
|
|
22
|
+
const positionClass = `toast--${position}`;
|
|
23
|
+
const toastClasses = `toast ${positionClass} ${className}`.trim();
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
<div class={toastClasses} data-toast-container>
|
|
27
|
+
<Alert variant={variant} dismissible={dismissible} autoDismiss={autoDismiss} id={id}>
|
|
28
|
+
<slot />
|
|
29
|
+
</Alert>
|
|
30
|
+
</div>
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
---
|
|
2
|
+
interface Props {
|
|
3
|
+
text: string;
|
|
4
|
+
position?: 'top' | 'bottom' | 'left' | 'right';
|
|
5
|
+
delay?: number;
|
|
6
|
+
class?: string;
|
|
7
|
+
id?: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const {
|
|
11
|
+
text,
|
|
12
|
+
position = 'top',
|
|
13
|
+
delay = 0,
|
|
14
|
+
class: className = '',
|
|
15
|
+
id,
|
|
16
|
+
} = Astro.props;
|
|
17
|
+
|
|
18
|
+
const tooltipId = id || `tooltip-${Math.random().toString(36).substr(2, 9)}`;
|
|
19
|
+
const positionClass = `tooltip--${position}`;
|
|
20
|
+
const classes = `tooltip ${positionClass} ${className}`.trim();
|
|
21
|
+
const delayStyle = delay > 0 ? `--tooltip-delay: ${delay}ms;` : '';
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
<span
|
|
25
|
+
class={classes}
|
|
26
|
+
role="tooltip"
|
|
27
|
+
id={tooltipId}
|
|
28
|
+
aria-hidden="true"
|
|
29
|
+
style={delayStyle}
|
|
30
|
+
>
|
|
31
|
+
{text}
|
|
32
|
+
</span>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
---
|
|
2
|
+
// Paint brush icon (for Semi Light Purple theme)
|
|
3
|
+
interface Props { width?: number; height?: number; class?: string; }
|
|
4
|
+
const { width = 16, height = 16, class: className = '' } = Astro.props;
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
<svg xmlns="http://www.w3.org/2000/svg" width={width} height={height} viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class={className} aria-hidden="true">
|
|
8
|
+
<path d="m9.06 11.9 8.07-8.06a2.85 2.85 0 1 1 4.03 4.03l-8.06 8.08" />
|
|
9
|
+
<path d="M7.87 14.14c-.32.32-.67.68-1.06 1.06a5.04 5.04 0 0 1-2.17 1.22c-.47.15-.85.2-1.15.2-.16 0-.3-.02-.41-.03a1 1 0 0 1-.63-.97c-.01-.14.02-.31.07-.51.1-.41.3-.95.6-1.59.3-.64.67-1.33 1.08-2.05" />
|
|
10
|
+
</svg>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
---
|
|
2
|
+
// Cake icon (for Red Velvet Cupcake theme)
|
|
3
|
+
interface Props { width?: number; height?: number; class?: string; }
|
|
4
|
+
const { width = 16, height = 16, class: className = '' } = Astro.props;
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
<svg xmlns="http://www.w3.org/2000/svg" width={width} height={height} viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class={className} aria-hidden="true">
|
|
8
|
+
<path d="M20 21v-8a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v8" />
|
|
9
|
+
<path d="M4 16s1-1 4-1 5 2 8 2 4-1 4-1V4" />
|
|
10
|
+
<path d="M2 16v4M22 16v4M8 8h.01M16 8h.01M8 12h.01M16 12h.01" />
|
|
11
|
+
</svg>
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
---
|
|
2
|
+
// Tabler Icons - Check
|
|
3
|
+
// Source: https://tabler.io/icons/icon/check
|
|
4
|
+
// License: MIT
|
|
5
|
+
|
|
6
|
+
interface Props {
|
|
7
|
+
width?: number;
|
|
8
|
+
height?: number;
|
|
9
|
+
class?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const { width = 16, height = 16, class: className = '' } = Astro.props;
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
<svg
|
|
16
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
17
|
+
width={width}
|
|
18
|
+
height={height}
|
|
19
|
+
viewBox="0 0 24 24"
|
|
20
|
+
fill="none"
|
|
21
|
+
stroke="currentColor"
|
|
22
|
+
stroke-width="2"
|
|
23
|
+
stroke-linecap="round"
|
|
24
|
+
stroke-linejoin="round"
|
|
25
|
+
class={`icon ${className}`.trim()}
|
|
26
|
+
aria-hidden="true"
|
|
27
|
+
>
|
|
28
|
+
<path d="M20 6L9 17l-5-5" />
|
|
29
|
+
</svg>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
---
|
|
2
|
+
// Cherry icon (for Cute Pink theme)
|
|
3
|
+
interface Props { width?: number; height?: number; class?: string; }
|
|
4
|
+
const { width = 16, height = 16, class: className = '' } = Astro.props;
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
<svg xmlns="http://www.w3.org/2000/svg" width={width} height={height} viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class={className} aria-hidden="true">
|
|
8
|
+
<path d="M9 18c0-2 1.5-4 4-4s4 2 4 4c0 2-1.5 4-4 4s-4-2-4-4Z" />
|
|
9
|
+
<path d="M15 18c0-2 1.5-4 4-4s4 2 4 4c0 2-1.5 4-4 4s-4-2-4-4Z" />
|
|
10
|
+
<path d="M12 8v4M10 10l-2 2M14 10l2 2" />
|
|
11
|
+
</svg>
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
---
|
|
2
|
+
// Tabler Icons - Chevron Down
|
|
3
|
+
// Source: https://tabler.io/icons/icon/chevron-down
|
|
4
|
+
// License: MIT
|
|
5
|
+
|
|
6
|
+
interface Props {
|
|
7
|
+
width?: number;
|
|
8
|
+
height?: number;
|
|
9
|
+
class?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const { width = 16, height = 16, class: className = '' } = Astro.props;
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
<svg
|
|
16
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
17
|
+
width={width}
|
|
18
|
+
height={height}
|
|
19
|
+
viewBox="0 0 24 24"
|
|
20
|
+
fill="none"
|
|
21
|
+
stroke="currentColor"
|
|
22
|
+
stroke-width="2"
|
|
23
|
+
stroke-linecap="round"
|
|
24
|
+
stroke-linejoin="round"
|
|
25
|
+
class={`icon ${className}`.trim()}
|
|
26
|
+
aria-hidden="true"
|
|
27
|
+
>
|
|
28
|
+
<path d="m6 9 6 6 6-6" />
|
|
29
|
+
</svg>
|