zabi-components 5.0.22 → 7.0.0

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.
Files changed (207) hide show
  1. package/README.md +139 -1478
  2. package/THEME.md +473 -0
  3. package/THEMING.md +248 -0
  4. package/dist/atoms/ActionPanel.svelte +116 -0
  5. package/dist/atoms/ActionPanel.svelte.d.ts +19 -0
  6. package/dist/atoms/Badge.svelte +1 -1
  7. package/dist/atoms/Badge.svelte.d.ts +1 -1
  8. package/dist/atoms/Button.svelte +35 -16
  9. package/dist/atoms/Button.svelte.d.ts +3 -1
  10. package/dist/atoms/Card.svelte +49 -67
  11. package/dist/atoms/Card.svelte.d.ts +4 -4
  12. package/dist/atoms/CardHeader.svelte +15 -2
  13. package/dist/atoms/CardHeader.svelte.d.ts +5 -0
  14. package/dist/atoms/Checkbox.svelte +50 -76
  15. package/dist/atoms/Checkbox.svelte.d.ts +7 -2
  16. package/dist/atoms/CodeBlock.svelte +20 -34
  17. package/dist/atoms/CodeBlock.svelte.d.ts +1 -0
  18. package/dist/atoms/ColorPicker.svelte +3 -7
  19. package/dist/atoms/Container.svelte +41 -0
  20. package/dist/atoms/Container.svelte.d.ts +12 -0
  21. package/dist/atoms/Divider.svelte +68 -0
  22. package/dist/atoms/Divider.svelte.d.ts +13 -0
  23. package/dist/atoms/FeatureCard.svelte +35 -50
  24. package/dist/atoms/FeatureCard.svelte.d.ts +9 -4
  25. package/dist/atoms/IconButton.svelte +33 -24
  26. package/dist/atoms/IconButton.svelte.d.ts +4 -8
  27. package/dist/atoms/Input.svelte +58 -26
  28. package/dist/atoms/Input.svelte.d.ts +6 -1
  29. package/dist/atoms/List.svelte +2 -7
  30. package/dist/atoms/List.svelte.d.ts +1 -6
  31. package/dist/atoms/ListItem.svelte +54 -65
  32. package/dist/atoms/ListItem.svelte.d.ts +7 -13
  33. package/dist/atoms/ListItemLeading.svelte +19 -0
  34. package/dist/atoms/ListItemLeading.svelte.d.ts +9 -0
  35. package/dist/atoms/Progress.svelte +2 -2
  36. package/dist/atoms/Radio.svelte +51 -0
  37. package/dist/atoms/Radio.svelte.d.ts +14 -0
  38. package/dist/atoms/Select.svelte +28 -33
  39. package/dist/atoms/Select.svelte.d.ts +0 -10
  40. package/dist/atoms/SelectionControl.svelte +98 -0
  41. package/dist/atoms/SelectionControl.svelte.d.ts +26 -0
  42. package/dist/atoms/Skeleton.svelte +39 -15
  43. package/dist/atoms/Skeleton.svelte.d.ts +7 -3
  44. package/dist/atoms/Table.svelte +27 -0
  45. package/dist/atoms/Table.svelte.d.ts +10 -0
  46. package/dist/atoms/Text.svelte +46 -0
  47. package/dist/atoms/Text.svelte.d.ts +13 -0
  48. package/dist/atoms/Textarea.svelte +74 -53
  49. package/dist/atoms/Textarea.svelte.d.ts +6 -2
  50. package/dist/atoms/ThemeToggle.svelte +35 -24
  51. package/dist/atoms/ThemeToggle.svelte.d.ts +1 -0
  52. package/dist/atoms/Toast.svelte +55 -31
  53. package/dist/atoms/Toast.svelte.d.ts +4 -1
  54. package/dist/atoms/Toggle.svelte +37 -22
  55. package/dist/atoms/Toggle.svelte.d.ts +2 -1
  56. package/dist/atoms/Tooltip.svelte +90 -11
  57. package/dist/atoms/index.d.ts +6 -0
  58. package/dist/atoms/index.js +6 -0
  59. package/dist/atoms/selection-control.styles.d.ts +25 -0
  60. package/dist/atoms/selection-control.styles.js +30 -0
  61. package/dist/components/atoms/index.d.ts +6 -0
  62. package/dist/components/atoms/index.d.ts.map +1 -1
  63. package/dist/components/atoms/selection-control.styles.d.ts +26 -0
  64. package/dist/components/atoms/selection-control.styles.d.ts.map +1 -0
  65. package/dist/components/index.d.ts +42 -7
  66. package/dist/components/index.d.ts.map +1 -1
  67. package/dist/components/molecules/index.d.ts +10 -0
  68. package/dist/components/molecules/index.d.ts.map +1 -1
  69. package/dist/components/molecules/navigation-menu-context.d.ts +11 -0
  70. package/dist/components/molecules/navigation-menu-context.d.ts.map +1 -1
  71. package/dist/components/molecules/toast-store.d.ts +39 -0
  72. package/dist/components/molecules/toast-store.d.ts.map +1 -0
  73. package/dist/components/organisms/index.d.ts +3 -3
  74. package/dist/components/organisms/index.d.ts.map +1 -1
  75. package/dist/components/types/page.types.d.ts +69 -0
  76. package/dist/components/types/page.types.d.ts.map +1 -0
  77. package/dist/components/types/page.types.js +1 -0
  78. package/dist/components/types/variants.d.ts +64 -0
  79. package/dist/components/types/variants.d.ts.map +1 -0
  80. package/dist/components/types/variants.js +44 -0
  81. package/dist/components/util/fixed-sidebar-flyout.d.ts +23 -0
  82. package/dist/components/util/fixed-sidebar-flyout.d.ts.map +1 -0
  83. package/dist/components/util/focus-utils.d.ts +12 -0
  84. package/dist/components/util/focus-utils.d.ts.map +1 -0
  85. package/dist/components/util/ssr-safe.d.ts +17 -0
  86. package/dist/components/util/ssr-safe.d.ts.map +1 -0
  87. package/dist/index.d.ts +42 -7
  88. package/dist/index.js +45 -10
  89. package/dist/lib/layout-width-tokens.d.ts +17 -0
  90. package/dist/lib/layout-width-tokens.d.ts.map +1 -0
  91. package/dist/lib/showcase/component-docs/Button.d.ts +3 -0
  92. package/dist/lib/showcase/component-docs/Button.d.ts.map +1 -0
  93. package/dist/lib/showcase/component-docs/Input.d.ts +3 -0
  94. package/dist/lib/showcase/component-docs/Input.d.ts.map +1 -0
  95. package/dist/lib/showcase/component-docs/List.d.ts +3 -0
  96. package/dist/lib/showcase/component-docs/List.d.ts.map +1 -0
  97. package/dist/lib/showcase/component-docs/Modal.d.ts +3 -0
  98. package/dist/lib/showcase/component-docs/Modal.d.ts.map +1 -0
  99. package/dist/lib/showcase/component-docs/Radio.d.ts +3 -0
  100. package/dist/lib/showcase/component-docs/Radio.d.ts.map +1 -0
  101. package/dist/lib/showcase/component-docs/SidebarNavigation.d.ts +3 -0
  102. package/dist/lib/showcase/component-docs/SidebarNavigation.d.ts.map +1 -0
  103. package/dist/lib/showcase/component-docs/Skeleton.d.ts +3 -0
  104. package/dist/lib/showcase/component-docs/Skeleton.d.ts.map +1 -0
  105. package/dist/lib/showcase/component-docs/_shared.d.ts +12 -0
  106. package/dist/lib/showcase/component-docs/_shared.d.ts.map +1 -0
  107. package/dist/lib/showcase/component-docs/index.d.ts +4 -0
  108. package/dist/lib/showcase/component-docs/index.d.ts.map +1 -0
  109. package/dist/lib/showcase/components-catalog.d.ts +3 -0
  110. package/dist/lib/showcase/components-catalog.d.ts.map +1 -0
  111. package/dist/lib/showcase/components-showcase-constants.d.ts +89 -0
  112. package/dist/lib/showcase/components-showcase-constants.d.ts.map +1 -0
  113. package/dist/lib/showcase/docs-sidebar-helpers.d.ts +15 -0
  114. package/dist/lib/showcase/docs-sidebar-helpers.d.ts.map +1 -0
  115. package/dist/molecules/Alert.svelte +50 -23
  116. package/dist/molecules/Alert.svelte.d.ts +1 -1
  117. package/dist/molecules/ComponentDemo.svelte +54 -51
  118. package/dist/molecules/ContactForm.svelte +70 -65
  119. package/dist/molecules/Dropdown.svelte +99 -108
  120. package/dist/molecules/Dropdown.svelte.d.ts +12 -6
  121. package/dist/molecules/EmptyState.svelte +44 -0
  122. package/dist/molecules/EmptyState.svelte.d.ts +11 -0
  123. package/dist/molecules/FormField.svelte +89 -0
  124. package/dist/molecules/FormField.svelte.d.ts +23 -0
  125. package/dist/molecules/Header.svelte +41 -0
  126. package/dist/molecules/Header.svelte.d.ts +10 -0
  127. package/dist/molecules/ImageUpload.svelte +1 -1
  128. package/dist/molecules/Modal.svelte +39 -26
  129. package/dist/molecules/Modal.svelte.d.ts +4 -2
  130. package/dist/molecules/NavigationMenu.svelte +16 -0
  131. package/dist/molecules/NavigationMenu.svelte.d.ts +2 -0
  132. package/dist/molecules/NavigationMenuContent.svelte +9 -1
  133. package/dist/molecules/NavigationMenuLink.svelte +1 -1
  134. package/dist/molecules/NavigationMenuTrigger.svelte +9 -4
  135. package/dist/molecules/Page.svelte +16 -0
  136. package/dist/molecules/Page.svelte.d.ts +8 -0
  137. package/dist/molecules/PropsTable.svelte +61 -0
  138. package/dist/molecules/PropsTable.svelte.d.ts +8 -0
  139. package/dist/molecules/RadioGroup.svelte +197 -0
  140. package/dist/molecules/RadioGroup.svelte.d.ts +20 -0
  141. package/dist/molecules/Section.svelte +14 -23
  142. package/dist/molecules/Section.svelte.d.ts +2 -11
  143. package/dist/molecules/SidebarBrandHeader.svelte +68 -0
  144. package/dist/molecules/SidebarBrandHeader.svelte.d.ts +10 -0
  145. package/dist/molecules/SidebarFooter.svelte +119 -0
  146. package/dist/molecules/SidebarFooter.svelte.d.ts +23 -0
  147. package/dist/molecules/SidebarNavSection.svelte +49 -0
  148. package/dist/molecules/SidebarNavSection.svelte.d.ts +14 -0
  149. package/dist/molecules/SlideUp.svelte +21 -16
  150. package/dist/molecules/SlideUp.svelte.d.ts +1 -1
  151. package/dist/molecules/Tabs.svelte +6 -11
  152. package/dist/molecules/Toaster.svelte +21 -0
  153. package/dist/molecules/Toaster.svelte.d.ts +6 -0
  154. package/dist/molecules/ToasterToast.svelte +217 -0
  155. package/dist/molecules/ToasterToast.svelte.d.ts +7 -0
  156. package/dist/molecules/index.d.ts +10 -0
  157. package/dist/molecules/index.js +10 -0
  158. package/dist/molecules/navigation-menu-context.d.ts +11 -0
  159. package/dist/molecules/navigation-menu-context.js +18 -0
  160. package/dist/molecules/toast-store.d.ts +38 -0
  161. package/dist/molecules/toast-store.js +34 -0
  162. package/dist/organisms/SidebarAccountPanel.svelte +118 -0
  163. package/dist/organisms/SidebarAccountPanel.svelte.d.ts +20 -0
  164. package/dist/organisms/SidebarNavigation.svelte +286 -212
  165. package/dist/organisms/SidebarNavigation.svelte.d.ts +22 -1
  166. package/dist/organisms/{SidebarProjectPanel.svelte → SidebarPanel.svelte} +67 -34
  167. package/dist/organisms/{SidebarProjectPanel.svelte.d.ts → SidebarPanel.svelte.d.ts} +9 -6
  168. package/dist/organisms/TopNavbar.svelte +214 -0
  169. package/dist/organisms/TopNavbar.svelte.d.ts +35 -0
  170. package/dist/organisms/index.d.ts +3 -3
  171. package/dist/organisms/index.js +3 -3
  172. package/dist/routes/lib/focus-utils.d.ts +7 -18
  173. package/dist/routes/lib/focus-utils.ts +32 -34
  174. package/dist/routes/lib/ssr-safe.ts +5 -4
  175. package/dist/routes/lib/variant-utils.ts +48 -39
  176. package/dist/types/components.d.ts +187 -0
  177. package/dist/types/components.d.ts.map +1 -0
  178. package/dist/types/events.d.ts +200 -0
  179. package/dist/types/events.d.ts.map +1 -0
  180. package/dist/types/index.d.ts +171 -0
  181. package/dist/types/index.d.ts.map +1 -0
  182. package/dist/types/page.types.d.ts +3 -0
  183. package/dist/types/page.types.d.ts.map +1 -0
  184. package/dist/types/page.types.js +1 -0
  185. package/dist/types/page.types.ts +79 -0
  186. package/dist/types/variants.d.ts +3 -0
  187. package/dist/types/variants.d.ts.map +1 -0
  188. package/dist/types/variants.js +1 -0
  189. package/dist/types/variants.ts +75 -0
  190. package/dist/util/fixed-sidebar-flyout.d.ts +22 -0
  191. package/dist/util/fixed-sidebar-flyout.js +148 -0
  192. package/dist/util/focus-utils.d.ts +11 -0
  193. package/dist/util/focus-utils.js +94 -0
  194. package/dist/util/ssr-safe.d.ts +16 -0
  195. package/dist/util/ssr-safe.js +48 -0
  196. package/dist/zabi-components-colors.css +360 -324
  197. package/dist/zabi-components-theme-dark-only.css +164 -151
  198. package/dist/zabi-components-theme-dark.css +164 -151
  199. package/dist/zabi-components-theme-only.css +253 -230
  200. package/dist/zabi-components-theme.css +253 -230
  201. package/dist/zabi-components.css +1262 -241
  202. package/docs/theme-imports.md +112 -0
  203. package/package.json +32 -10
  204. package/dist/organisms/Navbar.svelte +0 -92
  205. package/dist/organisms/Navbar.svelte.d.ts +0 -14
  206. package/dist/organisms/Navigation.svelte +0 -119
  207. package/dist/organisms/Navigation.svelte.d.ts +0 -21
