@svelte-atoms/core 1.0.0-alpha.23 → 1.0.0-alpha.25

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 (56) hide show
  1. package/README.md +645 -645
  2. package/dist/components/accordion/accordion-root.svelte.d.ts +2 -2
  3. package/dist/components/alert/alert-actions.svelte.d.ts +1 -0
  4. package/dist/components/alert/alert-close-button.svelte.d.ts +1 -0
  5. package/dist/components/alert/alert-content.svelte.d.ts +1 -0
  6. package/dist/components/atom/html-atom.svelte +151 -4
  7. package/dist/components/atom/html-atom.svelte.d.ts +4 -2
  8. package/dist/components/atom/types.d.ts +7 -0
  9. package/dist/components/button/button.stories.svelte +57 -17
  10. package/dist/components/button/button.stories.svelte.d.ts +6 -14
  11. package/dist/components/checkbox/checkbox.svelte.d.ts +1 -1
  12. package/dist/components/combobox/combobox-root.svelte.d.ts +2 -2
  13. package/dist/components/datagrid/datagrid.stories.svelte +75 -75
  14. package/dist/components/drawer/drawer-backdrop.svelte.d.ts +1 -0
  15. package/dist/components/icon/icon.svelte.d.ts +1 -0
  16. package/dist/components/input/input-placeholder.svelte +56 -56
  17. package/dist/components/input/input-placeholder.svelte.d.ts +1 -0
  18. package/dist/components/input/input-root.svelte +79 -79
  19. package/dist/components/input/input-root.svelte.d.ts +1 -0
  20. package/dist/components/input/input-value.svelte +113 -113
  21. package/dist/components/input/input-value.svelte.d.ts +1 -1
  22. package/dist/components/input/input.stories.svelte +38 -38
  23. package/dist/components/label/label.svelte.d.ts +1 -0
  24. package/dist/components/layer/layer-inner.svelte.d.ts +1 -0
  25. package/dist/components/layer/layer-root.svelte.d.ts +1 -0
  26. package/dist/components/popover/popover-arrow.svelte.d.ts +1 -0
  27. package/dist/components/portal/portal-inner.svelte.d.ts +1 -0
  28. package/dist/components/portal/portal-root.svelte.d.ts +1 -0
  29. package/dist/components/portal/teleport.svelte.d.ts +1 -0
  30. package/dist/components/radio/radio.svelte.d.ts +2 -2
  31. package/dist/components/root/root.svelte +121 -103
  32. package/dist/components/root/root.svelte.d.ts +1 -0
  33. package/dist/components/stack/stack-root.svelte.d.ts +1 -0
  34. package/dist/components/toast/toast-description.svelte.d.ts +1 -0
  35. package/dist/components/toast/toast-root.svelte.d.ts +1 -0
  36. package/dist/components/toast/toast-title.svelte.d.ts +1 -0
  37. package/dist/components/tree/tree-header.svelte.d.ts +1 -0
  38. package/dist/context/preset.svelte.d.ts +3 -0
  39. package/dist/runes/index.d.ts +3 -0
  40. package/dist/runes/index.js +3 -0
  41. package/dist/runes/reduced-motion.svelte.d.ts +23 -0
  42. package/dist/runes/reduced-motion.svelte.js +41 -0
  43. package/dist/utils/index.d.ts +1 -0
  44. package/dist/utils/index.js +1 -0
  45. package/dist/utils/variant.d.ts +213 -0
  46. package/dist/utils/variant.js +137 -0
  47. package/llm/composition.md +395 -0
  48. package/llm/crafting.md +838 -0
  49. package/llm/motion.md +970 -0
  50. package/llm/philosophy.md +23 -0
  51. package/llm/preset-variant-integration.md +516 -0
  52. package/llm/preset.md +383 -0
  53. package/llm/styling.md +216 -0
  54. package/llm/usage.md +46 -0
  55. package/llm/variants.md +712 -0
  56. package/package.json +2 -1
