rizzo-css 0.0.17 → 0.0.18
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/README.md +4 -4
- package/bin/rizzo-css.js +151 -103
- package/package.json +7 -3
- package/scaffold/astro-minimal/.env.example +3 -0
- package/scaffold/astro-minimal/README.md +36 -0
- package/scaffold/astro-minimal/package.json +13 -0
- package/scaffold/astro-minimal/src/layouts/Layout.astro +28 -0
- package/scaffold/astro-minimal/src/pages/index.astro +10 -0
- package/scaffold/svelte-minimal/.env.example +3 -0
- package/scaffold/svelte-minimal/README.md +37 -0
- package/scaffold/svelte-minimal/package.json +20 -0
- package/scaffold/svelte-minimal/src/app.d.ts +11 -0
- package/scaffold/svelte-minimal/src/app.html +15 -0
- package/scaffold/svelte-minimal/src/routes/+layout.svelte +1 -0
- package/scaffold/svelte-minimal/src/routes/+page.svelte +5 -0
- package/scaffold/svelte-minimal/svelte.config.js +10 -0
- package/scaffold/svelte-minimal/tsconfig.json +11 -0
- package/scaffold/vanilla/README.md +4 -4
- package/scaffold/vanilla/components/accordion.html +8 -0
- package/scaffold/vanilla/components/alert.html +8 -0
- package/scaffold/vanilla/components/avatar.html +8 -0
- package/scaffold/vanilla/components/badge.html +8 -0
- package/scaffold/vanilla/components/breadcrumb.html +8 -0
- package/scaffold/vanilla/components/button.html +8 -0
- package/scaffold/vanilla/components/cards.html +8 -0
- package/scaffold/vanilla/components/copy-to-clipboard.html +8 -0
- package/scaffold/vanilla/components/divider.html +8 -0
- package/scaffold/vanilla/components/dropdown.html +8 -0
- package/scaffold/vanilla/components/forms.html +8 -0
- package/scaffold/vanilla/components/icons.html +8 -0
- package/scaffold/vanilla/components/index.html +8 -0
- package/scaffold/vanilla/components/modal.html +8 -0
- package/scaffold/vanilla/components/navbar.html +8 -0
- package/scaffold/vanilla/components/pagination.html +8 -0
- package/scaffold/vanilla/components/progress-bar.html +8 -0
- package/scaffold/vanilla/components/search.html +8 -0
- package/scaffold/vanilla/components/settings.html +8 -0
- package/scaffold/vanilla/components/spinner.html +8 -0
- package/scaffold/vanilla/components/table.html +8 -0
- package/scaffold/vanilla/components/tabs.html +8 -0
- package/scaffold/vanilla/components/theme-switcher.html +8 -0
- package/scaffold/vanilla/components/toast.html +8 -0
- package/scaffold/vanilla/components/tooltip.html +8 -0
- package/scaffold/vanilla/index.html +8 -0
- package/scaffold/astro-app/README.md +0 -43
- package/scaffold/astro-app/package.json +0 -1
- package/scaffold/astro-app/src/components/Accordion.astro +0 -178
- package/scaffold/astro-app/src/components/Alert.astro +0 -131
- package/scaffold/astro-app/src/components/Avatar.astro +0 -59
- package/scaffold/astro-app/src/components/Badge.astro +0 -24
- package/scaffold/astro-app/src/components/Breadcrumb.astro +0 -61
- package/scaffold/astro-app/src/components/Button.astro +0 -3
- package/scaffold/astro-app/src/components/Card.astro +0 -18
- package/scaffold/astro-app/src/components/Checkbox.astro +0 -38
- package/scaffold/astro-app/src/components/CliCommandTabs.astro +0 -90
- package/scaffold/astro-app/src/components/CodeBlock.astro +0 -393
- package/scaffold/astro-app/src/components/CopyToClipboard.astro +0 -219
- package/scaffold/astro-app/src/components/Divider.astro +0 -37
- package/scaffold/astro-app/src/components/DocsSidebar.astro +0 -51
- package/scaffold/astro-app/src/components/Dropdown.astro +0 -807
- package/scaffold/astro-app/src/components/FormGroup.astro +0 -59
- package/scaffold/astro-app/src/components/FrameworkSwitcher.astro +0 -72
- package/scaffold/astro-app/src/components/Input.astro +0 -59
- package/scaffold/astro-app/src/components/Modal.astro +0 -212
- package/scaffold/astro-app/src/components/Navbar.astro +0 -623
- package/scaffold/astro-app/src/components/PackageInstallTabs.astro +0 -87
- package/scaffold/astro-app/src/components/Pagination.astro +0 -240
- package/scaffold/astro-app/src/components/ProgressBar.astro +0 -65
- package/scaffold/astro-app/src/components/Radio.astro +0 -38
- package/scaffold/astro-app/src/components/Search.astro +0 -1259
- package/scaffold/astro-app/src/components/Select.astro +0 -49
- package/scaffold/astro-app/src/components/Settings.astro +0 -382
- package/scaffold/astro-app/src/components/Spinner.astro +0 -30
- package/scaffold/astro-app/src/components/Table.astro +0 -181
- package/scaffold/astro-app/src/components/Tabs.astro +0 -223
- package/scaffold/astro-app/src/components/Textarea.astro +0 -58
- package/scaffold/astro-app/src/components/ThemeIcon.astro +0 -50
- package/scaffold/astro-app/src/components/ThemeSwitcher.astro +0 -504
- package/scaffold/astro-app/src/components/Toast.astro +0 -30
- package/scaffold/astro-app/src/components/Tooltip.astro +0 -32
- package/scaffold/astro-app/src/components/icons/Brush.astro +0 -10
- package/scaffold/astro-app/src/components/icons/Cake.astro +0 -11
- package/scaffold/astro-app/src/components/icons/Check.astro +0 -29
- package/scaffold/astro-app/src/components/icons/Cherry.astro +0 -11
- package/scaffold/astro-app/src/components/icons/ChevronDown.astro +0 -29
- package/scaffold/astro-app/src/components/icons/Circle.astro +0 -29
- package/scaffold/astro-app/src/components/icons/Close.astro +0 -30
- package/scaffold/astro-app/src/components/icons/Cmd.astro +0 -26
- package/scaffold/astro-app/src/components/icons/Copy.astro +0 -30
- package/scaffold/astro-app/src/components/icons/Eye.astro +0 -30
- package/scaffold/astro-app/src/components/icons/Filter.astro +0 -29
- package/scaffold/astro-app/src/components/icons/Flame.astro +0 -28
- package/scaffold/astro-app/src/components/icons/Flower.astro +0 -11
- package/scaffold/astro-app/src/components/icons/Gear.astro +0 -30
- package/scaffold/astro-app/src/components/icons/Heart.astro +0 -28
- package/scaffold/astro-app/src/components/icons/IceCream.astro +0 -31
- package/scaffold/astro-app/src/components/icons/Leaf.astro +0 -29
- package/scaffold/astro-app/src/components/icons/Lemon.astro +0 -11
- package/scaffold/astro-app/src/components/icons/Moon.astro +0 -29
- package/scaffold/astro-app/src/components/icons/Owl.astro +0 -34
- package/scaffold/astro-app/src/components/icons/Palette.astro +0 -33
- package/scaffold/astro-app/src/components/icons/Rainbow.astro +0 -31
- package/scaffold/astro-app/src/components/icons/Search.astro +0 -30
- package/scaffold/astro-app/src/components/icons/Shield.astro +0 -28
- package/scaffold/astro-app/src/components/icons/Snowflake.astro +0 -34
- package/scaffold/astro-app/src/components/icons/Sort.astro +0 -30
- package/scaffold/astro-app/src/components/icons/Sun.astro +0 -29
- package/scaffold/astro-app/src/components/icons/Sunset.astro +0 -10
- package/scaffold/astro-app/src/components/icons/Zap.astro +0 -9
- package/scaffold/astro-app/src/components/icons/devicons/Astro.astro +0 -53
- package/scaffold/astro-app/src/components/icons/devicons/Bash.astro +0 -34
- package/scaffold/astro-app/src/components/icons/devicons/Css3.astro +0 -29
- package/scaffold/astro-app/src/components/icons/devicons/Git.astro +0 -24
- package/scaffold/astro-app/src/components/icons/devicons/Html5.astro +0 -27
- package/scaffold/astro-app/src/components/icons/devicons/Javascript.astro +0 -25
- package/scaffold/astro-app/src/components/icons/devicons/Nodejs.astro +0 -47
- package/scaffold/astro-app/src/components/icons/devicons/Plaintext.astro +0 -33
- package/scaffold/astro-app/src/components/icons/devicons/React.astro +0 -27
- package/scaffold/astro-app/src/components/icons/devicons/Svelte.astro +0 -25
- package/scaffold/astro-app/src/components/icons/devicons/Vue.astro +0 -26
- package/scaffold/astro-app/src/config/frameworks.ts +0 -26
- package/scaffold/astro-app/src/config/themes.ts +0 -54
- package/scaffold/astro-app/src/layouts/DocsLayout.astro +0 -263
- package/scaffold/astro-app/src/layouts/Layout.astro +0 -41
- package/scaffold/astro-app/src/pages/components/accordion.astro +0 -172
- package/scaffold/astro-app/src/pages/components/alert.astro +0 -250
- package/scaffold/astro-app/src/pages/components/avatar.astro +0 -102
- package/scaffold/astro-app/src/pages/components/badge.astro +0 -119
- package/scaffold/astro-app/src/pages/components/breadcrumb.astro +0 -124
- package/scaffold/astro-app/src/pages/components/button.astro +0 -74
- package/scaffold/astro-app/src/pages/components/cards.astro +0 -247
- package/scaffold/astro-app/src/pages/components/copy-to-clipboard.astro +0 -49
- package/scaffold/astro-app/src/pages/components/divider.astro +0 -74
- package/scaffold/astro-app/src/pages/components/dropdown.astro +0 -394
- package/scaffold/astro-app/src/pages/components/forms.astro +0 -367
- package/scaffold/astro-app/src/pages/components/icons.astro +0 -246
- package/scaffold/astro-app/src/pages/components/modal.astro +0 -152
- package/scaffold/astro-app/src/pages/components/navbar.astro +0 -80
- package/scaffold/astro-app/src/pages/components/pagination.astro +0 -126
- package/scaffold/astro-app/src/pages/components/progress-bar.astro +0 -94
- package/scaffold/astro-app/src/pages/components/search.astro +0 -155
- package/scaffold/astro-app/src/pages/components/settings.astro +0 -78
- package/scaffold/astro-app/src/pages/components/spinner.astro +0 -81
- package/scaffold/astro-app/src/pages/components/table.astro +0 -144
- package/scaffold/astro-app/src/pages/components/tabs.astro +0 -220
- package/scaffold/astro-app/src/pages/components/theme-switcher.astro +0 -69
- package/scaffold/astro-app/src/pages/components/toast.astro +0 -157
- package/scaffold/astro-app/src/pages/components/tooltip.astro +0 -209
- package/scaffold/astro-app/src/pages/components.astro +0 -290
- package/scaffold/astro-app/src/pages/docs/accessibility.astro +0 -9
- package/scaffold/astro-app/src/pages/docs/colors.astro +0 -9
- package/scaffold/astro-app/src/pages/docs/design-system.astro +0 -9
- package/scaffold/astro-app/src/pages/docs/getting-started.astro +0 -9
- package/scaffold/astro-app/src/pages/docs/index.astro +0 -15
- package/scaffold/astro-app/src/pages/docs/themes/[theme].astro +0 -14
- package/scaffold/astro-app/src/pages/docs/theming.astro +0 -10
- package/scaffold/astro-app/src/pages/index.astro +0 -24
- package/scaffold/svelte-app/README.md +0 -39
- package/scaffold/svelte-app/package.json +0 -22
- package/scaffold/svelte-app/src/app.d.ts +0 -28
- package/scaffold/svelte-app/src/app.html +0 -21
- package/scaffold/svelte-app/src/lib/assets/favicon.svg +0 -1
- package/scaffold/svelte-app/src/lib/rizzo/Accordion.svelte +0 -128
- package/scaffold/svelte-app/src/lib/rizzo/Alert.svelte +0 -85
- package/scaffold/svelte-app/src/lib/rizzo/Avatar.svelte +0 -39
- package/scaffold/svelte-app/src/lib/rizzo/Badge.svelte +0 -31
- package/scaffold/svelte-app/src/lib/rizzo/Breadcrumb.svelte +0 -49
- package/scaffold/svelte-app/src/lib/rizzo/Button.svelte +0 -27
- package/scaffold/svelte-app/src/lib/rizzo/Card.svelte +0 -17
- package/scaffold/svelte-app/src/lib/rizzo/Checkbox.svelte +0 -37
- package/scaffold/svelte-app/src/lib/rizzo/CopyToClipboard.svelte +0 -79
- package/scaffold/svelte-app/src/lib/rizzo/Divider.svelte +0 -28
- package/scaffold/svelte-app/src/lib/rizzo/Dropdown.svelte +0 -254
- package/scaffold/svelte-app/src/lib/rizzo/FormGroup.svelte +0 -51
- package/scaffold/svelte-app/src/lib/rizzo/Input.svelte +0 -59
- package/scaffold/svelte-app/src/lib/rizzo/Modal.svelte +0 -157
- package/scaffold/svelte-app/src/lib/rizzo/Pagination.svelte +0 -93
- package/scaffold/svelte-app/src/lib/rizzo/ProgressBar.svelte +0 -58
- package/scaffold/svelte-app/src/lib/rizzo/Radio.svelte +0 -38
- package/scaffold/svelte-app/src/lib/rizzo/Select.svelte +0 -51
- package/scaffold/svelte-app/src/lib/rizzo/Spinner.svelte +0 -14
- package/scaffold/svelte-app/src/lib/rizzo/Table.svelte +0 -158
- package/scaffold/svelte-app/src/lib/rizzo/Tabs.svelte +0 -117
- package/scaffold/svelte-app/src/lib/rizzo/Textarea.svelte +0 -59
- package/scaffold/svelte-app/src/lib/rizzo/ThemeIcon.svelte +0 -54
- package/scaffold/svelte-app/src/lib/rizzo/ThemeSwitcher.svelte +0 -315
- package/scaffold/svelte-app/src/lib/rizzo/Toast.svelte +0 -33
- package/scaffold/svelte-app/src/lib/rizzo/Tooltip.svelte +0 -19
- package/scaffold/svelte-app/src/lib/rizzo/icons/Check.svelte +0 -29
- package/scaffold/svelte-app/src/lib/rizzo/icons/ChevronDown.svelte +0 -29
- package/scaffold/svelte-app/src/lib/rizzo/icons/Circle.svelte +0 -29
- package/scaffold/svelte-app/src/lib/rizzo/icons/Close.svelte +0 -30
- package/scaffold/svelte-app/src/lib/rizzo/icons/Cmd.svelte +0 -27
- package/scaffold/svelte-app/src/lib/rizzo/icons/Copy.svelte +0 -30
- package/scaffold/svelte-app/src/lib/rizzo/icons/Eye.svelte +0 -30
- package/scaffold/svelte-app/src/lib/rizzo/icons/Filter.svelte +0 -29
- package/scaffold/svelte-app/src/lib/rizzo/icons/Gear.svelte +0 -30
- package/scaffold/svelte-app/src/lib/rizzo/icons/IceCream.svelte +0 -31
- package/scaffold/svelte-app/src/lib/rizzo/icons/Moon.svelte +0 -29
- package/scaffold/svelte-app/src/lib/rizzo/icons/Owl.svelte +0 -34
- package/scaffold/svelte-app/src/lib/rizzo/icons/Palette.svelte +0 -33
- package/scaffold/svelte-app/src/lib/rizzo/icons/Rainbow.svelte +0 -31
- package/scaffold/svelte-app/src/lib/rizzo/icons/Search.svelte +0 -30
- package/scaffold/svelte-app/src/lib/rizzo/icons/Snowflake.svelte +0 -34
- package/scaffold/svelte-app/src/lib/rizzo/icons/Sort.svelte +0 -30
- package/scaffold/svelte-app/src/lib/rizzo/icons/devicons/Astro.svelte +0 -45
- package/scaffold/svelte-app/src/lib/rizzo/icons/devicons/Bash.svelte +0 -28
- package/scaffold/svelte-app/src/lib/rizzo/icons/devicons/Css3.svelte +0 -23
- package/scaffold/svelte-app/src/lib/rizzo/icons/devicons/Git.svelte +0 -18
- package/scaffold/svelte-app/src/lib/rizzo/icons/devicons/Html5.svelte +0 -21
- package/scaffold/svelte-app/src/lib/rizzo/icons/devicons/Javascript.svelte +0 -19
- package/scaffold/svelte-app/src/lib/rizzo/icons/devicons/Nodejs.svelte +0 -44
- package/scaffold/svelte-app/src/lib/rizzo/icons/devicons/Plaintext.svelte +0 -24
- package/scaffold/svelte-app/src/lib/rizzo/icons/devicons/React.svelte +0 -21
- package/scaffold/svelte-app/src/lib/rizzo/icons/devicons/SvelteIcon.svelte +0 -19
- package/scaffold/svelte-app/src/lib/rizzo/icons/devicons/Vue.svelte +0 -20
- package/scaffold/svelte-app/src/lib/rizzo/index.ts +0 -35
- package/scaffold/svelte-app/src/lib/rizzo-docs/CodeBlock.svelte +0 -239
- package/scaffold/svelte-app/src/lib/rizzo-docs/SvelteDocPage.svelte +0 -99
- package/scaffold/svelte-app/src/lib/rizzo-docs/pages/AccordionDoc.svelte +0 -53
- package/scaffold/svelte-app/src/lib/rizzo-docs/pages/AlertDoc.svelte +0 -114
- package/scaffold/svelte-app/src/lib/rizzo-docs/pages/AvatarDoc.svelte +0 -92
- package/scaffold/svelte-app/src/lib/rizzo-docs/pages/BadgeDoc.svelte +0 -60
- package/scaffold/svelte-app/src/lib/rizzo-docs/pages/BreadcrumbDoc.svelte +0 -55
- package/scaffold/svelte-app/src/lib/rizzo-docs/pages/ButtonDoc.svelte +0 -55
- package/scaffold/svelte-app/src/lib/rizzo-docs/pages/CardsDoc.svelte +0 -173
- package/scaffold/svelte-app/src/lib/rizzo-docs/pages/ComingSoon.svelte +0 -12
- package/scaffold/svelte-app/src/lib/rizzo-docs/pages/ComponentsOverview.svelte +0 -92
- package/scaffold/svelte-app/src/lib/rizzo-docs/pages/CopyToClipboardDoc.svelte +0 -26
- package/scaffold/svelte-app/src/lib/rizzo-docs/pages/DividerDoc.svelte +0 -105
- package/scaffold/svelte-app/src/lib/rizzo-docs/pages/DropdownDoc.svelte +0 -161
- package/scaffold/svelte-app/src/lib/rizzo-docs/pages/FormsDoc.svelte +0 -375
- package/scaffold/svelte-app/src/lib/rizzo-docs/pages/IconsDoc.svelte +0 -246
- package/scaffold/svelte-app/src/lib/rizzo-docs/pages/Index.svelte +0 -8
- package/scaffold/svelte-app/src/lib/rizzo-docs/pages/ModalDoc.svelte +0 -50
- package/scaffold/svelte-app/src/lib/rizzo-docs/pages/NavbarDoc.svelte +0 -79
- package/scaffold/svelte-app/src/lib/rizzo-docs/pages/PaginationDoc.svelte +0 -44
- package/scaffold/svelte-app/src/lib/rizzo-docs/pages/ProgressBarDoc.svelte +0 -95
- package/scaffold/svelte-app/src/lib/rizzo-docs/pages/SearchDoc.svelte +0 -147
- package/scaffold/svelte-app/src/lib/rizzo-docs/pages/SettingsDoc.svelte +0 -158
- package/scaffold/svelte-app/src/lib/rizzo-docs/pages/SpinnerDoc.svelte +0 -41
- package/scaffold/svelte-app/src/lib/rizzo-docs/pages/TableDoc.svelte +0 -116
- package/scaffold/svelte-app/src/lib/rizzo-docs/pages/TabsDoc.svelte +0 -152
- package/scaffold/svelte-app/src/lib/rizzo-docs/pages/ThemeSwitcherDoc.svelte +0 -189
- package/scaffold/svelte-app/src/lib/rizzo-docs/pages/Theming.svelte +0 -6
- package/scaffold/svelte-app/src/lib/rizzo-docs/pages/ToastDoc.svelte +0 -136
- package/scaffold/svelte-app/src/lib/rizzo-docs/pages/TooltipDoc.svelte +0 -57
- package/scaffold/svelte-app/src/routes/+layout.svelte +0 -10
- package/scaffold/svelte-app/src/routes/+page.svelte +0 -31
- package/scaffold/svelte-app/src/routes/components/+page.svelte +0 -4
- package/scaffold/svelte-app/src/routes/components/[slug]/+page.svelte +0 -7
- package/scaffold/svelte-app/static/robots.txt +0 -3
- package/scaffold/svelte-app/svelte.config.js +0 -13
- package/scaffold/svelte-app/tsconfig.json +0 -21
- package/scaffold/svelte-app/vite.config.ts +0 -6
- /package/scaffold/{astro-app → astro-minimal}/astro.config.mjs +0 -0
- /package/scaffold/{astro-app → astro-minimal}/public/.gitkeep +0 -0
- /package/scaffold/{astro-app → astro-minimal}/public/favicon.svg +0 -0
- /package/scaffold/{astro-app → astro-minimal}/tsconfig.json +0 -0
- /package/scaffold/{svelte-app → svelte-minimal}/static/.gitkeep +0 -0
|
@@ -1,504 +0,0 @@
|
|
|
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>
|
|
@@ -1,30 +0,0 @@
|
|
|
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>
|
|
@@ -1,32 +0,0 @@
|
|
|
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>
|
|
@@ -1,10 +0,0 @@
|
|
|
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>
|
|
@@ -1,11 +0,0 @@
|
|
|
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>
|
|
@@ -1,29 +0,0 @@
|
|
|
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>
|
|
@@ -1,11 +0,0 @@
|
|
|
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>
|
|
@@ -1,29 +0,0 @@
|
|
|
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>
|