zabi-components 1.0.3 → 1.0.5

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 CHANGED
@@ -1,15 +1,17 @@
1
1
  # Zabi Components
2
2
 
3
- A modern SvelteKit component library with TypeScript and Tailwind CSS support.
3
+ A comprehensive Svelte component library built with TypeScript and Tailwind CSS, designed for easy integration across multiple Svelte projects.
4
4
 
5
5
  ## Features
6
6
 
7
- - 🎨 **Modern Design**: Built with Tailwind CSS for consistent, responsive styling
8
- - 🔧 **TypeScript**: Full TypeScript support with comprehensive type definitions
9
- - 📦 **Modular**: Import only what you need with tree-shaking support
10
- - ♿ **Accessible**: Built with accessibility best practices
11
- - 🚀 **Performance**: Optimized for production with minimal bundle size
12
- - 📱 **Responsive**: Mobile-first design approach
7
+ - 🎨 **Consistent Design System** - Standardized props, events, and styling across all components
8
+ - 🎯 **TypeScript First** - Full TypeScript support with comprehensive type definitions
9
+ - 🎨 **Tailwind CSS Integration** - Built with Tailwind CSS and CSS custom properties for easy theming
10
+ - ♿ **Accessibility First** - ARIA compliant components with keyboard navigation support
11
+ - 📱 **Responsive Design** - Mobile-first approach with responsive utilities
12
+ - 🎭 **Dark Mode Support** - Built-in dark mode support with CSS custom properties
13
+ - 🧩 **Slot Support** - Flexible slot system for custom content
14
+ - 📦 **Tree Shakeable** - Import only what you need
13
15
 
14
16
  ## Installation
15
17
 
@@ -17,130 +19,369 @@ A modern SvelteKit component library with TypeScript and Tailwind CSS support.
17
19
  npm install zabi-components
18
20
  ```
19
21
 
20
- ## Usage
22
+ ## Quick Start
21
23
 
22
- ### Import All Components
24
+ ```svelte
25
+ <script>
26
+ import { Button, Input, Card, Alert } from 'zabi-components';
27
+
28
+ let name = '';
29
+ let showAlert = false;
30
+
31
+ function handleSubmit() {
32
+ showAlert = true;
33
+ }
34
+ </script>
23
35
 
24
- ```typescript
25
- import { Button, Card, Input, Modal } from 'zabi-components';
36
+ <Card>
37
+ <div slot="header">
38
+ <h2>User Form</h2>
39
+ </div>
40
+
41
+ <Input
42
+ bind:value={name}
43
+ label="Name"
44
+ placeholder="Enter your name"
45
+ on:input={(e) => console.log(e.detail.value)}
46
+ />
47
+
48
+ <Button on:click={handleSubmit}>
49
+ Submit
50
+ </Button>
51
+
52
+ <div slot="footer">
53
+ <Alert variant="success" closable bind:show={showAlert}>
54
+ Form submitted successfully!
55
+ </Alert>
56
+ </div>
57
+ </Card>
26
58
  ```
27
59
 
28
- ### Import by Category
60
+ ## Component API
29
61
 
