@stacksjs/components 0.2.3
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 +477 -0
- package/dist/Accordion-x2gjedap.stx +108 -0
- package/dist/Audio-0fk6p9tn.stx +50 -0
- package/dist/Avatar-5m0v0s4x.stx +88 -0
- package/dist/Badge-ynes82vv.stx +70 -0
- package/dist/Breadcrumb-h9n427sk.stx +79 -0
- package/dist/Button-7xtrzn14.stx +89 -0
- package/dist/Calendar-egvx1pma.stx +232 -0
- package/dist/Card-r9w7vy1a.stx +74 -0
- package/dist/Checkbox-m8v46pmx.stx +92 -0
- package/dist/Checkout-vcnnr176.stx +39 -0
- package/dist/CodeBlock-mwex82cm.stx +57 -0
- package/dist/Combobox-npb08vkp.stx +13 -0
- package/dist/ComboboxButton-vcdyq4zw.stx +13 -0
- package/dist/ComboboxInput-c9d2p02m.stx +25 -0
- package/dist/ComboboxOption-7d0h9ash.stx +52 -0
- package/dist/ComboboxOptions-4dtqc0qa.stx +12 -0
- package/dist/CommandPalette-ah00bf8v.stx +39 -0
- package/dist/CommandPaletteItem-2yx0gvtj.stx +32 -0
- package/dist/DefaultPaymentMethod-emw5fg8s.stx +62 -0
- package/dist/Dialog-1w4rz7x0.stx +19 -0
- package/dist/DialogBackdrop-qbm3y5ab.stx +9 -0
- package/dist/DialogDescription-01w5j74b.stx +11 -0
- package/dist/DialogPanel-brsszrrs.stx +16 -0
- package/dist/DialogTitle-3rxhwg21.stx +11 -0
- package/dist/Drawer-yfaz8q7f.stx +137 -0
- package/dist/Dropdown-ng7nx556.stx +24 -0
- package/dist/DropdownButton-vc4zpyrb.stx +23 -0
- package/dist/DropdownItem-z491y23c.stx +43 -0
- package/dist/DropdownItems-7ykf29sj.stx +18 -0
- package/dist/EmailInput-bfshpj92.stx +41 -0
- package/dist/Footer-xdaf02nr.stx +66 -0
- package/dist/Form-z4f7w6r1.stx +209 -0
- package/dist/Hero-9vvp7pxf.stx +25 -0
- package/dist/Image-ktk0451c.stx +197 -0
- package/dist/Installation-33bj4rm7.stx +39 -0
- package/dist/Listbox-xcejcmyc.stx +14 -0
- package/dist/ListboxButton-nx5kmw19.stx +17 -0
- package/dist/ListboxLabel-aky8a73n.stx +11 -0
- package/dist/ListboxOption-6h4hsdz5.stx +57 -0
- package/dist/ListboxOptions-2sacdtm5.stx +16 -0
- package/dist/Login-s2jkvd9y.stx +163 -0
- package/dist/Navigator-tqqdgdkw.stx +138 -0
- package/dist/Notification-sry8egea.stx +71 -0
- package/dist/NumberInput-zm93ddfw.stx +138 -0
- package/dist/Pagination-yza9v4qw.stx +183 -0
- package/dist/PasswordInput-4xnndp5y.stx +155 -0
- package/dist/PaymentMethods-jxba6kek.stx +113 -0
- package/dist/Popover-scbqatjq.stx +24 -0
- package/dist/PopoverButton-rbxhzj4k.stx +23 -0
- package/dist/PopoverPanel-9ng1rm6e.stx +23 -0
- package/dist/Portal-j111yvqp.stx +74 -0
- package/dist/Progress-gbmw3akr.stx +142 -0
- package/dist/Radio-1n9qamv1.stx +81 -0
- package/dist/RadioGroup-12dw2vhk.stx +13 -0
- package/dist/RadioGroupDescription-bjm3mdht.stx +11 -0
- package/dist/RadioGroupLabel-aky8a73n.stx +11 -0
- package/dist/RadioGroupOption-9pcxgwmd.stx +51 -0
- package/dist/SearchInput-g240e2nq.stx +63 -0
- package/dist/Select-p9f94b20.stx +89 -0
- package/dist/Sidebar-gwxw8q38.stx +288 -0
- package/dist/SidebarFooter-887kxret.stx +95 -0
- package/dist/SidebarHeader-qjeyx0hv.stx +100 -0
- package/dist/SidebarItem-4dpwtmb4.stx +118 -0
- package/dist/SidebarSection-kh92fk4m.stx +108 -0
- package/dist/Signup-3nxq5zag.stx +161 -0
- package/dist/Skeleton-g0nx1njm.stx +48 -0
- package/dist/Spinner-w4zj58xp.stx +109 -0
- package/dist/Stepper-rwc5actp.stx +17 -0
- package/dist/StepperStep-h0k657nm.stx +53 -0
- package/dist/SubscriptionCheckout-4cbxdg7w.stx +353 -0
- package/dist/Switch-kjq8qd2p.stx +74 -0
- package/dist/Table-59j9qwp0.stx +14 -0
- package/dist/TableBody-reka2gwv.stx +10 -0
- package/dist/TableCell-j7nh4sgr.stx +10 -0
- package/dist/TableHead-ecbrwpqm.stx +10 -0
- package/dist/TableHeader-jn2shwsv.stx +13 -0
- package/dist/TableRow-xz8rrxhc.stx +11 -0
- package/dist/Tabs-kb6ex6m7.stx +145 -0
- package/dist/Teleport-819cg9zm.stx +101 -0
- package/dist/TextInput-zx9kgr79.stx +146 -0
- package/dist/Textarea-5xvmrb0z.stx +119 -0
- package/dist/Tooltip-5ehqsy49.stx +76 -0
- package/dist/Transition-2j39s044.stx +174 -0
- package/dist/TwoFactorChallenge-2q4gg89m.stx +125 -0
- package/dist/Video-6aq4shh4.stx +45 -0
- package/dist/VirtualList-weh5qtm1.stx +83 -0
- package/dist/VirtualTable-59a1eskc.stx +113 -0
- package/dist/components/index.d.ts +4 -0
- package/dist/composables/index.d.ts +4 -0
- package/dist/composables/index.js +3 -0
- package/dist/composables/useCopyCode.d.ts +19 -0
- package/dist/composables/useDarkMode.d.ts +25 -0
- package/dist/composables/useSEO.d.ts +36 -0
- package/dist/composables/utilities/index.d.ts +5 -0
- package/dist/composables/utilities/useClickOutside.d.ts +28 -0
- package/dist/composables/utilities/useFocusTrap.d.ts +34 -0
- package/dist/composables/utilities/useKeyboard.d.ts +55 -0
- package/dist/composables/utilities/useLocalStorage.d.ts +33 -0
- package/dist/composables/utilities/useMediaQuery.d.ts +64 -0
- package/dist/index.d.ts +86 -0
- package/dist/index.js +19 -0
- package/dist/ui/accordion/index.d.ts +12 -0
- package/dist/ui/audio/index.d.ts +12 -0
- package/dist/ui/auth/index.d.ts +29 -0
- package/dist/ui/avatar/index.d.ts +11 -0
- package/dist/ui/badge/index.d.ts +9 -0
- package/dist/ui/breadcrumb/index.d.ts +13 -0
- package/dist/ui/button/index.d.ts +45 -0
- package/dist/ui/calendar/index.d.ts +13 -0
- package/dist/ui/card/index.d.ts +12 -0
- package/dist/ui/checkbox/index.d.ts +15 -0
- package/dist/ui/combobox/index.d.ts +35 -0
- package/dist/ui/command-palette/index.d.ts +13 -0
- package/dist/ui/dialog/index.d.ts +27 -0
- package/dist/ui/drawer/index.d.ts +8 -0
- package/dist/ui/dropdown/index.d.ts +25 -0
- package/dist/ui/form/index.d.ts +48 -0
- package/dist/ui/image/index.d.ts +21 -0
- package/dist/ui/input/index.d.ts +73 -0
- package/dist/ui/listbox/index.d.ts +34 -0
- package/dist/ui/navigator/index.d.ts +18 -0
- package/dist/ui/notification/index.d.ts +11 -0
- package/dist/ui/pagination/index.d.ts +10 -0
- package/dist/ui/payment/index.d.ts +53 -0
- package/dist/ui/popover/index.d.ts +19 -0
- package/dist/ui/portal/index.d.ts +5 -0
- package/dist/ui/progress/index.d.ts +11 -0
- package/dist/ui/radio/index.d.ts +14 -0
- package/dist/ui/radio-group/index.d.ts +26 -0
- package/dist/ui/select/index.d.ts +19 -0
- package/dist/ui/sidebar/index.d.ts +129 -0
- package/dist/ui/skeleton/index.d.ts +10 -0
- package/dist/ui/spinner/index.d.ts +8 -0
- package/dist/ui/stepper/index.d.ts +17 -0
- package/dist/ui/storage/index.d.ts +40 -0
- package/dist/ui/switch/index.d.ts +9 -0
- package/dist/ui/table/index.d.ts +29 -0
- package/dist/ui/tabs/index.d.ts +14 -0
- package/dist/ui/teleport/index.d.ts +6 -0
- package/dist/ui/textarea/index.d.ts +19 -0
- package/dist/ui/tooltip/index.d.ts +9 -0
- package/dist/ui/transition/index.d.ts +24 -0
- package/dist/ui/video/index.d.ts +15 -0
- package/dist/ui/virtual-list/index.d.ts +9 -0
- package/dist/ui/virtual-table/index.d.ts +19 -0
- package/dist/utils/accessibility.d.ts +285 -0
- package/dist/utils/animation/easing.d.ts +112 -0
- package/dist/utils/animation/helpers.d.ts +119 -0
- package/dist/utils/animation/index.d.ts +3 -0
- package/dist/utils/animation/keyframes.d.ts +334 -0
- package/dist/utils/error-handling.d.ts +182 -0
- package/dist/utils/highlighter.d.ts +27 -0
- package/dist/utils/highlighter.js +2 -0
- package/dist/utils/i18n.d.ts +245 -0
- package/dist/utils/keep-alive.d.ts +171 -0
- package/dist/utils/lazy-loading.d.ts +174 -0
- package/dist/utils/prop-validation.d.ts +106 -0
- package/dist/utils/theme.d.ts +234 -0
- package/package.json +69 -0
- package/src/components/CodeBlock.stx +57 -0
- package/src/components/Footer.stx +66 -0
- package/src/components/Hero.stx +25 -0
- package/src/components/Installation.stx +39 -0
- package/src/components/index.ts +4 -0
- package/src/composables/index.ts +4 -0
- package/src/composables/useCopyCode.ts +73 -0
- package/src/composables/useDarkMode.ts +100 -0
- package/src/composables/useSEO.ts +229 -0
- package/src/composables/utilities/index.ts +7 -0
- package/src/composables/utilities/useClickOutside.ts +72 -0
- package/src/composables/utilities/useFocusTrap.ts +159 -0
- package/src/composables/utilities/useKeyboard.ts +124 -0
- package/src/composables/utilities/useLocalStorage.ts +132 -0
- package/src/composables/utilities/useMediaQuery.ts +118 -0
- package/src/index.ts +99 -0
- package/src/stx.d.ts +4 -0
- package/src/ui/accordion/Accordion.stx +108 -0
- package/src/ui/accordion/index.ts +14 -0
- package/src/ui/audio/Audio.stx +50 -0
- package/src/ui/audio/README.md +42 -0
- package/src/ui/audio/index.ts +13 -0
- package/src/ui/auth/Login.stx +163 -0
- package/src/ui/auth/README.md +145 -0
- package/src/ui/auth/Signup.stx +161 -0
- package/src/ui/auth/TwoFactorChallenge.stx +125 -0
- package/src/ui/auth/index.ts +32 -0
- package/src/ui/avatar/Avatar.stx +88 -0
- package/src/ui/avatar/index.ts +12 -0
- package/src/ui/badge/Badge.stx +70 -0
- package/src/ui/badge/index.ts +10 -0
- package/src/ui/breadcrumb/Breadcrumb.stx +79 -0
- package/src/ui/breadcrumb/index.ts +15 -0
- package/src/ui/button/Button.stx +89 -0
- package/src/ui/button/README.md +100 -0
- package/src/ui/button/index.ts +85 -0
- package/src/ui/calendar/Calendar.stx +232 -0
- package/src/ui/calendar/README.md +254 -0
- package/src/ui/calendar/index.ts +14 -0
- package/src/ui/card/Card.stx +74 -0
- package/src/ui/card/index.ts +13 -0
- package/src/ui/checkbox/Checkbox.stx +92 -0
- package/src/ui/checkbox/index.ts +16 -0
- package/src/ui/combobox/Combobox.stx +13 -0
- package/src/ui/combobox/ComboboxButton.stx +13 -0
- package/src/ui/combobox/ComboboxInput.stx +25 -0
- package/src/ui/combobox/ComboboxOption.stx +52 -0
- package/src/ui/combobox/ComboboxOptions.stx +12 -0
- package/src/ui/combobox/README.md +154 -0
- package/src/ui/combobox/index.ts +40 -0
- package/src/ui/command-palette/CommandPalette.stx +39 -0
- package/src/ui/command-palette/CommandPaletteItem.stx +32 -0
- package/src/ui/command-palette/README.md +42 -0
- package/src/ui/command-palette/index.ts +15 -0
- package/src/ui/dialog/Dialog.stx +19 -0
- package/src/ui/dialog/DialogBackdrop.stx +9 -0
- package/src/ui/dialog/DialogDescription.stx +11 -0
- package/src/ui/dialog/DialogPanel.stx +16 -0
- package/src/ui/dialog/DialogTitle.stx +11 -0
- package/src/ui/dialog/README.md +133 -0
- package/src/ui/dialog/index.ts +32 -0
- package/src/ui/drawer/Drawer.stx +137 -0
- package/src/ui/drawer/README.md +110 -0
- package/src/ui/drawer/index.ts +9 -0
- package/src/ui/dropdown/Dropdown.stx +24 -0
- package/src/ui/dropdown/DropdownButton.stx +23 -0
- package/src/ui/dropdown/DropdownItem.stx +43 -0
- package/src/ui/dropdown/DropdownItems.stx +18 -0
- package/src/ui/dropdown/README.md +142 -0
- package/src/ui/dropdown/index.ts +29 -0
- package/src/ui/form/Form.stx +209 -0
- package/src/ui/form/index.ts +67 -0
- package/src/ui/heatmap/Heatmap.stx +315 -0
- package/src/ui/image/Image.stx +197 -0
- package/src/ui/image/README.md +171 -0
- package/src/ui/image/index.ts +22 -0
- package/src/ui/input/EmailInput.stx +41 -0
- package/src/ui/input/NumberInput.stx +138 -0
- package/src/ui/input/PasswordInput.stx +155 -0
- package/src/ui/input/SearchInput.stx +63 -0
- package/src/ui/input/TextInput.stx +146 -0
- package/src/ui/input/index.ts +180 -0
- package/src/ui/listbox/Listbox.stx +14 -0
- package/src/ui/listbox/ListboxButton.stx +17 -0
- package/src/ui/listbox/ListboxLabel.stx +11 -0
- package/src/ui/listbox/ListboxOption.stx +57 -0
- package/src/ui/listbox/ListboxOptions.stx +16 -0
- package/src/ui/listbox/README.md +143 -0
- package/src/ui/listbox/index.ts +39 -0
- package/src/ui/navigator/Navigator.stx +138 -0
- package/src/ui/navigator/README.md +352 -0
- package/src/ui/navigator/index.ts +20 -0
- package/src/ui/notification/Notification.stx +71 -0
- package/src/ui/notification/README.md +118 -0
- package/src/ui/notification/index.ts +12 -0
- package/src/ui/pagination/Pagination.stx +183 -0
- package/src/ui/pagination/index.ts +11 -0
- package/src/ui/payment/Checkout.stx +39 -0
- package/src/ui/payment/DefaultPaymentMethod.stx +62 -0
- package/src/ui/payment/PaymentMethods.stx +113 -0
- package/src/ui/payment/README.md +427 -0
- package/src/ui/payment/SubscriptionCheckout.stx +353 -0
- package/src/ui/payment/index.ts +59 -0
- package/src/ui/popover/Popover.stx +24 -0
- package/src/ui/popover/PopoverButton.stx +23 -0
- package/src/ui/popover/PopoverPanel.stx +23 -0
- package/src/ui/popover/README.md +95 -0
- package/src/ui/popover/index.ts +22 -0
- package/src/ui/portal/Portal.stx +74 -0
- package/src/ui/portal/index.ts +6 -0
- package/src/ui/progress/Progress.stx +142 -0
- package/src/ui/progress/index.ts +12 -0
- package/src/ui/radio/Radio.stx +81 -0
- package/src/ui/radio/index.ts +15 -0
- package/src/ui/radio-group/README.md +145 -0
- package/src/ui/radio-group/RadioGroup.stx +13 -0
- package/src/ui/radio-group/RadioGroupDescription.stx +11 -0
- package/src/ui/radio-group/RadioGroupLabel.stx +11 -0
- package/src/ui/radio-group/RadioGroupOption.stx +51 -0
- package/src/ui/radio-group/index.ts +30 -0
- package/src/ui/select/README.md +204 -0
- package/src/ui/select/Select.stx +89 -0
- package/src/ui/select/index.ts +21 -0
- package/src/ui/sidebar/Sidebar.stx +288 -0
- package/src/ui/sidebar/SidebarFooter.stx +95 -0
- package/src/ui/sidebar/SidebarHeader.stx +100 -0
- package/src/ui/sidebar/SidebarItem.stx +118 -0
- package/src/ui/sidebar/SidebarSection.stx +108 -0
- package/src/ui/sidebar/index.ts +175 -0
- package/src/ui/skeleton/Skeleton.stx +48 -0
- package/src/ui/skeleton/index.ts +11 -0
- package/src/ui/spinner/Spinner.stx +109 -0
- package/src/ui/spinner/index.ts +9 -0
- package/src/ui/stepper/README.md +36 -0
- package/src/ui/stepper/Stepper.stx +17 -0
- package/src/ui/stepper/StepperStep.stx +53 -0
- package/src/ui/stepper/index.ts +19 -0
- package/src/ui/storage/README.md +193 -0
- package/src/ui/storage/index.ts +347 -0
- package/src/ui/switch/README.md +133 -0
- package/src/ui/switch/Switch.stx +74 -0
- package/src/ui/switch/index.ts +10 -0
- package/src/ui/table/README.md +39 -0
- package/src/ui/table/Table.stx +14 -0
- package/src/ui/table/TableBody.stx +10 -0
- package/src/ui/table/TableCell.stx +10 -0
- package/src/ui/table/TableHead.stx +10 -0
- package/src/ui/table/TableHeader.stx +13 -0
- package/src/ui/table/TableRow.stx +11 -0
- package/src/ui/table/index.ts +35 -0
- package/src/ui/tabs/Tabs.stx +145 -0
- package/src/ui/tabs/index.ts +16 -0
- package/src/ui/teleport/Teleport.stx +101 -0
- package/src/ui/teleport/index.ts +7 -0
- package/src/ui/textarea/Textarea.stx +119 -0
- package/src/ui/textarea/index.ts +20 -0
- package/src/ui/tooltip/Tooltip.stx +76 -0
- package/src/ui/tooltip/index.ts +10 -0
- package/src/ui/transition/README.md +30 -0
- package/src/ui/transition/Transition.stx +174 -0
- package/src/ui/transition/index.ts +25 -0
- package/src/ui/video/README.md +48 -0
- package/src/ui/video/Video.stx +45 -0
- package/src/ui/video/index.ts +16 -0
- package/src/ui/virtual-list/VirtualList.stx +83 -0
- package/src/ui/virtual-list/index.ts +10 -0
- package/src/ui/virtual-table/VirtualTable.stx +113 -0
- package/src/ui/virtual-table/index.ts +21 -0
- package/src/utils/PROP_VALIDATION.md +458 -0
- package/src/utils/THEME_SYSTEM.md +702 -0
- package/src/utils/accessibility.ts +841 -0
- package/src/utils/animation/easing.ts +368 -0
- package/src/utils/animation/helpers.ts +223 -0
- package/src/utils/animation/index.ts +5 -0
- package/src/utils/animation/keyframes.ts +230 -0
- package/src/utils/error-handling.ts +473 -0
- package/src/utils/highlighter.ts +93 -0
- package/src/utils/i18n.ts +634 -0
- package/src/utils/keep-alive.ts +818 -0
- package/src/utils/lazy-loading.ts +530 -0
- package/src/utils/prop-validation.ts +478 -0
- package/src/utils/theme.ts +626 -0
|
@@ -0,0 +1,626 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Theme system for @stacksjs/components
|
|
3
|
+
*
|
|
4
|
+
* Provides customizable color palettes, typography, spacing, and component variants
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* import { createTheme, applyTheme, useTheme } from '@stacksjs/components'
|
|
9
|
+
*
|
|
10
|
+
* const myTheme = createTheme({
|
|
11
|
+
* colors: {
|
|
12
|
+
* primary: '#3b82f6',
|
|
13
|
+
* secondary: '#8b5cf6'
|
|
14
|
+
* }
|
|
15
|
+
* })
|
|
16
|
+
*
|
|
17
|
+
* applyTheme(myTheme)
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Color palette definition
|
|
23
|
+
*/
|
|
24
|
+
export interface ColorPalette {
|
|
25
|
+
primary?: string
|
|
26
|
+
secondary?: string
|
|
27
|
+
success?: string
|
|
28
|
+
warning?: string
|
|
29
|
+
danger?: string
|
|
30
|
+
info?: string
|
|
31
|
+
gray?: string
|
|
32
|
+
white?: string
|
|
33
|
+
black?: string
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Typography scale
|
|
38
|
+
*/
|
|
39
|
+
export interface Typography {
|
|
40
|
+
fontFamily?: {
|
|
41
|
+
sans?: string
|
|
42
|
+
serif?: string
|
|
43
|
+
mono?: string
|
|
44
|
+
}
|
|
45
|
+
fontSize?: {
|
|
46
|
+
'xs'?: string
|
|
47
|
+
'sm'?: string
|
|
48
|
+
'base'?: string
|
|
49
|
+
'lg'?: string
|
|
50
|
+
'xl'?: string
|
|
51
|
+
'2xl'?: string
|
|
52
|
+
'3xl'?: string
|
|
53
|
+
'4xl'?: string
|
|
54
|
+
}
|
|
55
|
+
fontWeight?: {
|
|
56
|
+
light?: string
|
|
57
|
+
normal?: string
|
|
58
|
+
medium?: string
|
|
59
|
+
semibold?: string
|
|
60
|
+
bold?: string
|
|
61
|
+
}
|
|
62
|
+
lineHeight?: {
|
|
63
|
+
tight?: string
|
|
64
|
+
normal?: string
|
|
65
|
+
relaxed?: string
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Spacing scale
|
|
71
|
+
*/
|
|
72
|
+
export interface Spacing {
|
|
73
|
+
'xs'?: string
|
|
74
|
+
'sm'?: string
|
|
75
|
+
'md'?: string
|
|
76
|
+
'lg'?: string
|
|
77
|
+
'xl'?: string
|
|
78
|
+
'2xl'?: string
|
|
79
|
+
'3xl'?: string
|
|
80
|
+
'4xl'?: string
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Border radius scale
|
|
85
|
+
*/
|
|
86
|
+
export interface BorderRadius {
|
|
87
|
+
none?: string
|
|
88
|
+
sm?: string
|
|
89
|
+
md?: string
|
|
90
|
+
lg?: string
|
|
91
|
+
full?: string
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Shadow scale
|
|
96
|
+
*/
|
|
97
|
+
export interface Shadows {
|
|
98
|
+
'sm'?: string
|
|
99
|
+
'md'?: string
|
|
100
|
+
'lg'?: string
|
|
101
|
+
'xl'?: string
|
|
102
|
+
'2xl'?: string
|
|
103
|
+
'none'?: string
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Component-specific overrides
|
|
108
|
+
*/
|
|
109
|
+
export interface ComponentOverrides {
|
|
110
|
+
button?: {
|
|
111
|
+
borderRadius?: string
|
|
112
|
+
padding?: string
|
|
113
|
+
fontSize?: string
|
|
114
|
+
fontWeight?: string
|
|
115
|
+
}
|
|
116
|
+
input?: {
|
|
117
|
+
borderRadius?: string
|
|
118
|
+
padding?: string
|
|
119
|
+
fontSize?: string
|
|
120
|
+
borderWidth?: string
|
|
121
|
+
}
|
|
122
|
+
card?: {
|
|
123
|
+
borderRadius?: string
|
|
124
|
+
padding?: string
|
|
125
|
+
shadow?: string
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Complete theme configuration
|
|
131
|
+
*/
|
|
132
|
+
export interface Theme {
|
|
133
|
+
colors: ColorPalette
|
|
134
|
+
typography: Typography
|
|
135
|
+
spacing: Spacing
|
|
136
|
+
borderRadius: BorderRadius
|
|
137
|
+
shadows: Shadows
|
|
138
|
+
components?: ComponentOverrides
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Default theme
|
|
143
|
+
*/
|
|
144
|
+
export const defaultTheme: Theme = {
|
|
145
|
+
colors: {
|
|
146
|
+
primary: '#3b82f6',
|
|
147
|
+
secondary: '#8b5cf6',
|
|
148
|
+
success: '#10b981',
|
|
149
|
+
warning: '#f59e0b',
|
|
150
|
+
danger: '#ef4444',
|
|
151
|
+
info: '#06b6d4',
|
|
152
|
+
gray: '#6b7280',
|
|
153
|
+
white: '#ffffff',
|
|
154
|
+
black: '#000000',
|
|
155
|
+
},
|
|
156
|
+
typography: {
|
|
157
|
+
fontFamily: {
|
|
158
|
+
sans: 'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',
|
|
159
|
+
serif: 'Georgia, Cambria, "Times New Roman", Times, serif',
|
|
160
|
+
mono: 'Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace',
|
|
161
|
+
},
|
|
162
|
+
fontSize: {
|
|
163
|
+
'xs': '0.75rem',
|
|
164
|
+
'sm': '0.875rem',
|
|
165
|
+
'base': '1rem',
|
|
166
|
+
'lg': '1.125rem',
|
|
167
|
+
'xl': '1.25rem',
|
|
168
|
+
'2xl': '1.5rem',
|
|
169
|
+
'3xl': '1.875rem',
|
|
170
|
+
'4xl': '2.25rem',
|
|
171
|
+
},
|
|
172
|
+
fontWeight: {
|
|
173
|
+
light: '300',
|
|
174
|
+
normal: '400',
|
|
175
|
+
medium: '500',
|
|
176
|
+
semibold: '600',
|
|
177
|
+
bold: '700',
|
|
178
|
+
},
|
|
179
|
+
lineHeight: {
|
|
180
|
+
tight: '1.25',
|
|
181
|
+
normal: '1.5',
|
|
182
|
+
relaxed: '1.75',
|
|
183
|
+
},
|
|
184
|
+
},
|
|
185
|
+
spacing: {
|
|
186
|
+
'xs': '0.25rem',
|
|
187
|
+
'sm': '0.5rem',
|
|
188
|
+
'md': '1rem',
|
|
189
|
+
'lg': '1.5rem',
|
|
190
|
+
'xl': '2rem',
|
|
191
|
+
'2xl': '3rem',
|
|
192
|
+
'3xl': '4rem',
|
|
193
|
+
'4xl': '6rem',
|
|
194
|
+
},
|
|
195
|
+
borderRadius: {
|
|
196
|
+
none: '0',
|
|
197
|
+
sm: '0.125rem',
|
|
198
|
+
md: '0.375rem',
|
|
199
|
+
lg: '0.5rem',
|
|
200
|
+
full: '9999px',
|
|
201
|
+
},
|
|
202
|
+
shadows: {
|
|
203
|
+
'sm': '0 1px 2px 0 rgba(0, 0, 0, 0.05)',
|
|
204
|
+
'md': '0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)',
|
|
205
|
+
'lg': '0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)',
|
|
206
|
+
'xl': '0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04)',
|
|
207
|
+
'2xl': '0 25px 50px -12px rgba(0, 0, 0, 0.25)',
|
|
208
|
+
'none': 'none',
|
|
209
|
+
},
|
|
210
|
+
components: {
|
|
211
|
+
button: {
|
|
212
|
+
borderRadius: '0.375rem',
|
|
213
|
+
padding: '0.5rem 1rem',
|
|
214
|
+
fontSize: '0.875rem',
|
|
215
|
+
fontWeight: '500',
|
|
216
|
+
},
|
|
217
|
+
input: {
|
|
218
|
+
borderRadius: '0.375rem',
|
|
219
|
+
padding: '0.5rem 0.75rem',
|
|
220
|
+
fontSize: '0.875rem',
|
|
221
|
+
borderWidth: '1px',
|
|
222
|
+
},
|
|
223
|
+
card: {
|
|
224
|
+
borderRadius: '0.5rem',
|
|
225
|
+
padding: '1.5rem',
|
|
226
|
+
shadow: '0 1px 3px 0 rgba(0, 0, 0, 0.1)',
|
|
227
|
+
},
|
|
228
|
+
},
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* Deep merge two objects
|
|
233
|
+
*/
|
|
234
|
+
function deepMerge<T extends object>(target: T, source: Partial<T>): T {
|
|
235
|
+
const output = { ...target }
|
|
236
|
+
|
|
237
|
+
for (const key in source) {
|
|
238
|
+
if (source[key] instanceof Object && key in target) {
|
|
239
|
+
output[key] = deepMerge(target[key] as any, source[key] as any)
|
|
240
|
+
}
|
|
241
|
+
else {
|
|
242
|
+
output[key] = source[key] as any
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
return output
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* Create a custom theme by merging with default theme
|
|
251
|
+
*
|
|
252
|
+
* @param customTheme - Partial theme configuration
|
|
253
|
+
* @returns Complete theme object
|
|
254
|
+
*
|
|
255
|
+
* @example
|
|
256
|
+
* ```ts
|
|
257
|
+
* const myTheme = createTheme({
|
|
258
|
+
* colors: {
|
|
259
|
+
* primary: '#3b82f6',
|
|
260
|
+
* secondary: '#8b5cf6'
|
|
261
|
+
* },
|
|
262
|
+
* typography: {
|
|
263
|
+
* fontFamily: {
|
|
264
|
+
* sans: 'Inter, sans-serif'
|
|
265
|
+
* }
|
|
266
|
+
* }
|
|
267
|
+
* })
|
|
268
|
+
* ```
|
|
269
|
+
*/
|
|
270
|
+
export function createTheme(customTheme: Partial<Theme>): Theme {
|
|
271
|
+
return deepMerge(defaultTheme, customTheme)
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* Current active theme
|
|
276
|
+
*/
|
|
277
|
+
let currentTheme: Theme = defaultTheme
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* Get the current active theme
|
|
281
|
+
*
|
|
282
|
+
* @returns Current theme object
|
|
283
|
+
*/
|
|
284
|
+
export function getTheme(): Theme {
|
|
285
|
+
return currentTheme
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
/**
|
|
289
|
+
* Convert theme to CSS custom properties
|
|
290
|
+
*
|
|
291
|
+
* @param theme - Theme object
|
|
292
|
+
* @returns CSS custom properties string
|
|
293
|
+
*/
|
|
294
|
+
export function themeToCSSProperties(theme: Theme): string {
|
|
295
|
+
const cssVars: string[] = []
|
|
296
|
+
|
|
297
|
+
// Colors
|
|
298
|
+
if (theme.colors) {
|
|
299
|
+
Object.entries(theme.colors).forEach(([key, value]) => {
|
|
300
|
+
if (value)
|
|
301
|
+
cssVars.push(`--color-${key}: ${value};`)
|
|
302
|
+
})
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
// Typography
|
|
306
|
+
if (theme.typography?.fontFamily) {
|
|
307
|
+
Object.entries(theme.typography.fontFamily).forEach(([key, value]) => {
|
|
308
|
+
if (value)
|
|
309
|
+
cssVars.push(`--font-${key}: ${value};`)
|
|
310
|
+
})
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
if (theme.typography?.fontSize) {
|
|
314
|
+
Object.entries(theme.typography.fontSize).forEach(([key, value]) => {
|
|
315
|
+
if (value)
|
|
316
|
+
cssVars.push(`--text-${key}: ${value};`)
|
|
317
|
+
})
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
if (theme.typography?.fontWeight) {
|
|
321
|
+
Object.entries(theme.typography.fontWeight).forEach(([key, value]) => {
|
|
322
|
+
if (value)
|
|
323
|
+
cssVars.push(`--font-weight-${key}: ${value};`)
|
|
324
|
+
})
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
if (theme.typography?.lineHeight) {
|
|
328
|
+
Object.entries(theme.typography.lineHeight).forEach(([key, value]) => {
|
|
329
|
+
if (value)
|
|
330
|
+
cssVars.push(`--leading-${key}: ${value};`)
|
|
331
|
+
})
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
// Spacing
|
|
335
|
+
if (theme.spacing) {
|
|
336
|
+
Object.entries(theme.spacing).forEach(([key, value]) => {
|
|
337
|
+
if (value)
|
|
338
|
+
cssVars.push(`--spacing-${key}: ${value};`)
|
|
339
|
+
})
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
// Border radius
|
|
343
|
+
if (theme.borderRadius) {
|
|
344
|
+
Object.entries(theme.borderRadius).forEach(([key, value]) => {
|
|
345
|
+
if (value)
|
|
346
|
+
cssVars.push(`--radius-${key}: ${value};`)
|
|
347
|
+
})
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
// Shadows
|
|
351
|
+
if (theme.shadows) {
|
|
352
|
+
Object.entries(theme.shadows).forEach(([key, value]) => {
|
|
353
|
+
if (value)
|
|
354
|
+
cssVars.push(`--shadow-${key}: ${value};`)
|
|
355
|
+
})
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
// Component overrides
|
|
359
|
+
if (theme.components?.button) {
|
|
360
|
+
Object.entries(theme.components.button).forEach(([key, value]) => {
|
|
361
|
+
if (value)
|
|
362
|
+
cssVars.push(`--button-${key.replace(/([A-Z])/g, '-$1').toLowerCase()}: ${value};`)
|
|
363
|
+
})
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
if (theme.components?.input) {
|
|
367
|
+
Object.entries(theme.components.input).forEach(([key, value]) => {
|
|
368
|
+
if (value)
|
|
369
|
+
cssVars.push(`--input-${key.replace(/([A-Z])/g, '-$1').toLowerCase()}: ${value};`)
|
|
370
|
+
})
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
if (theme.components?.card) {
|
|
374
|
+
Object.entries(theme.components.card).forEach(([key, value]) => {
|
|
375
|
+
if (value)
|
|
376
|
+
cssVars.push(`--card-${key.replace(/([A-Z])/g, '-$1').toLowerCase()}: ${value};`)
|
|
377
|
+
})
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
return `:root {\n ${cssVars.join('\n ')}\n}`
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
/**
|
|
384
|
+
* Apply theme to the document
|
|
385
|
+
*
|
|
386
|
+
* @param theme - Theme object to apply
|
|
387
|
+
* @param target - Target element (defaults to document.documentElement)
|
|
388
|
+
*
|
|
389
|
+
* @example
|
|
390
|
+
* ```ts
|
|
391
|
+
* const theme = createTheme({ colors: { primary: '#3b82f6' } })
|
|
392
|
+
* applyTheme(theme)
|
|
393
|
+
* ```
|
|
394
|
+
*/
|
|
395
|
+
export function applyTheme(theme: Theme, target?: HTMLElement): void {
|
|
396
|
+
currentTheme = theme
|
|
397
|
+
|
|
398
|
+
if (typeof document === 'undefined')
|
|
399
|
+
return
|
|
400
|
+
|
|
401
|
+
const element = target || document.documentElement
|
|
402
|
+
|
|
403
|
+
// Colors
|
|
404
|
+
if (theme.colors) {
|
|
405
|
+
Object.entries(theme.colors).forEach(([key, value]) => {
|
|
406
|
+
if (value)
|
|
407
|
+
element.style.setProperty(`--color-${key}`, value)
|
|
408
|
+
})
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
// Typography
|
|
412
|
+
if (theme.typography?.fontFamily) {
|
|
413
|
+
Object.entries(theme.typography.fontFamily).forEach(([key, value]) => {
|
|
414
|
+
if (value)
|
|
415
|
+
element.style.setProperty(`--font-${key}`, value)
|
|
416
|
+
})
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
if (theme.typography?.fontSize) {
|
|
420
|
+
Object.entries(theme.typography.fontSize).forEach(([key, value]) => {
|
|
421
|
+
if (value)
|
|
422
|
+
element.style.setProperty(`--text-${key}`, value)
|
|
423
|
+
})
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
if (theme.typography?.fontWeight) {
|
|
427
|
+
Object.entries(theme.typography.fontWeight).forEach(([key, value]) => {
|
|
428
|
+
if (value)
|
|
429
|
+
element.style.setProperty(`--font-weight-${key}`, value)
|
|
430
|
+
})
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
if (theme.typography?.lineHeight) {
|
|
434
|
+
Object.entries(theme.typography.lineHeight).forEach(([key, value]) => {
|
|
435
|
+
if (value)
|
|
436
|
+
element.style.setProperty(`--leading-${key}`, value)
|
|
437
|
+
})
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
// Spacing
|
|
441
|
+
if (theme.spacing) {
|
|
442
|
+
Object.entries(theme.spacing).forEach(([key, value]) => {
|
|
443
|
+
if (value)
|
|
444
|
+
element.style.setProperty(`--spacing-${key}`, value)
|
|
445
|
+
})
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
// Border radius
|
|
449
|
+
if (theme.borderRadius) {
|
|
450
|
+
Object.entries(theme.borderRadius).forEach(([key, value]) => {
|
|
451
|
+
if (value)
|
|
452
|
+
element.style.setProperty(`--radius-${key}`, value)
|
|
453
|
+
})
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
// Shadows
|
|
457
|
+
if (theme.shadows) {
|
|
458
|
+
Object.entries(theme.shadows).forEach(([key, value]) => {
|
|
459
|
+
if (value)
|
|
460
|
+
element.style.setProperty(`--shadow-${key}`, value)
|
|
461
|
+
})
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
// Component overrides
|
|
465
|
+
if (theme.components?.button) {
|
|
466
|
+
Object.entries(theme.components.button).forEach(([key, value]) => {
|
|
467
|
+
if (value)
|
|
468
|
+
element.style.setProperty(`--button-${key.replace(/([A-Z])/g, '-$1').toLowerCase()}`, value)
|
|
469
|
+
})
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
if (theme.components?.input) {
|
|
473
|
+
Object.entries(theme.components.input).forEach(([key, value]) => {
|
|
474
|
+
if (value)
|
|
475
|
+
element.style.setProperty(`--input-${key.replace(/([A-Z])/g, '-$1').toLowerCase()}`, value)
|
|
476
|
+
})
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
if (theme.components?.card) {
|
|
480
|
+
Object.entries(theme.components.card).forEach(([key, value]) => {
|
|
481
|
+
if (value)
|
|
482
|
+
element.style.setProperty(`--card-${key.replace(/([A-Z])/g, '-$1').toLowerCase()}`, value)
|
|
483
|
+
})
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
/**
|
|
488
|
+
* Hook to use theme in components
|
|
489
|
+
*
|
|
490
|
+
* @returns Current theme object
|
|
491
|
+
*
|
|
492
|
+
* @example
|
|
493
|
+
* ```ts
|
|
494
|
+
* const theme = useTheme()
|
|
495
|
+
* const primaryColor = theme.colors.primary
|
|
496
|
+
* ```
|
|
497
|
+
*/
|
|
498
|
+
export function useTheme(): Theme {
|
|
499
|
+
return currentTheme
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
/**
|
|
503
|
+
* Get a specific theme value by path
|
|
504
|
+
*
|
|
505
|
+
* @param path - Dot-notation path to theme value
|
|
506
|
+
* @returns Theme value or undefined
|
|
507
|
+
*
|
|
508
|
+
* @example
|
|
509
|
+
* ```ts
|
|
510
|
+
* const primary = getThemeValue('colors.primary')
|
|
511
|
+
* const fontSize = getThemeValue('typography.fontSize.base')
|
|
512
|
+
* ```
|
|
513
|
+
*/
|
|
514
|
+
export function getThemeValue(path: string): any {
|
|
515
|
+
const keys = path.split('.')
|
|
516
|
+
let value: any = currentTheme
|
|
517
|
+
|
|
518
|
+
for (const key of keys) {
|
|
519
|
+
if (value && typeof value === 'object' && key in value) {
|
|
520
|
+
value = value[key]
|
|
521
|
+
}
|
|
522
|
+
else {
|
|
523
|
+
return undefined
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
return value
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
/**
|
|
531
|
+
* Predefined theme presets
|
|
532
|
+
*/
|
|
533
|
+
export const themePresets: {
|
|
534
|
+
default: Theme
|
|
535
|
+
purple: Theme
|
|
536
|
+
green: Theme
|
|
537
|
+
orange: Theme
|
|
538
|
+
dark: Theme
|
|
539
|
+
minimal: Theme
|
|
540
|
+
} = {
|
|
541
|
+
/**
|
|
542
|
+
* Default blue theme
|
|
543
|
+
*/
|
|
544
|
+
default: defaultTheme,
|
|
545
|
+
|
|
546
|
+
/**
|
|
547
|
+
* Purple theme
|
|
548
|
+
*/
|
|
549
|
+
purple: createTheme({
|
|
550
|
+
colors: {
|
|
551
|
+
primary: '#8b5cf6',
|
|
552
|
+
secondary: '#a78bfa',
|
|
553
|
+
},
|
|
554
|
+
}),
|
|
555
|
+
|
|
556
|
+
/**
|
|
557
|
+
* Green theme
|
|
558
|
+
*/
|
|
559
|
+
green: createTheme({
|
|
560
|
+
colors: {
|
|
561
|
+
primary: '#10b981',
|
|
562
|
+
secondary: '#34d399',
|
|
563
|
+
},
|
|
564
|
+
}),
|
|
565
|
+
|
|
566
|
+
/**
|
|
567
|
+
* Orange theme
|
|
568
|
+
*/
|
|
569
|
+
orange: createTheme({
|
|
570
|
+
colors: {
|
|
571
|
+
primary: '#f97316',
|
|
572
|
+
secondary: '#fb923c',
|
|
573
|
+
},
|
|
574
|
+
}),
|
|
575
|
+
|
|
576
|
+
/**
|
|
577
|
+
* Dark theme
|
|
578
|
+
*/
|
|
579
|
+
dark: createTheme({
|
|
580
|
+
colors: {
|
|
581
|
+
primary: '#60a5fa',
|
|
582
|
+
secondary: '#a78bfa',
|
|
583
|
+
gray: '#9ca3af',
|
|
584
|
+
white: '#1f2937',
|
|
585
|
+
black: '#f9fafb',
|
|
586
|
+
},
|
|
587
|
+
}),
|
|
588
|
+
|
|
589
|
+
/**
|
|
590
|
+
* Minimal theme with reduced shadows and border radius
|
|
591
|
+
*/
|
|
592
|
+
minimal: createTheme({
|
|
593
|
+
borderRadius: {
|
|
594
|
+
none: '0',
|
|
595
|
+
sm: '0',
|
|
596
|
+
md: '0.125rem',
|
|
597
|
+
lg: '0.25rem',
|
|
598
|
+
full: '0.25rem',
|
|
599
|
+
},
|
|
600
|
+
shadows: {
|
|
601
|
+
'sm': 'none',
|
|
602
|
+
'md': '0 1px 2px 0 rgba(0, 0, 0, 0.05)',
|
|
603
|
+
'lg': '0 1px 3px 0 rgba(0, 0, 0, 0.1)',
|
|
604
|
+
'xl': '0 4px 6px -1px rgba(0, 0, 0, 0.1)',
|
|
605
|
+
'2xl': '0 10px 15px -3px rgba(0, 0, 0, 0.1)',
|
|
606
|
+
'none': 'none',
|
|
607
|
+
},
|
|
608
|
+
}),
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
/**
|
|
612
|
+
* Generate CSS file content for a theme
|
|
613
|
+
*
|
|
614
|
+
* @param theme - Theme object
|
|
615
|
+
* @returns CSS file content
|
|
616
|
+
*
|
|
617
|
+
* @example
|
|
618
|
+
* ```ts
|
|
619
|
+
* const theme = createTheme({ colors: { primary: '#3b82f6' } })
|
|
620
|
+
* const css = generateThemeCSS(theme)
|
|
621
|
+
* // Write to file or inject into page
|
|
622
|
+
* ```
|
|
623
|
+
*/
|
|
624
|
+
export function generateThemeCSS(theme: Theme): string {
|
|
625
|
+
return themeToCSSProperties(theme)
|
|
626
|
+
}
|