zabi-components 1.0.7 → 1.0.9
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 +460 -79
- package/dist/Tabs-DTuXgJQh.js +1105 -0
- package/dist/{Toast-DXZ9gllw.js → Toast-1EMgTOM4.js} +80 -80
- package/dist/{ToastManager-dvTS81rT.js → ToastManager-ZcovxilX.js} +79 -79
- package/dist/Toggle-kQ6Z43Ep.js +2509 -0
- package/dist/Tooltip-gkAHhbjD.js +1152 -0
- package/dist/atoms/index.js +15 -15
- package/dist/index/index.js +314 -34
- package/dist/molecules/index.js +12 -8
- package/dist/organisms/index.js +1 -1
- package/dist/{x-DpVwziig.js → x-Dsi-CPO3.js} +11 -11
- package/package.json +6 -4
- package/dist/Tabs-DKLMuogz.js +0 -859
- package/dist/Toggle-B_5U5Wyh.js +0 -2278
- package/dist/Tooltip-DlYy9_rQ.js +0 -1212
package/README.md
CHANGED
|
@@ -1,18 +1,22 @@
|
|
|
1
1
|
# Zabi Components
|
|
2
2
|
|
|
3
|
-
A
|
|
3
|
+
A clean, minimal Svelte component library built with TypeScript and Tailwind CSS. **Less is more** - focused on essential components that just work.
|
|
4
|
+
|
|
5
|
+
## Philosophy
|
|
6
|
+
|
|
7
|
+
**Clean & Simple**: No unnecessary complexity, just clean components that focus on what matters most. Every component is designed to be intuitive, accessible, and performant.
|
|
4
8
|
|
|
5
9
|
## Features
|
|
6
10
|
|
|
7
|
-
- 🎨 **Consistent Design System** - Standardized props, events, and styling across all components
|
|
8
11
|
- 🎯 **TypeScript First** - Full TypeScript support with comprehensive type definitions
|
|
9
|
-
- 🎨 **Tailwind CSS Integration** - Built with Tailwind CSS
|
|
12
|
+
- 🎨 **Tailwind CSS Integration** - Built with Tailwind CSS for consistent styling
|
|
10
13
|
- ♿ **Accessibility First** - ARIA compliant components with keyboard navigation support
|
|
11
14
|
- 📱 **Responsive Design** - Mobile-first approach with responsive utilities
|
|
12
15
|
- 🎭 **Dark Mode Support** - Built-in dark mode support with CSS custom properties
|
|
13
|
-
- 🧩 **
|
|
16
|
+
- 🧩 **Clean API** - Simple, intuitive component APIs
|
|
14
17
|
- 📦 **Tree Shakeable** - Import only what you need
|
|
15
18
|
- ✅ **Production Ready** - Fully tested and optimized for production use
|
|
19
|
+
- 🚀 **Modern CSS** - Uses modern CSS features like Container Queries and CSS Grid
|
|
16
20
|
|
|
17
21
|
## Installation
|
|
18
22
|
|
|
@@ -53,53 +57,191 @@ import type { ButtonEvents, InputEvents } from 'zabi-components/types';
|
|
|
53
57
|
|
|
54
58
|
```svelte
|
|
55
59
|
<script lang="ts">
|
|
56
|
-
|
|
60
|
+
// Clean Components - Less is More
|
|
61
|
+
import { Card, Form, Layout, Navigation, Button, Input } from 'zabi-components';
|
|
57
62
|
|
|
58
|
-
let
|
|
59
|
-
|
|
63
|
+
let formData = {
|
|
64
|
+
name: '',
|
|
65
|
+
email: '',
|
|
66
|
+
};
|
|
60
67
|
|
|
61
|
-
function
|
|
62
|
-
console.log('Form submitted
|
|
63
|
-
showAlert = true;
|
|
68
|
+
function handleFormSubmit(event: CustomEvent) {
|
|
69
|
+
console.log('Form submitted:', event.detail.data);
|
|
64
70
|
}
|
|
65
71
|
|
|
66
|
-
function
|
|
67
|
-
console.log('
|
|
72
|
+
function handleCardClick(event: CustomEvent) {
|
|
73
|
+
console.log('Card clicked:', event.detail);
|
|
68
74
|
}
|
|
69
75
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
76
|
+
const navItems = [
|
|
77
|
+
{ label: "Home", href: "/" },
|
|
78
|
+
{ label: "About", href: "/about" },
|
|
79
|
+
{ label: "Contact", href: "/contact" },
|
|
80
|
+
];
|
|
73
81
|
</script>
|
|
74
82
|
|
|
75
|
-
<
|
|
76
|
-
<div slot="header">
|
|
77
|
-
<
|
|
83
|
+
<Layout variant="main" className="min-h-screen bg-gray-50">
|
|
84
|
+
<div slot="header" class="flex items-center justify-between p-4 bg-white border-b">
|
|
85
|
+
<h1 class="text-xl font-bold">My App</h1>
|
|
86
|
+
<Navigation variant="header" items={navItems} />
|
|
78
87
|
</div>
|
|
79
|
-
|
|
80
|
-
<
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
</
|
|
88
|
+
|
|
89
|
+
<main class="container mx-auto p-6">
|
|
90
|
+
<Card title="Welcome" description="Clean components that just work" interactive on:click={handleCardClick} />
|
|
91
|
+
|
|
92
|
+
<Form on:submit={handleFormSubmit}>
|
|
93
|
+
<div class="form-field">
|
|
94
|
+
<label for="name" class="form-label">Name</label>
|
|
95
|
+
<Input id="name" name="name" bind:value={formData.name} placeholder="Enter your name" />
|
|
96
|
+
</div>
|
|
97
|
+
|
|
98
|
+
<div class="form-field">
|
|
99
|
+
<label for="email" class="form-label">Email</label>
|
|
100
|
+
<Input id="email" name="email" type="email" bind:value={formData.email} placeholder="Enter your email" />
|
|
101
|
+
</div>
|
|
102
|
+
|
|
103
|
+
<div class="form-actions">
|
|
104
|
+
<Button type="submit" variant="primary" className="flex-1">Submit</Button>
|
|
105
|
+
</div>
|
|
106
|
+
</Form>
|
|
107
|
+
</main>
|
|
108
|
+
</Layout>
|
|
99
109
|
```
|
|
100
110
|
|
|
111
|
+
## Component Overview
|
|
112
|
+
|
|
113
|
+
### Core Components (Clean & Simple)
|
|
114
|
+
|
|
115
|
+
| Component | Category | Description | Key Features |
|
|
116
|
+
|-----------|----------|-------------|--------------|
|
|
117
|
+
| **Card** | Atom | Clean card container | Interactive, elevated variants, semantic HTML |
|
|
118
|
+
| **Form** | Molecule | Simple form wrapper | FormData handling, validation support |
|
|
119
|
+
| **Layout** | Molecule | Page layout system | Header, main, footer slots, responsive |
|
|
120
|
+
| **Navigation** | Organism | Clean navigation | Header/sidebar variants, keyboard nav |
|
|
121
|
+
| **Button** | Atom | Action button | Multiple variants, loading states |
|
|
122
|
+
| **Input** | Atom | Form input | Validation, error states, accessibility |
|
|
123
|
+
| **Badge** | Atom | Status indicator | Color variants, closable |
|
|
124
|
+
| **Alert** | Molecule | Notification | Dismissible, multiple variants |
|
|
125
|
+
| **Modal** | Molecule | Overlay dialog | Focus trap, keyboard navigation |
|
|
126
|
+
| **Tabs** | Molecule | Tab navigation | Keyboard navigation, ARIA compliant |
|
|
127
|
+
|
|
128
|
+
### Advanced Components
|
|
129
|
+
|
|
130
|
+
| Component | Category | Description | Key Features |
|
|
131
|
+
|-----------|----------|-------------|--------------|
|
|
132
|
+
| **KeyValueForm** | Molecule | Dynamic form builder | Field types, validation, TypeScript |
|
|
133
|
+
| **ImageUpload** | Molecule | File upload | Drag & drop, preview, validation |
|
|
134
|
+
| **Dropdown** | Molecule | Select dropdown | Search, keyboard navigation |
|
|
135
|
+
| **ToastManager** | Organism | Toast notifications | Queue management, positioning |
|
|
136
|
+
| **Navbar** | Organism | Navigation bar | Mobile menu, responsive |
|
|
137
|
+
|
|
101
138
|
## Component API
|
|
102
139
|
|
|
140
|
+
### Card Component
|
|
141
|
+
|
|
142
|
+
```svelte
|
|
143
|
+
<Card
|
|
144
|
+
title={string}
|
|
145
|
+
subtitle={string}
|
|
146
|
+
description={string}
|
|
147
|
+
image={string}
|
|
148
|
+
variant="default" | "elevated"
|
|
149
|
+
interactive={boolean}
|
|
150
|
+
className={string}
|
|
151
|
+
on:click={(e) => console.log(e.detail.event)}
|
|
152
|
+
>
|
|
153
|
+
Custom Content
|
|
154
|
+
</Card>
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
**Props:**
|
|
158
|
+
- `title`: Card title
|
|
159
|
+
- `subtitle`: Card subtitle
|
|
160
|
+
- `description`: Card description
|
|
161
|
+
- `image`: Card image URL
|
|
162
|
+
- `variant`: Card style variant (default: "default")
|
|
163
|
+
- `interactive`: Make card clickable (default: false)
|
|
164
|
+
- `className`: Additional CSS classes
|
|
165
|
+
|
|
166
|
+
**Events:**
|
|
167
|
+
- `click`: Fired when interactive card is clicked - `{ detail: { event: MouseEvent } }`
|
|
168
|
+
|
|
169
|
+
### Form Component
|
|
170
|
+
|
|
171
|
+
```svelte
|
|
172
|
+
<Form
|
|
173
|
+
method="get" | "post"
|
|
174
|
+
action={string}
|
|
175
|
+
className={string}
|
|
176
|
+
on:submit={(e) => console.log(e.detail.data, e.detail.formData)}
|
|
177
|
+
>
|
|
178
|
+
<div class="form-field">
|
|
179
|
+
<label for="field" class="form-label">Label</label>
|
|
180
|
+
<Input id="field" name="field" class="form-input" />
|
|
181
|
+
</div>
|
|
182
|
+
<div class="form-actions">
|
|
183
|
+
<Button type="submit">Submit</Button>
|
|
184
|
+
</div>
|
|
185
|
+
</Form>
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
**Props:**
|
|
189
|
+
- `method`: Form method (default: "post")
|
|
190
|
+
- `action`: Form action URL
|
|
191
|
+
- `className`: Additional CSS classes
|
|
192
|
+
|
|
193
|
+
**Events:**
|
|
194
|
+
- `submit`: Fired on form submission - `{ detail: { data: Record<string, FormDataEntryValue>, formData: FormData } }`
|
|
195
|
+
|
|
196
|
+
**CSS Classes:**
|
|
197
|
+
- `.form-field`: Field container
|
|
198
|
+
- `.form-label`: Field label
|
|
199
|
+
- `.form-input`: Field input
|
|
200
|
+
- `.form-actions`: Action buttons container
|
|
201
|
+
|
|
202
|
+
### Layout Component
|
|
203
|
+
|
|
204
|
+
```svelte
|
|
205
|
+
<Layout
|
|
206
|
+
variant="main" | "sidebar" | "grid"
|
|
207
|
+
className={string}
|
|
208
|
+
>
|
|
209
|
+
<div slot="header">Header Content</div>
|
|
210
|
+
Main Content
|
|
211
|
+
<div slot="footer">Footer Content</div>
|
|
212
|
+
</Layout>
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
**Props:**
|
|
216
|
+
- `variant`: Layout type (default: "main")
|
|
217
|
+
- `className`: Additional CSS classes
|
|
218
|
+
|
|
219
|
+
**Slots:**
|
|
220
|
+
- `header`: Header content
|
|
221
|
+
- `default`: Main content
|
|
222
|
+
- `footer`: Footer content
|
|
223
|
+
|
|
224
|
+
### Navigation Component
|
|
225
|
+
|
|
226
|
+
```svelte
|
|
227
|
+
<Navigation
|
|
228
|
+
variant="header" | "sidebar"
|
|
229
|
+
items={Array<{label: string, href: string, icon?: any}>}
|
|
230
|
+
currentPath={string}
|
|
231
|
+
className={string}
|
|
232
|
+
on:navigate={(e) => console.log(e.detail.item, e.detail.href)}
|
|
233
|
+
/>
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
**Props:**
|
|
237
|
+
- `variant`: Navigation type (default: "header")
|
|
238
|
+
- `items`: Navigation items array
|
|
239
|
+
- `currentPath`: Current active path
|
|
240
|
+
- `className`: Additional CSS classes
|
|
241
|
+
|
|
242
|
+
**Events:**
|
|
243
|
+
- `navigate`: Fired when navigation item is clicked - `{ detail: { item: NavigationItem, href: string } }`
|
|
244
|
+
|
|
103
245
|
### Button Component
|
|
104
246
|
|
|
105
247
|
```svelte
|
|
@@ -228,9 +370,56 @@ import type { ButtonEvents, InputEvents } from 'zabi-components/types';
|
|
|
228
370
|
**Events:**
|
|
229
371
|
- `close`: Fired when alert is closed - `{ detail: { value: true, event: Event } }`
|
|
230
372
|
|
|
373
|
+
## Modern CSS Features
|
|
374
|
+
|
|
375
|
+
Zabi Components leverages modern CSS features for better performance and developer experience:
|
|
376
|
+
|
|
377
|
+
### Container Queries
|
|
378
|
+
```css
|
|
379
|
+
.card {
|
|
380
|
+
container-type: inline-size;
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
@container (min-width: 300px) {
|
|
384
|
+
.card-content {
|
|
385
|
+
display: flex;
|
|
386
|
+
flex-direction: row;
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
```
|
|
390
|
+
|
|
391
|
+
### CSS Grid & Subgrid
|
|
392
|
+
```css
|
|
393
|
+
.layout-grid {
|
|
394
|
+
display: grid;
|
|
395
|
+
grid-template-columns: subgrid;
|
|
396
|
+
gap: 1rem;
|
|
397
|
+
}
|
|
398
|
+
```
|
|
399
|
+
|
|
400
|
+
### CSS Logical Properties
|
|
401
|
+
```css
|
|
402
|
+
.component {
|
|
403
|
+
margin-inline-start: 1rem;
|
|
404
|
+
padding-block: 0.5rem;
|
|
405
|
+
border-inline-end: 1px solid;
|
|
406
|
+
}
|
|
407
|
+
```
|
|
408
|
+
|
|
409
|
+
### CSS Cascade Layers
|
|
410
|
+
```css
|
|
411
|
+
@layer base, components, utilities;
|
|
412
|
+
|
|
413
|
+
@layer components {
|
|
414
|
+
.card {
|
|
415
|
+
/* Component styles */
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
```
|
|
419
|
+
|
|
231
420
|
## Theming
|
|
232
421
|
|
|
233
|
-
Zabi Components uses CSS custom properties for easy theming. You can customize the appearance by overriding these variables:
|
|
422
|
+
Zabi Components uses CSS custom properties and Tailwind CSS for easy theming. You can customize the appearance by overriding these variables:
|
|
234
423
|
|
|
235
424
|
```css
|
|
236
425
|
:root {
|
|
@@ -308,21 +497,69 @@ interface BaseEventDetail<T = any> {
|
|
|
308
497
|
|
|
309
498
|
## TypeScript Support
|
|
310
499
|
|
|
311
|
-
Full TypeScript definitions are included with
|
|
500
|
+
Full TypeScript definitions are included with comprehensive type safety:
|
|
312
501
|
|
|
502
|
+
### Event Types
|
|
313
503
|
```typescript
|
|
314
|
-
import type {
|
|
315
|
-
|
|
316
|
-
|
|
504
|
+
import type {
|
|
505
|
+
ButtonEvents,
|
|
506
|
+
InputEvents,
|
|
507
|
+
CardEvents,
|
|
508
|
+
FormEvents,
|
|
509
|
+
NavigationEvents,
|
|
510
|
+
KeyValueFormEvents
|
|
511
|
+
} from 'zabi-components';
|
|
512
|
+
|
|
513
|
+
// Properly typed event handlers
|
|
317
514
|
function handleButtonClick(event: CustomEvent<{ value: boolean; event?: MouseEvent }>) {
|
|
318
515
|
console.log('Button clicked:', event.detail.value);
|
|
319
516
|
}
|
|
320
517
|
|
|
321
|
-
function
|
|
322
|
-
|
|
518
|
+
function handleFormSubmit(event: CustomEvent<{
|
|
519
|
+
data: Record<string, FormDataEntryValue>;
|
|
520
|
+
formData: FormData
|
|
521
|
+
}>) {
|
|
522
|
+
console.log('Form data:', event.detail.data);
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
function handleNavigation(event: CustomEvent<{
|
|
526
|
+
item: NavigationItem;
|
|
527
|
+
href: string
|
|
528
|
+
}>) {
|
|
529
|
+
console.log('Navigate to:', event.detail.href);
|
|
530
|
+
}
|
|
531
|
+
```
|
|
532
|
+
|
|
533
|
+
### Component Props
|
|
534
|
+
```typescript
|
|
535
|
+
// All components have proper prop typing
|
|
536
|
+
interface CardProps {
|
|
537
|
+
title?: string;
|
|
538
|
+
subtitle?: string;
|
|
539
|
+
description?: string;
|
|
540
|
+
image?: string;
|
|
541
|
+
variant?: "default" | "elevated";
|
|
542
|
+
interactive?: boolean;
|
|
543
|
+
className?: string;
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
interface FormProps {
|
|
547
|
+
method?: "get" | "post";
|
|
548
|
+
action?: string;
|
|
549
|
+
className?: string;
|
|
323
550
|
}
|
|
324
551
|
```
|
|
325
552
|
|
|
553
|
+
### Event Dispatchers
|
|
554
|
+
```typescript
|
|
555
|
+
// Components use typed event dispatchers
|
|
556
|
+
const dispatch = createEventDispatcher<{
|
|
557
|
+
click: { event: MouseEvent };
|
|
558
|
+
submit: { data: Record<string, FormDataEntryValue>; formData: FormData };
|
|
559
|
+
navigate: { item: NavigationItem; href: string };
|
|
560
|
+
}>();
|
|
561
|
+
```
|
|
562
|
+
|
|
326
563
|
### Event Types
|
|
327
564
|
|
|
328
565
|
All components use standardized event types:
|
|
@@ -481,66 +718,209 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file
|
|
|
481
718
|
|
|
482
719
|
## Changelog
|
|
483
720
|
|
|
484
|
-
### v1.0.
|
|
721
|
+
### v1.0.7 (Latest) - "Less is More" Edition
|
|
722
|
+
|
|
723
|
+
#### 🎯 Philosophy Change
|
|
724
|
+
- **Clean & Simple**: Adopted "less is more" philosophy - removed unnecessary complexity
|
|
725
|
+
- **Focused Components**: Streamlined to essential components that just work
|
|
726
|
+
- **Clean Naming**: Removed "Simple" prefixes - it's just Card, Form, Layout, Navigation
|
|
727
|
+
|
|
728
|
+
#### ✨ New Clean Components
|
|
729
|
+
- **Card**: Clean, semantic card container with interactive support
|
|
730
|
+
- **Form**: Simple form wrapper with FormData handling and validation
|
|
731
|
+
- **Layout**: Page layout system with header, main, footer slots
|
|
732
|
+
- **Navigation**: Clean navigation with header/sidebar variants
|
|
485
733
|
|
|
486
734
|
#### 🐛 Bug Fixes
|
|
487
|
-
- **Fixed
|
|
488
|
-
- **Fixed
|
|
489
|
-
- **Fixed
|
|
490
|
-
- **Fixed
|
|
491
|
-
- **Fixed
|
|
492
|
-
|
|
493
|
-
####
|
|
494
|
-
-
|
|
495
|
-
-
|
|
496
|
-
-
|
|
497
|
-
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
-
|
|
502
|
-
-
|
|
735
|
+
- **Fixed TypeScript Errors**: Resolved all event handler type mismatches
|
|
736
|
+
- **Fixed Import Paths**: Corrected .js extensions in lib exports
|
|
737
|
+
- **Fixed CSS Issues**: Resolved `:global()` selector placement errors
|
|
738
|
+
- **Fixed Variant Types**: Corrected component variant type mismatches
|
|
739
|
+
- **Fixed Accessibility**: Resolved tabindex warnings for non-interactive elements
|
|
740
|
+
|
|
741
|
+
#### 🚀 Modern CSS Features
|
|
742
|
+
- **Container Queries**: Added support for container-based responsive design
|
|
743
|
+
- **CSS Grid & Subgrid**: Implemented modern grid layouts
|
|
744
|
+
- **CSS Logical Properties**: Added RTL support with logical properties
|
|
745
|
+
- **CSS Cascade Layers**: Organized styles with cascade layers
|
|
746
|
+
- **CSS Containment**: Added performance optimizations
|
|
747
|
+
|
|
748
|
+
#### 📦 TypeScript Improvements
|
|
749
|
+
- **Event Type Safety**: All components now have proper event typing
|
|
750
|
+
- **Component Props**: Comprehensive prop type definitions
|
|
751
|
+
- **Event Dispatchers**: Typed event dispatchers for all components
|
|
752
|
+
- **Type Generation**: Proper TypeScript declaration generation
|
|
753
|
+
|
|
754
|
+
#### 🎨 Design System
|
|
755
|
+
- **Semantic HTML**: All components use proper semantic elements
|
|
756
|
+
- **Accessibility**: ARIA compliant with keyboard navigation
|
|
757
|
+
- **Dark Mode**: Built-in dark mode support with CSS custom properties
|
|
758
|
+
- **Responsive**: Mobile-first responsive design
|
|
759
|
+
|
|
760
|
+
## Development Setup
|
|
761
|
+
|
|
762
|
+
### Prerequisites
|
|
763
|
+
- Node.js 18+
|
|
764
|
+
- npm or yarn
|
|
765
|
+
- Svelte 4+ or SvelteKit 2+
|
|
766
|
+
|
|
767
|
+
### Local Development
|
|
768
|
+
```bash
|
|
769
|
+
# Clone the repository
|
|
770
|
+
git clone https://github.com/your-username/zabi-components.git
|
|
771
|
+
cd zabi-components
|
|
503
772
|
|
|
504
|
-
|
|
773
|
+
# Install dependencies
|
|
774
|
+
npm install
|
|
505
775
|
|
|
506
|
-
|
|
776
|
+
# Start development server
|
|
777
|
+
npm run dev
|
|
507
778
|
|
|
508
|
-
|
|
509
|
-
|
|
779
|
+
# Build library
|
|
780
|
+
npm run build
|
|
510
781
|
|
|
511
|
-
|
|
512
|
-
npm
|
|
782
|
+
# Run type checking
|
|
783
|
+
npm run check
|
|
784
|
+
|
|
785
|
+
# Run tests
|
|
786
|
+
npm run test
|
|
513
787
|
```
|
|
514
788
|
|
|
515
|
-
|
|
516
|
-
|
|
789
|
+
### Project Structure
|
|
790
|
+
```
|
|
791
|
+
src/
|
|
792
|
+
├── components/
|
|
793
|
+
│ ├── atoms/ # Basic UI components
|
|
794
|
+
│ ├── molecules/ # Composite components
|
|
795
|
+
│ └── organisms/ # Complex components
|
|
796
|
+
├── types/ # TypeScript definitions
|
|
797
|
+
├── styles/ # CSS and styling
|
|
798
|
+
└── lib/ # Library exports
|
|
799
|
+
```
|
|
800
|
+
|
|
801
|
+
## Troubleshooting
|
|
802
|
+
|
|
803
|
+
### Common Issues
|
|
804
|
+
|
|
805
|
+
#### TypeScript Errors
|
|
806
|
+
If you see TypeScript errors with event handlers, ensure proper typing:
|
|
517
807
|
|
|
518
808
|
```typescript
|
|
519
|
-
// ✅ Correct
|
|
809
|
+
// ✅ Correct - properly typed event handlers
|
|
810
|
+
function handleClick(event: CustomEvent<{ event: MouseEvent }>) {
|
|
811
|
+
console.log('Clicked:', event.detail.event);
|
|
812
|
+
}
|
|
813
|
+
|
|
814
|
+
function handleFormSubmit(event: CustomEvent<{
|
|
815
|
+
data: Record<string, FormDataEntryValue>;
|
|
816
|
+
formData: FormData
|
|
817
|
+
}>) {
|
|
818
|
+
console.log('Form data:', event.detail.data);
|
|
819
|
+
}
|
|
820
|
+
|
|
821
|
+
// ❌ Incorrect - missing proper typing
|
|
520
822
|
function handleClick(event: CustomEvent) {
|
|
521
|
-
console.log(event.detail.value);
|
|
823
|
+
console.log(event.detail.value); // May cause type errors
|
|
522
824
|
}
|
|
825
|
+
```
|
|
826
|
+
|
|
827
|
+
#### CSS @apply Warnings
|
|
828
|
+
If you see "Unknown at rule @apply" warnings in your IDE:
|
|
523
829
|
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
830
|
+
1. Install Tailwind CSS IntelliSense extension
|
|
831
|
+
2. Add to your VS Code settings:
|
|
832
|
+
```json
|
|
833
|
+
{
|
|
834
|
+
"css.customData": [".vscode/tailwind.json"],
|
|
835
|
+
"tailwindCSS.includeLanguages": {
|
|
836
|
+
"svelte": "html"
|
|
837
|
+
}
|
|
527
838
|
}
|
|
528
839
|
```
|
|
529
840
|
|
|
841
|
+
#### Import Errors
|
|
842
|
+
If you encounter import errors, ensure you're using the latest version:
|
|
843
|
+
|
|
844
|
+
```bash
|
|
845
|
+
npm install zabi-components@latest
|
|
846
|
+
```
|
|
847
|
+
|
|
530
848
|
#### Runtime Errors
|
|
531
849
|
If you encounter runtime errors, ensure you have the correct peer dependencies:
|
|
532
850
|
|
|
533
851
|
```bash
|
|
534
|
-
npm install svelte@^5.0.0 @sveltejs/kit@^2.0.0
|
|
852
|
+
npm install svelte@^4.0.0 || ^5.0.0 @sveltejs/kit@^2.0.0
|
|
535
853
|
```
|
|
536
854
|
|
|
537
855
|
### Migration from Previous Versions
|
|
538
856
|
|
|
539
857
|
If you're upgrading from a previous version, note these changes:
|
|
540
858
|
|
|
541
|
-
1. **
|
|
542
|
-
2. **
|
|
859
|
+
1. **Clean Components**: New Card, Form, Layout, Navigation components
|
|
860
|
+
2. **Event Structure**: All events follow standardized structure
|
|
543
861
|
3. **TypeScript**: Enhanced type definitions with proper event typing
|
|
862
|
+
4. **Modern CSS**: Uses Container Queries, CSS Grid, and logical properties
|
|
863
|
+
|
|
864
|
+
## Performance & Best Practices
|
|
865
|
+
|
|
866
|
+
### Performance Optimizations
|
|
867
|
+
- **Tree Shaking**: Import only what you need
|
|
868
|
+
- **CSS Containment**: Components use CSS containment for better performance
|
|
869
|
+
- **Efficient Animations**: Uses `will-change` and `transform` for smooth animations
|
|
870
|
+
- **Lazy Loading**: Components support lazy loading when needed
|
|
871
|
+
|
|
872
|
+
### Best Practices
|
|
873
|
+
|
|
874
|
+
#### Component Usage
|
|
875
|
+
```svelte
|
|
876
|
+
<!-- ✅ Good - Use semantic HTML -->
|
|
877
|
+
<Card title="User Profile" interactive on:click={handleClick}>
|
|
878
|
+
<p>User information</p>
|
|
879
|
+
</Card>
|
|
880
|
+
|
|
881
|
+
<!-- ❌ Avoid - Unnecessary complexity -->
|
|
882
|
+
<div class="custom-card" on:click={handleClick}>
|
|
883
|
+
<h3>User Profile</h3>
|
|
884
|
+
<p>User information</p>
|
|
885
|
+
</div>
|
|
886
|
+
```
|
|
887
|
+
|
|
888
|
+
#### Event Handling
|
|
889
|
+
```typescript
|
|
890
|
+
// ✅ Good - Proper event typing
|
|
891
|
+
function handleFormSubmit(event: CustomEvent<{
|
|
892
|
+
data: Record<string, FormDataEntryValue>;
|
|
893
|
+
formData: FormData
|
|
894
|
+
}>) {
|
|
895
|
+
// Handle form submission
|
|
896
|
+
console.log('Form data:', event.detail.data);
|
|
897
|
+
}
|
|
898
|
+
|
|
899
|
+
// ❌ Avoid - Untyped events
|
|
900
|
+
function handleFormSubmit(event: any) {
|
|
901
|
+
console.log(event.detail); // No type safety
|
|
902
|
+
}
|
|
903
|
+
```
|
|
904
|
+
|
|
905
|
+
#### Styling
|
|
906
|
+
```svelte
|
|
907
|
+
<!-- ✅ Good - Use component props and Tailwind -->
|
|
908
|
+
<Button variant="primary" size="lg" className="w-full">
|
|
909
|
+
Submit
|
|
910
|
+
</Button>
|
|
911
|
+
|
|
912
|
+
<!-- ❌ Avoid - Inline styles -->
|
|
913
|
+
<button style="background: blue; width: 100%;">
|
|
914
|
+
Submit
|
|
915
|
+
</button>
|
|
916
|
+
```
|
|
917
|
+
|
|
918
|
+
### Accessibility Guidelines
|
|
919
|
+
- Always provide proper labels and ARIA attributes
|
|
920
|
+
- Ensure keyboard navigation works correctly
|
|
921
|
+
- Use semantic HTML elements
|
|
922
|
+
- Test with screen readers
|
|
923
|
+
- Maintain proper color contrast ratios
|
|
544
924
|
|
|
545
925
|
## Support
|
|
546
926
|
|
|
@@ -548,4 +928,5 @@ For support, please open an issue on GitHub or contact the maintainers.
|
|
|
548
928
|
|
|
549
929
|
---
|
|
550
930
|
|
|
551
|
-
Built with ❤️ using Svelte, TypeScript, and Tailwind CSS.
|
|
931
|
+
Built with ❤️ using Svelte, TypeScript, and Tailwind CSS.
|
|
932
|
+
**Less is more** - Clean components that just work.
|