30
- ```typescript
31
- // Atomic components
32
- import { Button, Input, Card } from 'zabi-components/atoms';
62
+ ### Button Component
33
63
 
34
- // Molecular components
35
- import { Modal, Alert, Dropdown } from 'zabi-components/molecules';
64
+ ```svelte
65
+ <Button
66
+ variant="primary" | "secondary" | "danger" | "success" | "warning" | "info"
67
+ size="sm" | "md" | "lg"
68
+ disabled={boolean}
69
+ loading={boolean}
70
+ type="button" | "submit" | "reset"
71
+ className={string}
72
+ on:click={(e) => console.log(e.detail.value, e.detail.event)}
73
+ >
74
+ Button Content
75
+ </Button>
76
+ ```
36
77
 
37
- // Organism components
38
- import { ToastContainer } from 'zabi-components/organisms';
78
+ **Props:**
79
+ - `variant`: Button style variant (default: "primary")
80
+ - `size`: Button size (default: "md")
81
+ - `disabled`: Disable the button (default: false)
82
+ - `loading`: Show loading state (default: false)
83
+ - `type`: HTML button type (default: "button")
84
+ - `className`: Additional CSS classes
85
+
86
+ **Events:**
87
+ - `click`: Fired when button is clicked - `{ detail: { value: true, event: MouseEvent } }`
88
+
89
+ ### Input Component
90
+
91
+ ```svelte
92
+ <Input
93
+ bind:value={string}
94
+ type={string}
95
+ label={string}
96
+ placeholder={string}
97
+ required={boolean}
98
+ disabled={boolean}
99
+ size="sm" | "md" | "lg"
100
+ variant="default" | "error" | "success"
101
+ error={string}
102
+ success={string}
103
+ helpText={string}
104
+ className={string}
105
+ id={string}
106
+ on:input={(e) => console.log(e.detail.value, e.detail.event)}
107
+ on:change={(e) => console.log(e.detail.value, e.detail.event)}
108
+ />
39
109
  ```
40
110
 
41
- ### Basic Example
111
+ **Props:**
112
+ - `value`: Input value (bindable)
113
+ - `type`: Input type (default: "text")
114
+ - `label`: Input label
115
+ - `placeholder`: Input placeholder
116
+ - `required`: Mark as required (default: false)
117
+ - `disabled`: Disable the input (default: false)
118
+ - `size`: Input size (default: "md")
119
+ - `variant`: Input variant (default: "default")
120
+ - `error`: Error message
121
+ - `success`: Success message
122
+ - `helpText`: Helper text
123
+ - `className`: Additional CSS classes
124
+ - `id`: Input ID
125
+
126
+ **Events:**
127
+ - `input`: Fired on input - `{ detail: { value: string, event: InputEvent } }`
128
+ - `change`: Fired on change - `{ detail: { value: string, event: Event } }`
129
+
130
+ ### Card Component
42
131
 
43
132
  ```svelte