package/THEME.md ADDED
@@ -0,0 +1,473 @@
1
+ # Zabi Components Theme Guide
2
+
3
+ Complete guide to using and customizing the Zabi Components theme system with Tailwind CSS v4.
4
+
5
+ ## Table of Contents
6
+
7
+ - [Quick Start](#quick-start)
8
+ - [Theme Files](#theme-files)
9
+ - [Import Options](#import-options)
10
+ - [Theme Extension](#theme-extension)
11
+ - [Dark Mode](#dark-mode)
12
+ - [Color System](#color-system)
13
+ - [Customization Examples](#customization-examples)
14
+ - [Common Pitfalls](#common-pitfalls)
15
+
16
+ ## Quick Start
17
+
18
+ ### Basic Setup (Standalone)
19
+
20
+ If you don't have Tailwind CSS set up yet:
21
+
22
+ ```css
23
+ /* app.css */
24
+ @import 'zabi-components/theme';
25
+ @import 'zabi-components/dist/zabi-components.css';
26
+ ```
27
+
28
+ ### Setup with Existing Tailwind
29
+
30
+ If you already have Tailwind CSS configured:
31
+
32
+ ```css
33
+ /* app.css */
34
+ @import "tailwindcss";
35
+ @import 'zabi-components/theme-only';
36
+ @import 'zabi-components/dist/zabi-components.css';
37
+ ```
38
+
39
+ ### With Dark Mode
40
+
41
+ ```css
42
+ /* app.css */
43
+ @import "tailwindcss";
44
+ @import 'zabi-components/theme-only';
45
+ @import 'zabi-components/theme-dark-only';
46
+ @import 'zabi-components/dist/zabi-components.css';
47
+ ```
48
+
49
+ ## Theme Files
50
+
51
+ Zabi Components provides multiple theme file variants:
52
+
53
+ | File | Description | Use Case |
54
+ |------|-------------|----------|
55
+ | `zabi-components/theme` | Full theme with Tailwind import | Standalone projects |
56
+ | `zabi-components/theme-only` | Theme without Tailwind import | Projects with existing Tailwind |
57
+ | `zabi-components/theme-dark` | Dark mode with Tailwind import | Standalone + dark mode |
58
+ | `zabi-components/theme-dark-only` | Dark mode without Tailwind import | Existing Tailwind + dark mode |
59
+
60
+ ### Direct Path Imports
61
+
62
+ You can also import using direct paths:
63
+
64
+ ```css
65
+ @import 'zabi-components/dist/zabi-components-theme.css';
66
+ @import 'zabi-components/dist/zabi-components-theme-only.css';
67
+ @import 'zabi-components/dist/zabi-components-theme-dark.css';
68
+ @import 'zabi-components/dist/zabi-components-theme-dark-only.css';
69
+ ```
70
+
71
+ ## Import Options
72
+
73
+ ### Option 1: Standalone (No Existing Tailwind)
74
+
75
+ Best for new projects or projects without Tailwind:
76
+
77
+ ```css
78
+ @import 'zabi-components/theme';
79
+ @import 'zabi-components/theme-dark'; /* Optional: for dark mode */
80
+ @import 'zabi-components/dist/zabi-components.css';
81
+ ```
82
+
83
+ **Pros:**
84
+ - Simple setup
85
+ - No Tailwind configuration needed
86
+ - Everything included
87
+
88
+ **Cons:**
89
+ - Less control over Tailwind configuration
90
+ - Slightly larger bundle if you need custom Tailwind config
91
+
92
+ ### Option 2: With Existing Tailwind
93
+
94
+ Best for projects already using Tailwind CSS:
95
+
96
+ ```css
97
+ @import "tailwindcss";
98
+ @import 'zabi-components/theme-only';
99
+ @import 'zabi-components/theme-dark-only'; /* Optional: for dark mode */
100
+ @import 'zabi-components/dist/zabi-components.css';
101
+ ```
102
+
103
+ **Pros:**
104
+ - Full control over Tailwind configuration
105
+ - Can customize Tailwind before importing theme
106
+ - Smaller bundle (no duplicate Tailwind import)
107
+
108
+ **Cons:**
109
+ - Requires Tailwind setup
110
+ - Must import Tailwind first
111
+
112
+ ## Theme Extension
113
+
114
+ You can extend the Zabi theme with your own customizations using additional `@theme` blocks:
115
+
116
+ ```css
117
+ @import "tailwindcss";
118
+ @import 'zabi-components/theme-only';
119
+
120
+ /* Your custom theme extensions */
121
+ @theme {
122
+ /* Custom font families */
123
+ --font-family-title: 'Your Font', sans-serif;
124
+ --font-family-body: 'Another Font', sans-serif;
125
+
126
+ /* Custom colors */
127
+ --color-custom-primary: #ff0000;
128
+ --color-custom-secondary: #00ff00;
129
+ }
130
+
131
+ @import 'zabi-components/dist/zabi-components.css';
132
+ ```
133
+
134
+ ### Important: Import Order
135
+
136
+ The import order is critical:
137
+
138
+ 1. **First:** `@import "tailwindcss"` (if using theme-only)
139
+ 2. **Second:** `@import 'zabi-components/theme-only'` (or theme)
140
+ 3. **Third:** Your custom `@theme` block (extends zabi theme)
141
+ 4. **Fourth:** `@import 'zabi-components/dist/zabi-components.css'` (uses the theme)
142
+
143
+ This order ensures:
144
+ - Tailwind is available for `theme()` function calls
145
+ - Zabi theme is defined first
146
+ - Your extensions override zabi defaults
147
+ - Components can use all theme values
148
+
149
+ ## Dark Mode
150
+
151
+ Zabi Components supports dark mode through CSS custom properties in the `.dark` class.
152
+
153
+ ### Automatic Dark Mode (System Preference)
154
+
155
+ ```css
156
+ @import "tailwindcss";
157
+ @import 'zabi-components/theme-only';
158
+ @import 'zabi-components/theme-dark-only'; /* Supports system preference */
159
+ @import 'zabi-components/dist/zabi-components.css';
160
+ ```
161
+
162
+ The dark theme file uses `@media (prefers-color-scheme: dark)` to automatically switch based on system preference.
163
+
164
+ ### Manual Dark Mode Toggle
165
+
166
+ For manual dark mode toggling, add the `.dark` class to your HTML element:
167
+
168
+ ```javascript
169
+ // Toggle dark mode
170
+ document.documentElement.classList.toggle('dark');
171
+ ```
172
+
173
+ The dark theme file also includes `.dark` class support, so both system preference and manual toggle work.
174
+
175
+ ### Custom Dark Mode Colors
176
+
177
+ You can override dark mode colors in your custom theme:
178
+
179
+ ```css
180
+ @import "tailwindcss";
181
+ @import 'zabi-components/theme-only';
182
+ @import 'zabi-components/theme-dark-only';
183
+
184
+ @theme {
185
+ /* Your light mode customizations */
186
+ --color-custom: #ff0000;
187
+ }
188
+
189
+ /* Custom dark mode overrides */
190
+ .dark {
191
+ --color-custom: #ff6666; /* Lighter red for dark mode */
192
+ }
193
+
194
+ @import 'zabi-components/dist/zabi-components.css';
195
+ ```
196
+
197
+ ## Color System
198
+
199
+ Zabi Components uses a semantic color system with the following color scales:
200
+
201
+ ### Color Scales
202
+
203
+ - **Brand** - Primary brand colors (blue palette)
204
+ - **Citron** - Energetic/yellow colors
205
+ - **Pine** - Success/green colors
206
+ - **Iris** - Info/purple colors
207
+
208
+ Each scale includes shades from 50 (lightest) to 950 (darkest).
209
+
210
+ ### Semantic Colors
211
+
212
+ Semantic colors map to specific use cases:
213
+
214
+ - `--color-background` - Main background
215
+ - `--color-headline` - Headings and titles
216
+ - `--color-body` - Body text
217
+ - `--color-description` - Secondary/description text
218
+ - `--color-caption` - Captions and labels
219
+ - `--color-border` - Borders and dividers
220
+ - `--color-surface-elevated` - Elevated surfaces (cards, modals)
221
+ - `--color-surface-level-0/1/2` - Surface hierarchy
222
+ - `--color-primary` - Primary actions
223
+ - `--color-secondary` - Secondary actions
224
+ - `--color-success` - Success states
225
+ - `--color-warning` - Warning states
226
+ - `--color-error` - Error states
227
+
228
+ ### Using Colors
229
+
230
+ #### In CSS
231
+
232
+ ```css
233
+ .my-element {
234
+ background-color: var(--color-primary);
235
+ color: var(--color-headline);
236
+ }
237
+ ```
238
+
239
+ #### In Tailwind Classes
240
+
241
+ Zabi Components provides utility classes:
242
+
243
+ ```html
244
+ <div class="bg-primary text-headline">
245
+ Primary background with headline text
246
+ </div>
247
+ ```
248
+
249
+ #### In Tailwind theme() Function
250
+
251
+ ```css
252
+ .custom-class {
253
+ color: theme(colors.brand.600);
254
+ background: theme(colors.surface.elevated);
255
+ }
256
+ ```
257
+
258
+ ## Customization Examples
259
+
260
+ ### Example 1: Custom Brand Colors
261
+
262
+ ```css
263
+ @import "tailwindcss";
264
+ @import 'zabi-components/theme-only';
265
+
266
+
267
+ @import 'zabi-components/dist/zabi-components.css';
268
+ ```
269
+
270
+ ### Example 2: Custom Fonts
271
+
272
+ ```css
273
+ @import "tailwindcss";
274
+ @import 'zabi-components/theme-only';
275
+
276
+ @theme {
277
+ --font-family-title: 'Inter', 'Helvetica', sans-serif;
278
+ --font-family-body: 'Inter', 'Helvetica', sans-serif;
279
+ --font-family-sans: 'Inter', ui-sans-serif, system-ui, sans-serif;
280
+ }
281
+
282
+ @import 'zabi-components/dist/zabi-components.css';
283
+ ```
284
+
285
+ ### Example 3: Custom Semantic Colors
286
+
287
+ ```css
288
+ @import "tailwindcss";
289
+ @import 'zabi-components/theme-only';
290
+
291
+ @theme {
292
+ /* Custom primary color */
293
+ --color-primary: theme(colors.purple.600);
294
+ --color-primary-weak: theme(colors.purple.700);
295
+ --color-primary-medium: theme(colors.purple.800);
296
+ --color-primary-strong: theme(colors.purple.900);
297
+ }
298
+
299
+ @import 'zabi-components/dist/zabi-components.css';
300
+ ```
301
+
302
+ ### Example 4: Multiple Theme Variants
303
+
304
+ ```css
305
+ @import "tailwindcss";
306
+ @import 'zabi-components/theme-only';
307
+
308
+ /* Default theme */
309
+ @theme {
310
+ --color-primary: theme(colors.blue.600);
311
+ }
312
+
313
+ /* Custom variant */
314
+ .variant-custom {
315
+ --color-primary: theme(colors.purple.600);
316
+ --color-secondary: theme(colors.pink.600);
317
+ }
318
+
319
+ @import 'zabi-components/dist/zabi-components.css';
320
+ ```
321
+
322
+ ## Common Pitfalls
323
+
324
+ ### Pitfall 1: Wrong Import Order
325
+
326
+ **Wrong:**
327
+ ```css
328
+ @import 'zabi-components/dist/zabi-components.css';
329
+ @import 'zabi-components/theme-only'; /* Too late! */
330
+ ```
331
+
332
+ **Correct:**
333
+ ```css
334
+ @import "tailwindcss";
335
+ @import 'zabi-components/theme-only';
336
+ @import 'zabi-components/dist/zabi-components.css';
337
+ ```
338
+
339
+ ### Pitfall 2: Double Tailwind Import
340
+
341
+ **Wrong:**
342
+ ```css
343
+ @import "tailwindcss";
344
+ @import 'zabi-components/theme'; /* This also imports Tailwind! */
345
+ ```
346
+
347
+ **Correct:**
348
+ ```css
349
+ @import "tailwindcss";
350
+ @import 'zabi-components/theme-only'; /* Use theme-only */
351
+ ```
352
+
353
+ ### Pitfall 3: Theme Extension After Components
354
+
355
+ **Wrong:**
356
+ ```css
357
+ @import 'zabi-components/theme-only';
358
+ @import 'zabi-components/dist/zabi-components.css';
359
+ @theme { /* Too late! */ }
360
+ ```
361
+
362
+ **Correct:**
363
+ ```css
364
+ @import "tailwindcss";
365
+ @import 'zabi-components/theme-only';
366
+ @theme { /* Extend before components */ }
367
+ @import 'zabi-components/dist/zabi-components.css';
368
+ ```
369
+
370
+ ### Pitfall 4: Missing Dark Mode Import
371
+
372
+ If you want dark mode support, you must import the dark theme file:
373
+
374
+ ```css
375
+ @import "tailwindcss";
376
+ @import 'zabi-components/theme-only';
377
+ @import 'zabi-components/theme-dark-only'; /* Don't forget this! */
378
+ @import 'zabi-components/dist/zabi-components.css';
379
+ ```
380
+
381
+ ### Pitfall 5: Using theme() Before Theme is Defined
382
+
383
+ **Wrong:**
384
+ ```css
385
+ @theme {
386
+ --color-custom: theme(colors.brand.600); /* Works */
387
+ --color-other: theme(colors.custom.500); /* Fails - custom not defined yet */
388
+ }
389
+ ```
390
+
391
+ **Correct:**
392
+ ```css
393
+ @theme {
394
+ --color-custom: theme(colors.brand.600);
395
+ /* Define custom colors first, then reference them */
396
+ --color-custom-500: #ff0000;
397
+ --color-other: var(--color-custom-500); /* Use var() for custom colors */
398
+ }
399
+ ```
400
+
401
+ ## Troubleshooting
402
+
403
+ ### Theme Variables Not Working
404
+
405
+ 1. Check import order (theme must come before components CSS)
406
+ 2. Verify you're using the correct theme file variant
407
+ 3. Ensure Tailwind is imported if using `theme-only`
408
+ 4. Check browser console for CSS errors
409
+
410
+ ### Dark Mode Not Working
411
+
412
+ 1. Ensure dark theme file is imported
413
+ 2. Check that `.dark` class is applied to `<html>` or root element
414
+ 3. Verify system preference detection (if using automatic mode)
415
+ 4. Check that dark mode CSS custom properties are defined
416
+
417
+ ### Colors Not Updating
418
+
419
+ 1. Clear browser cache
420
+ 2. Restart dev server
421
+ 3. Check for CSS specificity issues
422
+ 4. Verify theme extension is after zabi theme import
423
+
424
+ ## Advanced Usage
425
+
426
+ ### Programmatic Theme Switching
427
+
428
+ ```javascript
429
+ // Switch to dark mode
430
+ document.documentElement.classList.add('dark');
431
+
432
+ // Switch to light mode
433
+ document.documentElement.classList.remove('dark');
434
+
435
+ // Toggle
436
+ document.documentElement.classList.toggle('dark');
437
+ ```
438
+
439
+ ### Theme with Svelte
440
+
441
+ ```svelte
442
+ <script>
443
+ import { onMount } from 'svelte';
444
+
445
+ let isDark = $state(false);
446
+
447
+ onMount(() => {
448
+ // Check system preference
449
+ const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
450
+ isDark = prefersDark;
451
+ updateTheme();
452
+ });
453
+
454
+ function updateTheme() {
455
+ if (isDark) {
456
+ document.documentElement.classList.add('dark');
457
+ } else {
458
+ document.documentElement.classList.remove('dark');
459
+ }
460
+ }
461
+ </script>
462
+
463
+ <button on:click={() => { isDark = !isDark; updateTheme(); }}>
464
+ Toggle Theme
465
+ </button>
466
+ ```
467
+
468
+ ## Additional Resources
469
+
470
+ - [Tailwind CSS v4 Documentation](https://tailwindcss.com/docs)
471
+ - [CSS Custom Properties](https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_custom_properties)
472
+ - [Zabi Components GitHub](https://github.com/zabi-components/zabi-components)
473
+
package/THEMING.md ADDED
@@ -0,0 +1,248 @@
1
+ # Theming Guide
2
+
3
+ ## 🎨 Single Source of Truth
4
+
5
+ **All theming is done in one file: `src/app.css`**
6
+
7
+ This file contains:
8
+ - All color scales (brand, citron, pine, iris, base)
9
+ - Semantic color tokens (primary, secondary, success, error, etc.)
10
+ - Action colors (for buttons and interactive elements)
11
+ - Dark mode overrides
12
+ - Typography settings
13
+ - Spacing, border radius, and z-index values
14
+
15
+ ## 📍 Where to Make Changes
16
+
17
+ ### Main Theme (Light Mode)
18
+ Edit the `@theme` block in `src/app.css`.
19
+
20
+ ### Dark Mode Theme
21
+ Edit the `.dark` block in `src/app.css`.
22
+
23
+ ## ⚠️ Important: Don't Edit These Files
24
+
25
+ ### Generated Files (in `dist/` folder)
26
+ These files are **automatically generated** from `src/app.css` by the build script:
27
+ - ❌ `dist/zabi-components.css` - Full compiled CSS (generated)
28
+ - ❌ `dist/zabi-components-theme.css` - Theme with Tailwind import (generated)
29
+ - ❌ `dist/zabi-components-theme-only.css` - Theme only, no Tailwind (generated)
30
+ - ❌ `dist/zabi-components-theme-dark.css` - Dark mode theme (generated)
31
+ - ❌ `dist/zabi-components-theme-dark-only.css` - Dark mode theme only (generated)
32
+ - ❌ `dist/zabi-components-colors.css` - Standalone colors (generated from app.css)
33
+
34
+ **These files are overwritten every time you run `npm run build:css`**
35
+
36
+ ### Example Files
37
+ - ❌ `examples/theme-extensions/02-custom-brand-colors.css` - Just an example, not your actual theme
38
+ - ❌ `examples/theme-extensions/03-custom-semantic-colors.css` - Just an example, not your actual theme
39
+
40
+ ### Source Files (Edit These)
41
+ - ✅ `src/app.css` - **THIS IS THE ONLY FILE YOU NEED TO EDIT**
42
+ - ✅ Removed deprecated files (`src/styles/colors.css`, `src/styles/base.css`, `src/styles/simple.css`, `src/app-simple.css`)
43
+
44
+ ## 📦 What Are the Dist Files For?
45
+
46
+ The `dist/` files are **for consumers** of your library who want to import the theme separately.
47
+
48
+ **Full import matrix, export paths, and examples:** [docs/theme-imports.md](./docs/theme-imports.md)
49
+
50
+ ### For Library Developers (You)
51
+ - **Edit**: `src/app.css` only
52
+ - **Build**: Run `npm run build:css` to regenerate all dist files (or `npm run build:lib` before publish)
53
+ - **After token edits**: run `node scripts/verify-build.js` to confirm outputs (also runs as part of `build:lib`)
54
+ - **Base scale source**: use `tokens/base-scale.js`; run `npm run sync:tokens` (or `npm run build:css`) to render token blocks back into `src/app.css`
55
+
56
+ ### For Library Consumers
57
+
58
+ Use **package exports** (preferred):
59
+
60
+ | Need | Import |
61
+ |------|--------|
62
+ | Tailwind + full `@theme` (app has no Tailwind yet) | `zabi-components/theme` |
63
+ | Tailwind already in app — merge `@theme` only | `zabi-components/theme-only` |
64
+ | Dark overrides (+ Tailwind import in file) | `zabi-components/theme-dark` |
65
+ | Dark overrides only (Tailwind already loaded) | `zabi-components/theme-dark-only` |
66
+ | CSS variables only, no Tailwind | `zabi-components/colors` |
67
+ | Full compiled CSS (utilities + everything) | `zabi-components/css` |
68
+
69
+ Examples:
70
+
71
+ ```css
72
+ @import "zabi-components/theme-only";
73
+ @import "zabi-components/theme-dark-only";
74
+ ```
75
+
76
+ ```css
77
+ @import "zabi-components/colors";
78
+ ```
79
+
80
+ ```css
81
+ @import "zabi-components/css";
82
+ ```
83
+
84
+ Canonical recommendation for most apps remains:
85
+
86
+ ```css
87
+ @import "tailwindcss";
88
+ @import "zabi-components/theme-only";
89
+ @import "zabi-components/theme-dark-only";
90
+ ```
91
+
92
+ Dark mapping rule reference:
93
+ - Physical ramp tokens are `--zabi-base-50 ... --zabi-base-950`.
94
+ - Semantic dark mapping is generated with `S -> 1000 - S` (for example `50 <-> 950`, `75 <-> 925`, `500` unchanged).
95
+
96
+ ## 🎯 Common Customizations
97
+
98
+ ### Change Brand Colors
99
+
100
+ ```css
101
+ @theme {
102
+ /* Replace the brand color scale */
103
+ --color-brand-50: #f0f9ff;
104
+ --color-brand-100: #e0f2fe;
105
+ --color-brand-200: #bae6fd;
106
+ --color-brand-300: #7dd3fc;
107
+ --color-brand-400: #38bdf8;
108
+ --color-brand-500: #0ea5e9;
109
+ --color-brand-600: #0284c7;
110
+ --color-brand-700: #0369a1;
111
+ --color-brand-800: #075985;
112
+ --color-brand-900: #0c4a6e;
113
+ --color-brand-950: #082f49;
114
+ }
115
+ ```
116
+
117
+ ### Change Primary Button Color
118
+
119
+ The primary button uses `--color-action-primary` which defaults to `brand-800`. To change it:
120
+
121
+ ```css
122
+ @theme {
123
+ /* Use a different brand shade */
124
+ --color-action-primary: theme(colors.brand.600);
125
+
126
+ /* Or use a completely custom color */
127
+ --color-action-primary: #your-color-here;
128
+ }
129
+ ```
130
+
131
+ ### Brand Scale Usage
132
+
133
+ The brand scale is used throughout the system:
134
+
135
+ - **brand-50 to brand-100**: Subtle backgrounds, hover states
136
+ - **brand-300 to brand-400**: Light accents, disabled states
137
+ - **brand-500**: Focus rings, medium emphasis
138
+ - **brand-600**: Primary color, links
139
+ - **brand-700**: Link hover, primary hover
140
+ - **brand-800**: **Primary buttons** (`action-primary`)
141
+ - **brand-900**: Primary button hover
142
+ - **brand-950**: Darkest brand shade
143
+
144
+ ### Dark Mode
145
+
146
+ Dark mode automatically inverts the brand scale:
147
+ - `brand-50` becomes `brand-950` (darkest)
148
+ - `brand-950` becomes `brand-50` (lightest)
149
+
150
+ This happens automatically in the `.dark` block, so you typically don't need to override action colors in dark mode.
151
+
152
+ ## 🌙 Dark Mode Action Colors
153
+
154
+ Dark mode action colors are handled in `src/app.css` in the `.dark` block (lines 393-404):
155
+
156
+ ### Primary Actions
157
+ - **No explicit dark mode override needed** - Brand colors are automatically inverted
158
+ - `brand-800` (light mode) → `brand-200` (dark mode) automatically
159
+
160
+ ### Secondary Actions
161
+ - **No explicit dark mode override needed** - Base colors are automatically inverted
162
+ - `base-600` (light mode) → `base-400` (dark mode) automatically
163
+
164
+ ### Danger Actions
165
+ - **Has explicit dark mode overrides** (lines 399-404) because red colors aren't automatically inverted:
166
+ ```css
167
+ .dark {
168
+ --color-action-danger: theme(colors.red.500);
169
+ --color-action-danger-hover: theme(colors.red.600);
170
+ --color-action-danger-active: theme(colors.red.700);
171
+ /* ... */
172
+ }
173
+ ```
174
+
175
+ ### In Generated Files
176
+
177
+ - **`dist/zabi-components.css`**: Has dark mode at line 2178, danger actions at lines 2264-2269
178
+ - **`dist/zabi-components-theme-dark-only.css`**: Has dark mode action colors at lines 119-130 (only danger has explicit overrides)
179
+ - **`dist/zabi-components-theme-only.css`**: Only has light mode (@theme block), no dark mode
180
+ - **`dist/zabi-components-theme.css`**: Only has light mode (@theme block), no dark mode
181
+
182
+ ## 📁 File Structure
183
+
184
+ ```
185
+ src/
186
+ └── app.css ← 🎯 EDIT THIS FILE FOR ALL THEMING (single source of truth)
187
+
188
+ dist/ ← ⚠️ GENERATED FILES - DON'T EDIT
189
+ ├── zabi-components.css (full CSS with dark mode)
190
+ ├── zabi-components-theme.css (light mode only)
191
+ ├── zabi-components-theme-only.css (light mode only)
192
+ ├── zabi-components-theme-dark.css (dark mode only)
193
+ ├── zabi-components-theme-dark-only.css (dark mode only)
194
+ └── zabi-components-colors.css (standalone, both modes)
195
+
196
+ examples/ ← ⚠️ EXAMPLES ONLY - DON'T EDIT
197
+ └── theme-extensions/
198
+ ├── 02-custom-brand-colors.css
199
+ └── 03-custom-semantic-colors.css
200
+ ```
201
+
202
+ ## ⚠️ Important Notes
203
+
204
+ 1. **Never edit files in `dist/`** - These are automatically generated from `src/app.css` by `scripts/build-css.js`
205
+ 2. **All theming is in `src/app.css`** - This is the single source of truth
206
+ 3. **Always edit `src/app.css`** - This is your single source of truth
207
+ 4. The `examples/` folder contains examples, not your actual theme
208
+ 5. **Dist files are overwritten** every time you run `npm run build:css`
209
+
210
+ ## 🔄 Build Process
211
+
212
+ When you edit `src/app.css`:
213
+
214
+ 1. **Development**: Changes are automatically reflected (no build needed)
215
+ 2. **Production**: Run `npm run build:css` to regenerate dist files
216
+ 3. The build script (`scripts/build-css.js`) reads `src/app.css` and generates:
217
+ - `zabi-components.css` - Full compiled CSS with Tailwind processed (includes dark mode)
218
+ - `zabi-components-theme.css` - Theme block with Tailwind import (light mode only)
219
+ - `zabi-components-theme-only.css` - Theme block only (light mode only)
220
+ - `zabi-components-theme-dark.css` - Dark mode theme with Tailwind import
221
+ - `zabi-components-theme-dark-only.css` - Dark mode theme only
222
+ - `zabi-components-colors.css` - Standalone CSS custom properties (both light and dark)
223
+
224
+ ## 🔄 After Making Changes
225
+
226
+ ### For Development
227
+ After editing `src/app.css`, changes are automatically reflected in your app. No build needed!
228
+
229
+ ### For Production/Library Build
230
+ If you're building the library for distribution:
231
+ ```bash
232
+ npm run build:css # Regenerates all dist CSS files from src/app.css
233
+ ```
234
+
235
+ ## Optional perceptual midpoint generation (OKLCH)
236
+
237
+ Base midpoints are frozen hex by default (`fixed` mode).
238
+ For experimentation, you can generate midpoint steps in OKLCH interpolation and commit the resulting frozen values:
239
+
240
+ ```bash
241
+ ZABI_BASE_SCALE_MODE=oklch npm run sync:tokens
242
+ npm run build:css
243
+ ```
244
+
245
+ Notes:
246
+ - Primary anchors (`50, 100, 200 ... 950`) stay fixed.
247
+ - Midpoints (`75, 150, 250 ... 925`) are generated from adjacent anchors.
248
+ - Commit updated `src/app.css` and regenerated `dist/` outputs together.