package/README.md CHANGED
@@ -1,645 +1,645 @@
1
- # ⚛️ @svelte-atoms/core
2
-
3
- > A modern, modular, and accessible Svelte 5 UI component library built with composability at its core.
4
-
5
- **@svelte-atoms/core** is a comprehensive Svelte component library that provides fundamental building blocks ("atoms") for creating sophisticated, interactive design systems. Each component is designed with accessibility, type safety, and developer experience in mind. Built with Svelte 5 runes for optimal reactivity and performance.
6
-
7
- [![npm version](https://img.shields.io/npm/v/@svelte-atoms/core.svg)](https://www.npmjs.com/package/@svelte-atoms/core)
8
- [![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/svelte-atoms/core)
9
- [![license](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
10
-
11
- ---
12
-
13
- ## ✨ Features
14
-
15
- ### 🧱 **Bond Architecture**
16
-
17
- Built around the concept of "Bonds" - self-contained, reusable state management classes that encapsulate component state and DOM interactions. Each component uses the Bond pattern for consistent, predictable behavior across complex interactions. Simple components like Button don't require the Bond pattern as they have minimal state management needs.
18
-
19
- ### 🔗 **Context-Driven Communication**
20
-
21
- Components seamlessly communicate through Svelte's context API using standardized static methods (`Bond.get()` / `Bond.set()`) of the Bond class, enabling powerful parent-child relationships without prop drilling.
22
-
23
- ### ♿ **Accessibility First**
24
-
25
- Every component includes proper ARIA attributes, keyboard navigation, and focus management out of the box.
26
-
27
- ### 🔧 **Highly Extensible**
28
-
29
- Easily extend components with custom behaviors, animations, and styling while maintaining the core functionality.
30
-
31
- ### 🎯 **Type Safety**
32
-
33
- Fully written in TypeScript with comprehensive type definitions for a robust development experience.
34
-
35
- ### ⚡ **Reactive by Design**
36
-
37
- Leverages Svelte's fine-grained reactivity system for optimal performance and smooth user interactions.
38
-
39
- ### 🎨 **Headless & Stylable**
40
-
41
- Components are headless by default, giving you complete control over styling while providing sensible defaults.
42
-
43
- ### 🧩 **Composable**
44
-
45
- Build complex UIs by combining simple, reusable components. Each component is designed to work seamlessly with others through the Bond pattern and context API. Create sophisticated features like multi-level dropdowns, nested accordions, or custom form controls by composing atomic components together.
46
-
47
- ---
48
-
49
- ## 📦 Available Components
50
-
51
- Our comprehensive collection of UI components with implementation status:
52
-
53
- ### Layout & Navigation
54
-
55
- | Component | Description | Status |
56
- | ----------------------------------------------- | ---------------------------- | ------ |
57
- | [**Accordion**](docs/components/accordion.md) | Collapsible content sections | ✅ |
58
- | [**Breadcrumb**](docs/components/breadcrumb.md) | Navigation hierarchy | ✅ |
59
- | [**Sidebar**](docs/components/sidebar.md) | Collapsible side navigation | ✅ |
60
- | [**Tabs**](docs/components/tabs.md) | Tabbed interfaces | ✅ |
61
- | [**Tree**](docs/components/tree.md) | Hierarchical data structures | ✅ |
62
- | **Stepper** | Multi-step process indicator | ❌ |
63
- | **Pagination** | Page navigation controls | ❌ |
64
-
65
- ### Forms & Input
66
-
67
- | Component | Description | Status |
68
- | ------------------------------------------- | ------------------------------------ | ------ |
69
- | [**Button**](docs/components/button.md) | Interactive buttons with variants | ✅ |
70
- | [**Checkbox**](docs/components/checkbox.md) | Multi-select inputs | ✅ |
71
- | [**Combobox**](docs/components/combobox.md) | Searchable select inputs | ✅ |
72
- | [**Input**](docs/components/input.md) | Text input fields | ✅ |
73
- | [**Radio**](docs/components/radio.md) | Single-select inputs | ✅ |
74
- | **Slider** | Range input controls | ❌ |
75
- | **Switch** | Toggle controls | ❌ |
76
- | [**Textarea**](docs/components/textarea.md) | Multi-line text inputs | ✅ |
77
- | [**Form**](docs/components/form.md) | Form validation and state management | ✅ |
78
- | **DatePicker** | Date selection component | ❌ |
79
- | **TimePicker** | Time selection component | ❌ |
80
- | **FileUpload** | File upload component | ❌ |
81
- | **ColorPicker** | Color selection component | ❌ |
82
- | **Rating** | Star rating component | ❌ |
83
-
84
- ### Data Display
85
-
86
- | Component | Description | Status |
87
- | ------------------------------------------- | --------------------------- | ------ |
88
- | [**Avatar**](docs/components/avatar.md) | User profile images | ✅ |
89
- | [**Badge**](docs/components/badge.md) | Status indicators | ✅ |
90
- | [**DataGrid**](docs/components/datagrid.md) | Advanced data tables | ✅ |
91
- | [**Divider**](docs/components/divider.md) | Content separators | ✅ |
92
- | [**Icon**](docs/components/icon.md) | Scalable icons | ✅ |
93
- | [**Label**](docs/components/label.md) | Form labels | ✅ |
94
- | [**Link**](docs/components/link.md) | Navigation links | ✅ |
95
- | [**List**](docs/components/list.md) | Structured lists | ✅ |
96
- | [**Card**](docs/components/card.md) | Content containers | ✅ |
97
- | **Table** | Simple data tables | ❌ |
98
- | **Chip** | Compact information display | ❌ |
99
- | **Progress** | Progress indicators | ❌ |
100
- | **Skeleton** | Loading placeholders | ❌ |
101
- | **Timeline** | Event timeline display | ❌ |
102
- | **Calendar** | Date display component | ❌ |
103
-
104
- ### Overlays & Feedback
105
-
106
- | Component | Description | Status |
107
- | ------------------------------------------------- | ------------------------ | ------ |
108
- | [**Dialog**](docs/components/dialog.md) | Modal dialogs | ✅ |
109
- | [**Dropdown**](docs/components/dropdown.md) | Contextual menus | ✅ |
110
- | [**Popover**](docs/components/popover.md) | Contextual information | ✅ |
111
- | [**Toast**](docs/components/toast.md) | Notification messages | ✅ |
112
- | [**Tooltip**](docs/components/tooltip.md) | Contextual hints | ✅ |
113
- | [**ContextMenu**](docs/components/contextmenu.md) | Right-click menus | ✅ |
114
- | [**Drawer**](docs/components/drawer.md) | Slide-out panels | ✅ |
115
- | [**Alert**](docs/components/alert.md) | Alert messages | ✅ |
116
- | **Banner** | Full-width notifications | ❌ |
117
- | **Spotlight** | Feature highlighting | ❌ |
118
-
119
- ### Utilities & Layout
120
-
121
- | Component | Description | Status |
122
- | ------------------------------------------------- | ----------------------------------- | ------ |
123
- | [**Portal**](docs/components/portal.md) | Declare a portal anywhere in DOM | ✅ |
124
- | **Teleport** | Render content in a specific portal | ✅ |
125
- | **Root** | Application root container | ✅ |
126
- | [**Layer**](docs/components/layer.md) | Layer management utility | ✅ |
127
- | [**Collapsible**](docs/components/collapsible.md) | Generic collapsible wrapper | ✅ |
128
- | **Container** | Layout container | ✅ |
129
- | [**Scrollable**](docs/components/scrollable.md) | Custom scrollbar component | ✅ |
130
- | [**Stack**](docs/components/stack.md) | Flexible layout stacking component | ✅ |
131
- | **Spacer** | Space management utility | ❌ |
132
- | **VirtualList** | Virtual scrolling list | ❌ |
133
-
134
- ---
135
-
136
- ## 🏗️ Architecture
137
-
138
- The library is organized into distinct layers for maximum maintainability and extensibility:
139
-
140
- ```
141
- src/lib/
142
- ├── components/ # 30+ Core UI components
143
- ├── shared/ # Base classes (Bond, BondState) and utilities
144
- ├── helpers/ # Helper functions and components
145
- ├── attachments/ # DOM attachment utilities
146
- ├── runes/ # Reactive utilities (Svelte 5 runes)
147
- ├── types/ # TypeScript type definitions
148
- └── utils/ # General utility functions
149
- ```
150
-
151
- ### Bond Pattern
152
-
153
- Each component follows a consistent Bond pattern:
154
-
155
- - **Bond Class**: Manages component state and DOM interactions
156
- - **BondState Class**: Holds reactive component state using Svelte 5 runes
157
- - **Context Methods**: Static `CONTEXT_KEY`, `get()`, and `set()` methods for component communication
158
- - **Component Files**: Svelte components that use the Bond for behavior
159
-
160
- ```typescript
161
- class MyComponentBond extends Bond<MyComponentBondState> {
162
- static CONTEXT_KEY = '@atoms/context/my-component';
163
-
164
- static get(): MyComponentBond | undefined {
165
- return getContext(MyComponentBond.CONTEXT_KEY);
166
- }
167
-
168
- static set(bond: MyComponentBond): MyComponentBond {
169
- return setContext(MyComponentBond.CONTEXT_KEY, bond);
170
- }
171
- }
172
- ```
173
-
174
- ---
175
-
176
- ## 🚀 Quick Start
177
-
178
- ### Installation
179
-
180
- ```bash
181
- # npm
182
- npm install @svelte-atoms/core
183
-
184
- # yarn
185
- yarn install @svelte-atoms/core
186
-
187
- # pnpm
188
- pnpm add @svelte-atoms/core
189
-
190
- # bun
191
- bun add @svelte-atoms/core
192
- ```
193
-
194
- ### Basic Usage
195
-
196
- ```svelte
197
- <script lang="ts">
198
- import { Button, Dialog, Input } from '@svelte-atoms/core';
199
-
200
- let dialogOpen = $state(false);
201
- let inputValue = '';
202
- </script>
203
-
204
- <!-- Simple Button -->
205
- <Button onclick={() => (dialogOpen = true)}>Open Dialog</Button>
206
-
207
- <!-- Dialog with Input -->
208
- <Dialog.Root bind:open={dialogOpen}>
209
- <Dialog.Content>
210
- <Dialog.Header>
211
- <Dialog.Title>Enter your name</Dialog.Title>
212
- </Dialog.Header>
213
- <Dialog.Body>
214
- <Input.Root>
215
- <Input.Value bind:value={inputValue} placeholder="Your name...">
216
- </Input.Root>
217
- </Dialog.Body>
218
- <Dialog.Footer>
219
- <Button.Root onclick={() => (dialogOpen = false)}>Cancel</Button.Root>
220
- <Button.Root variant="primary" onclick={() => (dialogOpen = false)}>Confirm</Button.Root>
221
- </Dialog.Footer>
222
- </Dialog.Content>
223
- </Dialog.Root>
224
- ```
225
-
226
- ### Advanced Usage with Bonds
227
-
228
- For more control, you can use the Bond system directly:
229
-
230
- ```svelte
231
- <script lang="ts">
232
- import { DialogBond, DialogBondState } from '@svelte-atoms/core/dialog';
233
-
234
- const { open = false, disable = false } = $props();
235
-
236
- const bondProps = defineState(
237
- [
238
- defineProperty(
239
- 'open',
240
- () => open,
241
- (v) => (open = v)
242
- ),
243
- defineProperty('disable', () => disable)
244
- ],
245
- {
246
- // Other props
247
- }
248
- );
249
-
250
- // Create dialog state
251
- const dialogState = new DialogBondState(() => bondProps);
252
-
253
- // Create dialog bond
254
- // Make available via context
255
- const dialogBond = new DialogBond(dialogState).share();
256
- </script>
257
-
258
- <div {...dialogBond.root()}>
259
- <button {...dialogBond.trigger()} onclick={() => dialogBond.state.toggle()}>
260
- Toggle Dialog
261
- </button>
262
-
263
- {#if open}
264
- <div {...dialogBond.overlay()}>
265
- <div {...dialogBond.content()}>
266
- <h2 {...dialogBond.title()}>Dialog Title</h2>
267
- <p>Dialog content goes here...</p>
268
- <button onclick={() => dialogBond.state.close()}>Close</button>
269
- </div>
270
- </div>
271
- {/if}
272
- </div>
273
- ```
274
-
275
- ### Advanced Usage With Composition
276
-
277
- This example demonstrates the power of component composition by combining `Dropdown`, `Input`, and animation capabilities to create a searchable multi-select dropdown with smooth transitions:
278
-
279
- ```svelte
280
- <script lang="ts">
281
- import { Dropdown, Input, Root, filter } from '@svelte-atoms/core';
282
- import { flip } from 'svelte/animate';
283
-
284
- // Sample data
285
- let data = [
286
- { id: 1, value: 'apple', text: 'Apple' },
287
- { id: 2, value: 'banana', text: 'Banana' },
288
- { id: 3, value: 'cherry', text: 'Cherry' },
289
- { id: 4, value: 'date', text: 'Date' },
290
- { id: 5, value: 'elderberry', text: 'Elderberry' }
291
- ];
292
-
293
- let open = $state(false);
294
- // Filter items based on search query
295
- const dd = filter(
296
- () => data,
297
- (query, item) => item.text.toLowerCase().includes(query.toLowerCase())
298
- );
299
- </script>
300
-
301
- <Root class="items-center justify-center p-4">
302
- <!-- Multi-select dropdown with search functionality -->
303
- <Dropdown.Root
304
- bind:open
305
- multiple
306
- keys={data.map((item) => item.value)}
307
- onquerychange={(q) => (dd.query = q)}
308
- >
309
- {#snippet children({ dropdown })}
310
- <!-- Compose Dropdown.Trigger with Input.Root for a custom trigger -->
311
- <Dropdown.Trigger
312
- base={Input.Root}
313
- class="h-auto min-h-12 max-w-sm min-w-sm items-center gap-2 rounded-sm px-4 transition-colors duration-200"
314
- onclick={(ev) => {
315
- ev.preventDefault();
316
-
317
- dropdown.state.open();
318
- }}
319
- >
320
- <!-- Display selected values with animation -->
321
- {#each dropdown?.state?.selectedItems ?? [] as item (item.id)}
322
- <div animate:flip={{ duration: 200 }}>
323
- <ADropdown.Value value={item.value} class="text-foreground/80">
324
- {item.text}
325
- </ADropdown.Value>
326
- </div>
327
- {/each}
328
-
329
- <!-- Inline search input within the trigger -->
330
- <Dropdown.Query class="flex-1 px-1" placeholder="Search for fruits..." />
331
- </Dropdown.Trigger>
332
-
333
- <!-- Dropdown list with filtered items -->
334
- <Dropdown.List>
335
- {#each dd.current as item (item.id)}
336
- <div animate:flip={{ duration: 200 }}>
337
- <Dropdown.Item value={item.value}>{item.text}</Dropdown.Item>
338
- </div>
339
- {/each}
340
- </Dropdown.List>
341
- {/snippet}
342
- </Dropdown.Root>
343
- </Root>
344
- ```
345
-
346
- **Key composition features demonstrated:**
347
-
348
- - **Component Fusion**: Using `base={Input.Root}` to compose Dropdown.Trigger with Input styling and behavior
349
- - **Snippet Patterns**: Accessing internal state through snippets for custom rendering
350
- - **Reactive Filtering**: Combining search query state with reactive effects for real-time filtering
351
- - **Smooth Animations**: Using Svelte's `flip` animation for seamless list transitions
352
- - **Multi-Select State**: Managing complex selection state through the Bond pattern
353
-
354
- ---
355
-
356
- ## 📖 Documentation
357
-
358
- ### Component Examples
359
-
360
- #### Dropdown with Multiple Selection
361
-
362
- ```svelte
363
- <script lang="ts">
364
- import { Dropdown } from '@svelte-atoms/core';
365
-
366
- let selectedValues = ['option1'];
367
- const options = [
368
- { value: 'option1', label: 'Option 1' },
369
- { value: 'option2', label: 'Option 2' },
370
- { value: 'option3', label: 'Option 3' }
371
- ];
372
- </script>
373
-
374
- <Dropdown.Root multiple bind:values={selectedValues}>
375
- <!-- Access internal bond -->
376
- {#snippet children({ dropdown })}
377
- <Dropdown.Trigger>
378
- Select options ({selectedValues.length} selected)
379
- </Dropdown.Trigger>
380
-
381
- <Dropdown.Content>
382
- {#each options as option}
383
- <Dropdown.Item value={option.value}>
384
- {option.label}
385
- </Dropdown.Item>
386
- {/each}
387
- </Dropdown.Content>
388
- {/snippet}
389
- </Dropdown.Root>
390
- ```
391
-
392
- #### Form with Validation
393
-
394
- ```svelte
395
- <script lang="ts">
396
- import { Form, Input, Button } from '@svelte-atoms/core';
397
- import { z } from 'zod';
398
-
399
- const schema = z.object({
400
- email: z.string().email('Invalid email address'),
401
- password: z.string().min(8, 'Password must be at least 8 characters')
402
- });
403
-
404
- let formData = { email: '', password: '' };
405
- let errors = {};
406
- </script>
407
-
408
- <Form {schema} bind:value={formData} bind:errors>
409
- <Field name="email">
410
- <Field.Label>Email</Field.Label>
411
- <Field.Control>
412
- <Input.Root type="email" placeholder="Enter your email" bind:value={formData.email} />
413
- </Field.Control>
414
- {#if errors.email}
415
- <Form.Error>{errors.email}</Form.Error>
416
- {/if}
417
- </.Field>
418
-
419
- <Field name="password">
420
- <Field.Label>Password</Field.Label>
421
- <Field.Control>
422
- <Input.Root
423
- type="password"
424
- placeholder="Enter your password"
425
- bind:value={formData.password}
426
- />
427
- </Field.Control>
428
- {#if errors.password}
429
- <Field.Error>{errors.password}</Field.Error>
430
- {/if}
431
- </.Field>
432
-
433
- <Button type="submit">Submit</Button>
434
- </Form>
435
- ```
436
-
437
- #### Data Grid with Sorting and Selection
438
-
439
- ```svelte
440
- <script lang="ts">
441
- import { DataGrid, Checkbox } from '@svelte-atoms/core';
442
-
443
- let data = [
444
- { id: 1, name: 'John Doe', email: 'john@example.com', role: 'Admin' },
445
- { id: 2, name: 'Jane Smith', email: 'jane@example.com', role: 'User' },
446
- { id: 3, name: 'Bob Johnson', email: 'bob@example.com', role: 'Editor' }
447
- ];
448
-
449
- let selectedRows = [];
450
- </script>
451
-
452
- <DataGrid.Root {data} bind:selectedRows multiple>
453
- <DataGrid.Header>
454
- <DataGrid.Tr>
455
- <DataGrid.Th>
456
- <Checkbox />
457
- </DataGrid.Th>
458
- <DataGrid.Th sortable="name">Name</DataGrid.Th>
459
- <DataGrid.Th sortable="email">Email</DataGrid.Th>
460
- <DataGrid.Th>Role</DataGrid.Th>
461
- </DataGrid.Tr>
462
- </DataGrid.Header>
463
-
464
- <DataGrid.Body>
465
- {#each data as row}
466
- <DataGrid.Tr value={row.id}>
467
- <DataGrid.Td>
468
- <Checkbox.Root value={row.id} />
469
- </DataGrid.Td>
470
- <DataGrid.Td>{row.name}</DataGrid.Td>
471
- <DataGrid.Td>{row.email}</DataGrid.Td>
472
- <DataGrid.Td>{row.role}</DataGrid.Td>
473
- </DataGrid.Tr>
474
- {/each}
475
- </DataGrid.Body>
476
- </DataGrid.Root>
477
- ```
478
-
479
- ---
480
-
481
- ## 🎨 Styling
482
-
483
- @svelte-atoms/core is completely headless, giving you full control over styling. Here are some approaches:
484
-
485
- ### Using Vanilla CSS
486
-
487
- ```css
488
- /* Default button styles */
489
- .btn {
490
- @apply rounded-md px-4 py-2 font-medium transition-colors;
491
- }
492
-
493
- .btn-primary {
494
- @apply bg-blue-600 text-white hover:bg-blue-700;
495
- }
496
-
497
- .btn-secondary {
498
- @apply bg-gray-200 text-gray-900 hover:bg-gray-300;
499
- }
500
- ```
501
-
502
- ### Using Tailwind CSS
503
-
504
- ```svelte
505
- <Button class="rounded-md bg-blue-600 px-4 py-2 text-white hover:bg-blue-700">Styled Button</Button>
506
- ```
507
-
508
- ---
509
-
510
- ## 🧪 Development
511
-
512
- ### Setup
513
-
514
- 1. **Clone the repository:**
515
-
516
- ```bash
517
- git clone https://github.com/ryu-man/svelte-atoms.git
518
- cd svelte-atoms
519
- ```
520
-
521
- 2. **Install dependencies:**
522
-
523
- ```bash
524
- bun install
525
- ```
526
-
527
- 3. **Start development server:**
528
-
529
- ```bash
530
- bun dev
531
- ```
532
-
533
- 4. **Run Storybook:**
534
- ```bash
535
- bun run storybook:dev
536
- ```
537
-
538
- ### Building
539
-
540
- ```bash
541
- # Build library
542
- bun run build
543
-
544
- # Build Storybook
545
- bun run storybook:build
546
- ```
547
-
548
- ---
549
-
550
- <!-- ## 🤝 Contributing
551
-
552
- We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details. -->
553
-
554
- <!-- ### Development Workflow
555
-
556
- 1. Fork the repository
557
- 2. Create a feature branch: `git checkout -b feature/amazing-feature`
558
- 3. Make your changes and add tests
559
- 4. Run the test suite: `bun test`
560
- 5. Commit your changes: `git commit -m 'Add amazing feature'`
561
- 6. Push to the branch: `git push origin feature/amazing-feature`
562
- 7. Open a Pull Request -->
563
-
564
- ### Creating New Components
565
-
566
- When adding new components, follow these guidelines:
567
-
568
- 1. **Create the bond structure:**
569
-
570
- ```
571
- src/lib/atoms/my-component/
572
- ├── bond.svelte.ts # Core bond logic (Bond + BondState classes)
573
- ├── index.ts # Public exports
574
- ├── atoms.ts # Component exports
575
- ├── my-component-root.svelte # Use namespace pattern when building complex component
576
- ├── my-component-content.svelte
577
- └── README.md # Component documentation
578
- ```
579
-
580
- 2. **Implement accessibility features:**
581
- - ARIA attributes
582
- - Keyboard navigation
583
- - Focus management
584
- - Screen reader support
585
-
586
- 3. **Add comprehensive tests:**
587
- - Unit tests for bond logic
588
- - Component integration tests
589
- - Accessibility tests
590
-
591
- 4. **Create Storybook stories:**
592
- - Basic usage examples
593
- - Advanced configurations
594
- - Interactive demos
595
-
596
- ---
597
-
598
- ## 📚 Resources
599
-
600
- - **[Documentation](https://svelte-atoms.dev)** - Comprehensive documentation
601
- - **[Storybook](https://storybook.svelte-atoms.dev/)** - Interactive component documentation
602
- - **[GitHub](https://github.com/ryu-man/svelte-atoms)** - Source code and issues
603
- - **[@svelte-atoms/alchemist](../alchimist)** - Data visualization companion library
604
-
605
- ---
606
-
607
- ## 🗺️ Roadmap
608
-
609
- ### v1.0.0 (Current - Alpha)
610
-
611
- - ✅ Bond architecture with Svelte 5 runes
612
- - ✅ 35+ essential components
613
- - ✅ TypeScript support
614
- - ✅ Accessibility features
615
- - ✅ Storybook documentation
616
- - ✅ Standardized context pattern
617
-
618
- ---
619
-
620
- ## 📄 License
621
-
622
- MIT License - see the [LICENSE](LICENSE) file for details.
623
-
624
- ---
625
-
626
- ## 🙏 Acknowledgements
627
-
628
- - [Svelte](https://svelte.dev/) - The amazing framework that powers this library
629
- - [Motion](https://motion.dev/) - For handling internal default animations
630
- - [Floating UI](https://floating-ui.com/) - For advanced positioning logic
631
- - [Tailwind CSS](https://tailwindcss.com/) - For styling
632
- - [Storybook](https://storybook.js.org/) - For component documentation and testing
633
- - [Vitest](https://vitest.dev/) - For fast and reliable testing
634
- - [Playwright](https://playwright.dev/) - For end-to-end testing
635
-
636
- ---
637
-
638
- <div align="center">
639
- <p>Built with ❤️ by the Svelte Atoms team</p>
640
- <!-- <p>
641
- <a href="https://github.com/ryu-man/svelte-atoms">GitHub</a> •
642
- <a href="https://svelte-atoms.dev">Documentation</a> •
643
- <a href="https://storybook.svelte-atoms.dev">Storybook</a>
644
- </p> -->
645
- </div>
1
+ # ⚛️ @svelte-atoms/core
2
+
3
+ > A modern, modular, and accessible Svelte 5 UI component library built with composability at its core.
4
+
5
+ **@svelte-atoms/core** is a comprehensive Svelte component library that provides fundamental building blocks ("atoms") for creating sophisticated, interactive design systems. Each component is designed with accessibility, type safety, and developer experience in mind. Built with Svelte 5 runes for optimal reactivity and performance.
6
+
7
+ [![npm version](https://img.shields.io/npm/v/@svelte-atoms/core.svg)](https://www.npmjs.com/package/@svelte-atoms/core)
8
+ [![license](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
9
+ [![TypeScript](https://img.shields.io/badge/TypeScript-Ready-blue.svg)](https://www.typescriptlang.org/)
10
+
11
+ ---
12
+
13
+ ## ✨ Features
14
+
15
+ ### 🧱 **Bond Architecture**
16
+
17
+ Built around the concept of "Bonds" - self-contained, reusable state management classes that encapsulate component state and DOM interactions. Each component uses the Bond pattern for consistent, predictable behavior across complex interactions. Simple components like Button don't require the Bond pattern as they have minimal state management needs.
18
+
19
+ ### 🔗 **Context-Driven Communication**
20
+
21
+ Components seamlessly communicate through Svelte's context API using standardized static methods (`Bond.get()` / `Bond.set()`) of the Bond class, enabling powerful parent-child relationships without prop drilling.
22
+
23
+ ### ♿ **Accessibility First**
24
+
25
+ Every component includes proper ARIA attributes, keyboard navigation, and focus management out of the box.
26
+
27
+ ### 🔧 **Highly Extensible**
28
+
29
+ Easily extend components with custom behaviors, animations, and styling while maintaining the core functionality.
30
+
31
+ ### 🎯 **Type Safety**
32
+
33
+ Fully written in TypeScript with comprehensive type definitions for a robust development experience.
34
+
35
+ ### ⚡ **Reactive by Design**
36
+
37
+ Leverages Svelte's fine-grained reactivity system for optimal performance and smooth user interactions.
38
+
39
+ ### 🎨 **Headless & Stylable**
40
+
41
+ Components are headless by default, giving you complete control over styling while providing sensible defaults.
42
+
43
+ ### 🧩 **Composable**
44
+
45
+ Build complex UIs by combining simple, reusable components. Each component is designed to work seamlessly with others through the Bond pattern and context API. Create sophisticated features like multi-level dropdowns, nested accordions, or custom form controls by composing atomic components together.
46
+
47
+ ---
48
+
49
+ ## 📦 Available Components
50
+
51
+ Our comprehensive collection of UI components with implementation status:
52
+
53
+ ### Layout & Navigation
54
+
55
+ | Component | Description | Status |
56
+ | ----------------------------------------------- | ---------------------------- | ------ |
57
+ | [**Accordion**](docs/components/accordion.md) | Collapsible content sections | ✅ |
58
+ | [**Breadcrumb**](docs/components/breadcrumb.md) | Navigation hierarchy | ✅ |
59
+ | [**Sidebar**](docs/components/sidebar.md) | Collapsible side navigation | ✅ |
60
+ | [**Tabs**](docs/components/tabs.md) | Tabbed interfaces | ✅ |
61
+ | [**Tree**](docs/components/tree.md) | Hierarchical data structures | ✅ |
62
+ | **Stepper** | Multi-step process indicator | ❌ |
63
+ | **Pagination** | Page navigation controls | ❌ |
64
+
65
+ ### Forms & Input
66
+
67
+ | Component | Description | Status |
68
+ | ------------------------------------------- | ------------------------------------ | ------ |
69
+ | [**Button**](docs/components/button.md) | Interactive buttons with variants | ✅ |
70
+ | [**Checkbox**](docs/components/checkbox.md) | Multi-select inputs | ✅ |
71
+ | [**Combobox**](docs/components/combobox.md) | Searchable select inputs | ✅ |
72
+ | [**Input**](docs/components/input.md) | Text input fields | ✅ |
73
+ | [**Radio**](docs/components/radio.md) | Single-select inputs | ✅ |
74
+ | **Slider** | Range input controls | ❌ |
75
+ | **Switch** | Toggle controls | ❌ |
76
+ | [**Textarea**](docs/components/textarea.md) | Multi-line text inputs | ✅ |
77
+ | [**Form**](docs/components/form.md) | Form validation and state management | ✅ |
78
+ | **DatePicker** | Date selection component | ❌ |
79
+ | **TimePicker** | Time selection component | ❌ |
80
+ | **FileUpload** | File upload component | ❌ |
81
+ | **ColorPicker** | Color selection component | ❌ |
82
+ | **Rating** | Star rating component | ❌ |
83
+
84
+ ### Data Display
85
+
86
+ | Component | Description | Status |
87
+ | ------------------------------------------- | --------------------------- | ------ |
88
+ | [**Avatar**](docs/components/avatar.md) | User profile images | ✅ |
89
+ | [**Badge**](docs/components/badge.md) | Status indicators | ✅ |
90
+ | [**DataGrid**](docs/components/datagrid.md) | Advanced data tables | ✅ |
91
+ | [**Divider**](docs/components/divider.md) | Content separators | ✅ |
92
+ | [**Icon**](docs/components/icon.md) | Scalable icons | ✅ |
93
+ | [**Label**](docs/components/label.md) | Form labels | ✅ |
94
+ | [**Link**](docs/components/link.md) | Navigation links | ✅ |
95
+ | [**List**](docs/components/list.md) | Structured lists | ✅ |
96
+ | [**Card**](docs/components/card.md) | Content containers | ✅ |
97
+ | **Table** | Simple data tables | ❌ |
98
+ | **Chip** | Compact information display | ❌ |
99
+ | **Progress** | Progress indicators | ❌ |
100
+ | **Skeleton** | Loading placeholders | ❌ |
101
+ | **Timeline** | Event timeline display | ❌ |
102
+ | **Calendar** | Date display component | ❌ |
103
+
104
+ ### Overlays & Feedback
105
+
106
+ | Component | Description | Status |
107
+ | ------------------------------------------------- | ------------------------ | ------ |
108
+ | [**Dialog**](docs/components/dialog.md) | Modal dialogs | ✅ |
109
+ | [**Dropdown**](docs/components/dropdown.md) | Contextual menus | ✅ |
110
+ | [**Popover**](docs/components/popover.md) | Contextual information | ✅ |
111
+ | [**Toast**](docs/components/toast.md) | Notification messages | ✅ |
112
+ | [**Tooltip**](docs/components/tooltip.md) | Contextual hints | ✅ |
113
+ | [**ContextMenu**](docs/components/contextmenu.md) | Right-click menus | ✅ |
114
+ | [**Drawer**](docs/components/drawer.md) | Slide-out panels | ✅ |
115
+ | [**Alert**](docs/components/alert.md) | Alert messages | ✅ |
116
+ | **Banner** | Full-width notifications | ❌ |
117
+ | **Spotlight** | Feature highlighting | ❌ |
118
+
119
+ ### Utilities & Layout
120
+
121
+ | Component | Description | Status |
122
+ | ------------------------------------------------- | ----------------------------------- | ------ |
123
+ | [**Portal**](docs/components/portal.md) | Declare a portal anywhere in DOM | ✅ |
124
+ | **Teleport** | Render content in a specific portal | ✅ |
125
+ | **Root** | Application root container | ✅ |
126
+ | [**Layer**](docs/components/layer.md) | Layer management utility | ✅ |
127
+ | [**Collapsible**](docs/components/collapsible.md) | Generic collapsible wrapper | ✅ |
128
+ | **Container** | Layout container | ✅ |
129
+ | [**Scrollable**](docs/components/scrollable.md) | Custom scrollbar component | ✅ |
130
+ | [**Stack**](docs/components/stack.md) | Flexible layout stacking component | ✅ |
131
+ | **Spacer** | Space management utility | ❌ |
132
+ | **VirtualList** | Virtual scrolling list | ❌ |
133
+
134
+ ---
135
+
136
+ ## 🏗️ Architecture
137
+
138
+ The library is organized into distinct layers for maximum maintainability and extensibility:
139
+
140
+ ```
141
+ src/lib/
142
+ ├── components/ # 30+ Core UI components
143
+ ├── shared/ # Base classes (Bond, BondState) and utilities
144
+ ├── helpers/ # Helper functions and components
145
+ ├── attachments/ # DOM attachment utilities
146
+ ├── runes/ # Reactive utilities (Svelte 5 runes)
147
+ ├── types/ # TypeScript type definitions
148
+ └── utils/ # General utility functions
149
+ ```
150
+
151
+ ### Bond Pattern
152
+
153
+ Each component follows a consistent Bond pattern:
154
+
155
+ - **Bond Class**: Manages component state and DOM interactions
156
+ - **BondState Class**: Holds reactive component state using Svelte 5 runes
157
+ - **Context Methods**: Static `CONTEXT_KEY`, `get()`, and `set()` methods for component communication
158
+ - **Component Files**: Svelte components that use the Bond for behavior
159
+
160
+ ```typescript
161
+ class MyComponentBond extends Bond<MyComponentBondState> {
162
+ static CONTEXT_KEY = '@atoms/context/my-component';
163
+
164
+ static get(): MyComponentBond | undefined {
165
+ return getContext(MyComponentBond.CONTEXT_KEY);
166
+ }
167
+
168
+ static set(bond: MyComponentBond): MyComponentBond {
169
+ return setContext(MyComponentBond.CONTEXT_KEY, bond);
170
+ }
171
+ }
172
+ ```
173
+
174
+ ---
175
+
176
+ ## 🚀 Quick Start
177
+
178
+ ### Installation
179
+
180
+ ```bash
181
+ # npm
182
+ npm install @svelte-atoms/core
183
+
184
+ # yarn
185
+ yarn install @svelte-atoms/core
186
+
187
+ # pnpm
188
+ pnpm add @svelte-atoms/core
189
+
190
+ # bun
191
+ bun add @svelte-atoms/core
192
+ ```
193
+
194
+ ### Basic Usage
195
+
196
+ ```svelte
197
+ <script lang="ts">
198
+ import { Button, Dialog, Input } from '@svelte-atoms/core';
199
+
200
+ let dialogOpen = $state(false);
201
+ let inputValue = '';
202
+ </script>
203
+
204
+ <!-- Simple Button -->
205
+ <Button onclick={() => (dialogOpen = true)}>Open Dialog</Button>
206
+
207
+ <!-- Dialog with Input -->
208
+ <Dialog.Root bind:open={dialogOpen}>
209
+ <Dialog.Content>
210
+ <Dialog.Header>
211
+ <Dialog.Title>Enter your name</Dialog.Title>
212
+ </Dialog.Header>
213
+ <Dialog.Body>
214
+ <Input.Root>
215
+ <Input.Value bind:value={inputValue} placeholder="Your name...">
216
+ </Input.Root>
217
+ </Dialog.Body>
218
+ <Dialog.Footer>
219
+ <Button.Root onclick={() => (dialogOpen = false)}>Cancel</Button.Root>
220
+ <Button.Root variant="primary" onclick={() => (dialogOpen = false)}>Confirm</Button.Root>
221
+ </Dialog.Footer>
222
+ </Dialog.Content>
223
+ </Dialog.Root>
224
+ ```
225
+
226
+ ### Advanced Usage with Bonds
227
+
228
+ For more control, you can use the Bond system directly:
229
+
230
+ ```svelte
231
+ <script lang="ts">
232
+ import { DialogBond, DialogBondState } from '@svelte-atoms/core/dialog';
233
+
234
+ const { open = false, disable = false } = $props();
235
+
236
+ const bondProps = defineState(
237
+ [
238
+ defineProperty(
239
+ 'open',
240
+ () => open,
241
+ (v) => (open = v)
242
+ ),
243
+ defineProperty('disable', () => disable)
244
+ ],
245
+ {
246
+ // Other props
247
+ }
248
+ );
249
+
250
+ // Create dialog state
251
+ const dialogState = new DialogBondState(() => bondProps);
252
+
253
+ // Create dialog bond
254
+ // Make available via context
255
+ const dialogBond = new DialogBond(dialogState).share();
256
+ </script>
257
+
258
+ <div {...dialogBond.root()}>
259
+ <button {...dialogBond.trigger()} onclick={() => dialogBond.state.toggle()}>
260
+ Toggle Dialog
261
+ </button>
262
+
263
+ {#if open}
264
+ <div {...dialogBond.overlay()}>
265
+ <div {...dialogBond.content()}>
266
+ <h2 {...dialogBond.title()}>Dialog Title</h2>
267
+ <p>Dialog content goes here...</p>
268
+ <button onclick={() => dialogBond.state.close()}>Close</button>
269
+ </div>
270
+ </div>
271
+ {/if}
272
+ </div>
273
+ ```
274
+
275
+ ### Advanced Usage With Composition
276
+
277
+ This example demonstrates the power of component composition by combining `Dropdown`, `Input`, and animation capabilities to create a searchable multi-select dropdown with smooth transitions:
278
+
279
+ ```svelte
280
+ <script lang="ts">
281
+ import { Dropdown, Input, Root, filter } from '@svelte-atoms/core';
282
+ import { flip } from 'svelte/animate';
283
+
284
+ // Sample data
285
+ let data = [
286
+ { id: 1, value: 'apple', text: 'Apple' },
287
+ { id: 2, value: 'banana', text: 'Banana' },
288
+ { id: 3, value: 'cherry', text: 'Cherry' },
289
+ { id: 4, value: 'date', text: 'Date' },
290
+ { id: 5, value: 'elderberry', text: 'Elderberry' }
291
+ ];
292
+
293
+ let open = $state(false);
294
+ // Filter items based on search query
295
+ const dd = filter(
296
+ () => data,
297
+ (query, item) => item.text.toLowerCase().includes(query.toLowerCase())
298
+ );
299
+ </script>
300
+
301
+ <Root class="items-center justify-center p-4">
302
+ <!-- Multi-select dropdown with search functionality -->
303
+ <Dropdown.Root
304
+ bind:open
305
+ multiple
306
+ keys={data.map((item) => item.value)}
307
+ onquerychange={(q) => (dd.query = q)}
308
+ >
309
+ {#snippet children({ dropdown })}
310
+ <!-- Compose Dropdown.Trigger with Input.Root for a custom trigger -->
311
+ <Dropdown.Trigger
312
+ base={Input.Root}
313
+ class="h-auto min-h-12 max-w-sm min-w-sm items-center gap-2 rounded-sm px-4 transition-colors duration-200"
314
+ onclick={(ev) => {
315
+ ev.preventDefault();
316
+
317
+ dropdown.state.open();
318
+ }}
319
+ >
320
+ <!-- Display selected values with animation -->
321
+ {#each dropdown?.state?.selectedItems ?? [] as item (item.id)}
322
+ <div animate:flip={{ duration: 200 }}>
323
+ <ADropdown.Value value={item.value} class="text-foreground/80">
324
+ {item.text}
325
+ </ADropdown.Value>
326
+ </div>
327
+ {/each}
328
+
329
+ <!-- Inline search input within the trigger -->
330
+ <Dropdown.Query class="flex-1 px-1" placeholder="Search for fruits..." />
331
+ </Dropdown.Trigger>
332
+
333
+ <!-- Dropdown list with filtered items -->
334
+ <Dropdown.List>
335
+ {#each dd.current as item (item.id)}
336
+ <div animate:flip={{ duration: 200 }}>
337
+ <Dropdown.Item value={item.value}>{item.text}</Dropdown.Item>
338
+ </div>
339
+ {/each}
340
+ </Dropdown.List>
341
+ {/snippet}
342
+ </Dropdown.Root>
343
+ </Root>
344
+ ```
345
+
346
+ **Key composition features demonstrated:**
347
+
348
+ - **Component Fusion**: Using `base={Input.Root}` to compose Dropdown.Trigger with Input styling and behavior
349
+ - **Snippet Patterns**: Accessing internal state through snippets for custom rendering
350
+ - **Reactive Filtering**: Combining search query state with reactive effects for real-time filtering
351
+ - **Smooth Animations**: Using Svelte's `flip` animation for seamless list transitions
352
+ - **Multi-Select State**: Managing complex selection state through the Bond pattern
353
+
354
+ ---
355
+
356
+ ## 📖 Documentation
357
+
358
+ ### Component Examples
359
+
360
+ #### Dropdown with Multiple Selection
361
+
362
+ ```svelte
363
+ <script lang="ts">
364
+ import { Dropdown } from '@svelte-atoms/core';
365
+
366
+ let selectedValues = ['option1'];
367
+ const options = [
368
+ { value: 'option1', label: 'Option 1' },
369
+ { value: 'option2', label: 'Option 2' },
370
+ { value: 'option3', label: 'Option 3' }
371
+ ];
372
+ </script>
373
+
374
+ <Dropdown.Root multiple bind:values={selectedValues}>
375
+ <!-- Access internal bond -->
376
+ {#snippet children({ dropdown })}
377
+ <Dropdown.Trigger>
378
+ Select options ({selectedValues.length} selected)
379
+ </Dropdown.Trigger>
380
+
381
+ <Dropdown.Content>
382
+ {#each options as option}
383
+ <Dropdown.Item value={option.value}>
384
+ {option.label}
385
+ </Dropdown.Item>
386
+ {/each}
387
+ </Dropdown.Content>
388
+ {/snippet}
389
+ </Dropdown.Root>
390
+ ```
391
+
392
+ #### Form with Validation
393
+
394
+ ```svelte
395
+ <script lang="ts">
396
+ import { Form, Input, Button } from '@svelte-atoms/core';
397
+ import { z } from 'zod';
398
+
399
+ const schema = z.object({
400
+ email: z.string().email('Invalid email address'),
401
+ password: z.string().min(8, 'Password must be at least 8 characters')
402
+ });
403
+
404
+ let formData = { email: '', password: '' };
405
+ let errors = {};
406
+ </script>
407
+
408
+ <Form {schema} bind:value={formData} bind:errors>
409
+ <Field name="email">
410
+ <Field.Label>Email</Field.Label>
411
+ <Field.Control>
412
+ <Input.Root type="email" placeholder="Enter your email" bind:value={formData.email} />
413
+ </Field.Control>
414
+ {#if errors.email}
415
+ <Form.Error>{errors.email}</Form.Error>
416
+ {/if}
417
+ </.Field>
418
+
419
+ <Field name="password">
420
+ <Field.Label>Password</Field.Label>
421
+ <Field.Control>
422
+ <Input.Root
423
+ type="password"
424
+ placeholder="Enter your password"
425
+ bind:value={formData.password}
426
+ />
427
+ </Field.Control>
428
+ {#if errors.password}
429
+ <Field.Error>{errors.password}</Field.Error>
430
+ {/if}
431
+ </.Field>
432
+
433
+ <Button type="submit">Submit</Button>
434
+ </Form>
435
+ ```
436
+
437
+ #### Data Grid with Sorting and Selection
438
+
439
+ ```svelte
440
+ <script lang="ts">
441
+ import { DataGrid, Checkbox } from '@svelte-atoms/core';
442
+
443
+ let data = [
444
+ { id: 1, name: 'John Doe', email: 'john@example.com', role: 'Admin' },
445
+ { id: 2, name: 'Jane Smith', email: 'jane@example.com', role: 'User' },
446
+ { id: 3, name: 'Bob Johnson', email: 'bob@example.com', role: 'Editor' }
447
+ ];
448
+
449
+ let selectedRows = [];
450
+ </script>
451
+
452
+ <DataGrid.Root {data} bind:selectedRows multiple>
453
+ <DataGrid.Header>
454
+ <DataGrid.Tr>
455
+ <DataGrid.Th>
456
+ <Checkbox />
457
+ </DataGrid.Th>
458
+ <DataGrid.Th sortable="name">Name</DataGrid.Th>
459
+ <DataGrid.Th sortable="email">Email</DataGrid.Th>
460
+ <DataGrid.Th>Role</DataGrid.Th>
461
+ </DataGrid.Tr>
462
+ </DataGrid.Header>
463
+
464
+ <DataGrid.Body>
465
+ {#each data as row}
466
+ <DataGrid.Tr value={row.id}>
467
+ <DataGrid.Td>
468
+ <Checkbox.Root value={row.id} />
469
+ </DataGrid.Td>
470
+ <DataGrid.Td>{row.name}</DataGrid.Td>
471
+ <DataGrid.Td>{row.email}</DataGrid.Td>
472
+ <DataGrid.Td>{row.role}</DataGrid.Td>
473
+ </DataGrid.Tr>
474
+ {/each}
475
+ </DataGrid.Body>
476
+ </DataGrid.Root>
477
+ ```
478
+
479
+ ---
480
+
481
+ ## 🎨 Styling
482
+
483
+ @svelte-atoms/core is completely headless, giving you full control over styling. Here are some approaches:
484
+
485
+ ### Using Vanilla CSS
486
+
487
+ ```css
488
+ /* Default button styles */
489
+ .btn {
490
+ @apply rounded-md px-4 py-2 font-medium transition-colors;
491
+ }
492
+
493
+ .btn-primary {
494
+ @apply bg-blue-600 text-white hover:bg-blue-700;
495
+ }
496
+
497
+ .btn-secondary {
498
+ @apply bg-gray-200 text-gray-900 hover:bg-gray-300;
499
+ }
500
+ ```
501
+
502
+ ### Using Tailwind CSS
503
+
504
+ ```svelte
505
+ <Button class="rounded-md bg-blue-600 px-4 py-2 text-white hover:bg-blue-700">Styled Button</Button>
506
+ ```
507
+
508
+ ---
509
+
510
+ ## 🧪 Development
511
+
512
+ ### Setup
513
+
514
+ 1. **Clone the repository:**
515
+
516
+ ```bash
517
+ git clone https://github.com/ryu-man/svelte-atoms.git
518
+ cd svelte-atoms
519
+ ```
520
+
521
+ 2. **Install dependencies:**
522
+
523
+ ```bash
524
+ bun install
525
+ ```
526
+
527
+ 3. **Start development server:**
528
+
529
+ ```bash
530
+ bun dev
531
+ ```
532
+
533
+ 4. **Run Storybook:**
534
+ ```bash
535
+ bun run storybook:dev
536
+ ```
537
+
538
+ ### Building
539
+
540
+ ```bash
541
+ # Build library
542
+ bun run build
543
+
544
+ # Build Storybook
545
+ bun run storybook:build
546
+ ```
547
+
548
+ ---
549
+
550
+ <!-- ## 🤝 Contributing
551
+
552
+ We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details. -->
553
+
554
+ <!-- ### Development Workflow
555
+
556
+ 1. Fork the repository
557
+ 2. Create a feature branch: `git checkout -b feature/amazing-feature`
558
+ 3. Make your changes and add tests
559
+ 4. Run the test suite: `bun test`
560
+ 5. Commit your changes: `git commit -m 'Add amazing feature'`
561
+ 6. Push to the branch: `git push origin feature/amazing-feature`
562
+ 7. Open a Pull Request -->
563
+
564
+ ### Creating New Components
565
+
566
+ When adding new components, follow these guidelines:
567
+
568
+ 1. **Create the bond structure:**
569
+
570
+ ```
571
+ src/lib/atoms/my-component/
572
+ ├── bond.svelte.ts # Core bond logic (Bond + BondState classes)
573
+ ├── index.ts # Public exports
574
+ ├── atoms.ts # Component exports
575
+ ├── my-component-root.svelte # Use namespace pattern when building complex component
576
+ ├── my-component-content.svelte
577
+ └── README.md # Component documentation
578
+ ```
579
+
580
+ 2. **Implement accessibility features:**
581
+ - ARIA attributes
582
+ - Keyboard navigation
583
+ - Focus management
584
+ - Screen reader support
585
+
586
+ 3. **Add comprehensive tests:**
587
+ - Unit tests for bond logic
588
+ - Component integration tests
589
+ - Accessibility tests
590
+
591
+ 4. **Create Storybook stories:**
592
+ - Basic usage examples
593
+ - Advanced configurations
594
+ - Interactive demos
595
+
596
+ ---
597
+
598
+ ## 📚 Resources
599
+
600
+ - **[Documentation](https://svelte-atoms.dev)** - Comprehensive documentation
601
+ - **[Storybook](https://storybook.svelte-atoms.dev/)** - Interactive component documentation
602
+ - **[GitHub](https://github.com/ryu-man/svelte-atoms)** - Source code and issues
603
+ - **[@svelte-atoms/alchemist](../alchimist)** - Data visualization companion library
604
+
605
+ ---
606
+
607
+ ## 🗺️ Roadmap
608
+
609
+ ### v1.0.0 (Current - Alpha)
610
+
611
+ - ✅ Bond architecture with Svelte 5 runes
612
+ - ✅ 35+ essential components
613
+ - ✅ TypeScript support
614
+ - ✅ Accessibility features
615
+ - ✅ Storybook documentation
616
+ - ✅ Standardized context pattern
617
+
618
+ ---
619
+
620
+ ## 📄 License
621
+
622
+ MIT License - see the [LICENSE](LICENSE) file for details.
623
+
624
+ ---
625
+
626
+ ## 🙏 Acknowledgements
627
+
628
+ - [Svelte](https://svelte.dev/) - The amazing framework that powers this library
629
+ - [Motion](https://motion.dev/) - For handling internal default animations
630
+ - [Floating UI](https://floating-ui.com/) - For advanced positioning logic
631
+ - [Tailwind CSS](https://tailwindcss.com/) - For styling
632
+ - [Storybook](https://storybook.js.org/) - For component documentation and testing
633
+ - [Vitest](https://vitest.dev/) - For fast and reliable testing
634
+ - [Playwright](https://playwright.dev/) - For end-to-end testing
635
+
636
+ ---
637
+
638
+ <div align="center">
639
+ <p>Built with ❤️ by the Svelte Atoms team</p>
640
+ <!-- <p>
641
+ <a href="https://github.com/ryu-man/svelte-atoms">GitHub</a> •
642
+ <a href="https://svelte-atoms.dev">Documentation</a> •
643
+ <a href="https://storybook.svelte-atoms.dev">Storybook</a>
644
+ </p> -->
645
+ </div>