44
- <script lang="ts">
45
- import { Button, Card, Input } from 'zabi-components';
133
+ <Card
134
+ variant="default" | "elevated" | "outlined"
135
+ density="comfortable" | "compact"
136
+ disabled={boolean}
137
+ loading={boolean}
138
+ className={string}
139
+ on:click={(e) => console.log(e.detail.value, e.detail.event)}
140
+ >
141
+ <div slot="header">Header Content</div>
142
+ Main Content
143
+ <div slot="footer">Footer Content</div>
144
+ </Card>
145
+ ```
146
+
147
+ **Props:**
148
+ - `variant`: Card style variant (default: "default")
149
+ - `density`: Card density (default: "comfortable")
150
+ - `disabled`: Disable interactions (default: false)
151
+ - `loading`: Show loading state (default: false)
152
+ - `className`: Additional CSS classes
153
+
154
+ **Slots:**
155
+ - `header`: Card header content
156
+ - `default`: Main card content
157
+ - `footer`: Card footer content
158
+
159
+ **Events:**
160
+ - `click`: Fired when card is clicked - `{ detail: { value: true, event: MouseEvent } }`
161
+
162
+ ### Alert Component
163
+
164
+ ```svelte
165
+ <Alert
166
+ variant="info" | "success" | "warning" | "error"
167
+ title={string}
168
+ message={string}
169
+ closable={boolean}
170
+ className={string}
171
+ on:close={(e) => console.log(e.detail.value, e.detail.event)}
172
+ >
173
+ Custom Alert Content
174
+ </Alert>
175
+ ```
176
+
177
+ **Props:**
178
+ - `variant`: Alert type (default: "info")
179
+ - `title`: Alert title
180
+ - `message`: Alert message
181
+ - `closable`: Show close button (default: false)
182
+ - `className`: Additional CSS classes
183
+
184
+ **Slots:**
185
+ - `default`: Custom alert content (overrides message prop)
186
+
187
+ **Events:**
188
+ - `close`: Fired when alert is closed - `{ detail: { value: true, event: Event } }`
189
+
190
+ ## Theming
191
+
192
+ Zabi Components uses CSS custom properties for easy theming. You can customize the appearance by overriding these variables:
193
+
194
+ ```css
195
+ :root {
196
+ /* Primary Colors */
197
+ --zabi-primary: theme('colors.blue.600');
198
+ --zabi-primary-hover: theme('colors.blue.700');
199
+ --zabi-primary-active: theme('colors.blue.800');
46
200
 
47
- let name = '';
48
- let showCard = false;
49
- </script>
201
+ /* Secondary Colors */
202
+ --zabi-secondary: theme('colors.gray.600');
203
+ --zabi-secondary-hover: theme('colors.gray.700');
204
+
205
+ /* Success Colors */
206
+ --zabi-success: theme('colors.green.600');
207
+ --zabi-success-hover: theme('colors.green.700');
208
+
209
+ /* Warning Colors */
210
+ --zabi-warning: theme('colors.yellow.600');
211
+ --zabi-warning-hover: theme('colors.yellow.700');
212
+
213
+ /* Error Colors */
214
+ --zabi-error: theme('colors.red.600');
215
+ --zabi-error-hover: theme('colors.red.700');
216
+
217
+ /* Info Colors */
218
+ --zabi-info: theme('colors.blue.600');
219
+ --zabi-info-hover: theme('colors.blue.700');
220
+
221
+ /* Surface Colors */
222
+ --zabi-surface: theme('colors.white');
223
+ --zabi-surface-hover: theme('colors.gray.50');
224
+
225
+ /* Border Colors */
226
+ --zabi-border: theme('colors.gray.300');
227
+ --zabi-border-hover: theme('colors.gray.400');
228
+ --zabi-border-focus: theme('colors.blue.500');
229
+
230
+ /* Text Colors */
231
+ --zabi-text: theme('colors.gray.900');
232
+ --zabi-text-muted: theme('colors.gray.600');
233
+ --zabi-text-placeholder: theme('colors.gray.400');
234
+ --zabi-text-inverse: theme('colors.white');
235
+ }
236
+ ```
50
237
 
51
- <Input bind:value={name} placeholder="Enter your name" />
52
- <Button on:click={() => showCard = !showCard}>
53
- Toggle Card
54
- </Button>
238
+ ### Dark Mode
239
+
240
+ Dark mode is automatically supported through CSS custom properties:
55
241
 
56
- {#if showCard}
57
- <Card>
58
- <h2>Hello, {name}!</h2>
59
- </Card>
60
- {/if}
242
+ ```css
243
+ .dark {
244
+ --zabi-surface: theme('colors.gray.900');
245
+ --zabi-surface-hover: theme('colors.gray.800');
246
+ --zabi-text: theme('colors.gray.100');
247
+ --zabi-text-muted: theme('colors.gray.400');
248
+ --zabi-border: theme('colors.gray.700');
249
+ }
61
250
  ```
62
251
 
63
- ## Component Categories
64
-
65
- ### Atoms
66
- Basic building blocks of your UI:
67
- - `Badge` - Status indicators and labels
68
- - `Button` - Interactive buttons with variants
69
- - `Card` - Content containers
70
- - `Checkbox` - Form checkboxes
71
- - `ColorPicker` - Color selection input
72
- - `Heading` - Typography headings
73
- - `Input` - Text input fields
74
- - `OptimizedImage` - Performance-optimized images
75
- - `Select` - Dropdown selections
76
- - `Skeleton` - Loading placeholders
77
- - `Textarea` - Multi-line text input
78
- - `TextAlignment` - Text alignment controls
79
- - `Toggle` - Switch controls
80
-
81
- ### Molecules
82
- Simple combinations of atoms:
83
- - `Alert` - Notification messages
84
- - `Modal` - Overlay dialogs
85
- - `FileUpload` - File upload interface
86
- - `DynamicForm` - Dynamic form builder
87
- - `Dropdown` - Dropdown menus
88
- - `SlideUp` - Slide-up animations
89
-
90
- ### Organisms
91
- Complex components with state management:
92
- - `ToastContainer` - Notification management system
252
+ ## Event Structure
253
+
254
+ All components follow a consistent event structure:
255
+
256
+ ```typescript
257
+ interface BaseEventDetail<T = any> {
258
+ value: T;
259
+ event?: Event;
260
+ }
261
+ ```
262
+
263
+ **Examples:**
264
+ - Button click: `{ detail: { value: true, event: MouseEvent } }`
265
+ - Input change: `{ detail: { value: string, event: Event } }`
266
+ - Checkbox change: `{ detail: { value: boolean, event: Event } }`
93
267
 
94
268
  ## TypeScript Support
95
269
 
96
- The library includes comprehensive TypeScript definitions:
270
+ Full TypeScript definitions are included:
97
271
 
98
272
  ```typescript
99
- import type { FieldConfig } from 'zabi-components';
100
-
101
- const formConfig: FieldConfig[] = [
102
- {
103
- key: 'email',
104
- type: 'email',
105
- label: 'Email Address',
106
- required: true
107
- }
108
- ];
273
+ import type { ButtonEvents, InputEvents, CardEvents, AlertEvents } from 'zabi-components';
274
+
275
+ // Event handlers with proper typing
276
+ function handleButtonClick(event: CustomEvent<{ value: boolean; event?: MouseEvent }>) {
277
+ console.log('Button clicked:', event.detail.value);
278
+ }
109
279
  ```
110
280
 
111
- ## Styling
281
+ ## Advanced Usage
112
282
 
113
- Components are styled with Tailwind CSS. Make sure to include Tailwind in your project:
283
+ ### Custom Styling
114
284
 
115
- ```bash
116
- npm install -D tailwindcss
285
+ ```svelte
286
+ <Button
287
+ variant="primary"
288
+ size="lg"
289
+ className="w-full shadow-lg hover:shadow-xl"
290
+ on:click={(e) => console.log('Clicked!', e.detail.value)}
291
+ >
292
+ Custom Button
293
+ </Button>
117
294
  ```
118
295
 
119
- ## Development
296
+ ### Form Integration
120
297
 
121
- ```bash
122
- # Install dependencies
123
- npm install
298
+ ```svelte
299
+ <script>
300
+ import { Button, Input, Card, Alert } from 'zabi-components';
301
+
302
+ let formData = {
303
+ name: '',
304
+ email: '',
305
+ message: ''
306
+ };
307
+
308
+ let errors = {};
309
+ let showSuccess = false;
310
+
311
+ function validateForm() {
312
+ errors = {};
313
+ if (!formData.name) errors.name = 'Name is required';
314
+ if (!formData.email) errors.email = 'Email is required';
315
+ return Object.keys(errors).length === 0;
316
+ }
317
+
318
+ function handleSubmit() {
319
+ if (validateForm()) {
320
+ showSuccess = true;
321
+ // Submit form
322
+ }
323
+ }
324
+ </script>
325
+
326
+ <Card>
327
+ <div slot="header">
328
+ <h2>Contact Form</h2>
329
+ </div>
330
+
331
+ <form on:submit|preventDefault={handleSubmit}>
332
+ <Input
333
+ bind:value={formData.name}
334
+ label="Name"
335
+ placeholder="Enter your name"
336
+ required
337
+ error={errors.name}
338
+ />
339
+
340
+ <Input
341
+ bind:value={formData.email}
342
+ type="email"
343
+ label="Email"
344
+ placeholder="Enter your email"
345
+ required
346
+ error={errors.email}
347
+ />
348
+
349
+ <Input
350
+ bind:value={formData.message}
351
+ label="Message"
352
+ placeholder="Enter your message"
353
+ helpText="Tell us what you think"
354
+ />
355
+
356
+ <Button type="submit" variant="primary">
357
+ Send Message
358
+ </Button>
359
+ </form>
360
+
361
+ <div slot="footer">
362
+ <Alert variant="success" closable bind:show={showSuccess}>
363
+ Message sent successfully!
364
+ </Alert>
365
+ </div>
366
+ </Card>
367
+ ```
124
368
 
125
- # Start development server
126
- npm run dev
369
+ ## Contributing
127
370
 
128
- # Build library
129
- npm run build:lib
371
+ 1. Fork the repository
372
+ 2. Create your feature branch (`git checkout -b feature/amazing-feature`)
373
+ 3. Commit your changes (`git commit -m 'Add some amazing feature'`)
374
+ 4. Push to the branch (`git push origin feature/amazing-feature`)
375
+ 5. Open a Pull Request
130
376
 
131
- # Run Storybook
132
- npm run storybook
133
- ```
377
+ ## License
134
378
 
135
- ## Publishing
379
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
136
380
 
137
- To publish your component library:
381
+ ## Support
138
382
 
139
- 1. **Update version** in `package.json`
140
- 2. **Build the library**: `npm run build:lib`
141
- 3. **Test locally**: `npm pack` to create a tarball
142
- 4. **Publish**: `npm publish`
383
+ For support, please open an issue on GitHub or contact the maintainers.
143
384
 
144
- ## License
385
+ ---
145
386
 
146
- MIT
387
+ Built with ❤️ using Svelte, TypeScript, and Tailwind CSS.