@flightlesslabs/dodo-ui 0.22.1 → 0.23.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.
- package/README.md +1 -9
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -0
- package/package.json +25 -35
- package/src/lib/index.ts +5 -0
- package/src/lib/utils/time/date-creator/createDate/createDate.test.ts +109 -0
- package/src/lib/utils/time/date-creator/createDateFactory/createDateFactory.test.ts +146 -0
- package/dist/Home.mdx +0 -69
- package/dist/components/Form/Button/Button.stories.svelte +0 -178
- package/dist/components/Form/Button/Button.stories.svelte.d.ts +0 -22
- package/dist/components/Form/Checkbox/Checkbox.stories.svelte +0 -132
- package/dist/components/Form/Checkbox/Checkbox.stories.svelte.d.ts +0 -25
- package/dist/components/Form/DatePicker/DatePicker.stories.svelte +0 -139
- package/dist/components/Form/DatePicker/DatePicker.stories.svelte.d.ts +0 -22
- package/dist/components/Form/FormField/FormField.stories.svelte +0 -48
- package/dist/components/Form/FormField/FormField.stories.svelte.d.ts +0 -25
- package/dist/components/Form/InputEnclosure/InputEnclosure.stories.svelte +0 -166
- package/dist/components/Form/InputEnclosure/InputEnclosure.stories.svelte.d.ts +0 -22
- package/dist/components/Form/Label/Label.stories.svelte +0 -31
- package/dist/components/Form/Label/Label.stories.svelte.d.ts +0 -25
- package/dist/components/Form/RadioGroup/Radio/Radio.stories.svelte +0 -78
- package/dist/components/Form/RadioGroup/Radio/Radio.stories.svelte.d.ts +0 -25
- package/dist/components/Form/RadioGroup/RadioGroup.stories.svelte +0 -172
- package/dist/components/Form/RadioGroup/RadioGroup.stories.svelte.d.ts +0 -25
- package/dist/components/Form/Select/Select.stories.svelte +0 -175
- package/dist/components/Form/Select/Select.stories.svelte.d.ts +0 -22
- package/dist/components/Form/Switch/Switch.stories.svelte +0 -128
- package/dist/components/Form/Switch/Switch.stories.svelte.d.ts +0 -25
- package/dist/components/Form/TextInput/TextInput.stories.svelte +0 -162
- package/dist/components/Form/TextInput/TextInput.stories.svelte.d.ts +0 -22
- package/dist/components/Form/UtilityButton/UtilityButton.stories.svelte +0 -163
- package/dist/components/Form/UtilityButton/UtilityButton.stories.svelte.d.ts +0 -22
- package/dist/components/Info/Calendar/Calendar.stories.svelte +0 -134
- package/dist/components/Info/Calendar/Calendar.stories.svelte.d.ts +0 -22
- package/dist/components/Layout/Card/Card.stories.svelte +0 -113
- package/dist/components/Layout/Card/Card.stories.svelte.d.ts +0 -22
- package/dist/components/Layout/Grid/Column/Column.stories.svelte +0 -66
- package/dist/components/Layout/Grid/Column/Column.stories.svelte.d.ts +0 -22
- package/dist/components/Layout/Grid/Grid.stories.svelte +0 -192
- package/dist/components/Layout/Grid/Grid.stories.svelte.d.ts +0 -22
- package/dist/components/Layout/Grid/Row/Row.stories.svelte +0 -39
- package/dist/components/Layout/Grid/Row/Row.stories.svelte.d.ts +0 -22
- package/dist/components/Layout/Theme/Theme.stories.svelte +0 -54
- package/dist/components/Layout/Theme/Theme.stories.svelte.d.ts +0 -25
- package/dist/components/Layout/Theme/ThemeSystem/index.mdx +0 -35
- package/dist/storybook-types.d.ts +0 -129
- package/dist/storybook-types.js +0 -1
- package/dist/utils/time/date-creator/createDate/createDate.mdx +0 -98
- package/dist/utils/time/date-creator/createDateFactory/createDateFactory.mdx +0 -104
- package/dist/utils/time/timeout/timeout.mdx +0 -114
- package/src/lib/Home.mdx +0 -69
- package/src/lib/components/Form/Button/Button.stories.svelte +0 -178
- package/src/lib/components/Form/Checkbox/Checkbox.stories.svelte +0 -132
- package/src/lib/components/Form/DatePicker/DatePicker.stories.svelte +0 -139
- package/src/lib/components/Form/FormField/FormField.stories.svelte +0 -48
- package/src/lib/components/Form/InputEnclosure/InputEnclosure.stories.svelte +0 -166
- package/src/lib/components/Form/Label/Label.stories.svelte +0 -31
- package/src/lib/components/Form/RadioGroup/Radio/Radio.stories.svelte +0 -78
- package/src/lib/components/Form/RadioGroup/RadioGroup.stories.svelte +0 -172
- package/src/lib/components/Form/Select/Select.stories.svelte +0 -175
- package/src/lib/components/Form/Switch/Switch.stories.svelte +0 -128
- package/src/lib/components/Form/TextInput/TextInput.stories.svelte +0 -162
- package/src/lib/components/Form/UtilityButton/UtilityButton.stories.svelte +0 -163
- package/src/lib/components/Info/Calendar/Calendar.stories.svelte +0 -134
- package/src/lib/components/Layout/Card/Card.stories.svelte +0 -113
- package/src/lib/components/Layout/Grid/Column/Column.stories.svelte +0 -66
- package/src/lib/components/Layout/Grid/Grid.stories.svelte +0 -192
- package/src/lib/components/Layout/Grid/Row/Row.stories.svelte +0 -39
- package/src/lib/components/Layout/Theme/Theme.stories.svelte +0 -54
- package/src/lib/components/Layout/Theme/ThemeSystem/index.mdx +0 -35
- package/src/lib/storybook-types.ts +0 -182
- package/src/lib/utils/time/date-creator/createDate/createDate.mdx +0 -98
- package/src/lib/utils/time/date-creator/createDateFactory/createDateFactory.mdx +0 -104
- package/src/lib/utils/time/timeout/timeout.mdx +0 -114
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
# createDate
|
|
2
|
-
|
|
3
|
-
A centralized date factory built on top of `dayjs`.
|
|
4
|
-
|
|
5
|
-
This utility ensures **consistent parsing, timezone handling, and validation** across your application.
|
|
6
|
-
|
|
7
|
-
## 📦 Import
|
|
8
|
-
|
|
9
|
-
```ts
|
|
10
|
-
import { createDate } from '@flightlesslabs/dodo-ui';
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
## 🚀 Basic Usage
|
|
14
|
-
|
|
15
|
-
### Current Date
|
|
16
|
-
|
|
17
|
-
```ts
|
|
18
|
-
const now = createDate();
|
|
19
|
-
console.log(now.format());
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
### Parse a Date
|
|
24
|
-
|
|
25
|
-
```ts
|
|
26
|
-
const date = createDate("01-02-2025", "DD-MM-YYYY");
|
|
27
|
-
console.log(date.format());
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
## 🌍 Timezone & UTC
|
|
31
|
-
|
|
32
|
-
### UTC Mode
|
|
33
|
-
|
|
34
|
-
```ts
|
|
35
|
-
const utcDate = createDate("2025-01-01T12:00:00Z", undefined, {
|
|
36
|
-
utc: true,
|
|
37
|
-
});
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
### Timezone Conversion
|
|
41
|
-
|
|
42
|
-
```ts
|
|
43
|
-
const indiaTime = createDate("01-01-2025", "DD-MM-YYYY", {
|
|
44
|
-
timezone: "Asia/Kolkata",
|
|
45
|
-
});
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
## ⚙️ Options
|
|
49
|
-
|
|
50
|
-
```ts
|
|
51
|
-
interface CreateDateOptions {
|
|
52
|
-
timezone?: string;
|
|
53
|
-
utc?: boolean;
|
|
54
|
-
strict?: boolean;
|
|
55
|
-
throwOnInvalid?: boolean;
|
|
56
|
-
}
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
## 🔁 Behavior Priority
|
|
60
|
-
|
|
61
|
-
1. utc (highest priority)
|
|
62
|
-
2. timezone
|
|
63
|
-
3. local
|
|
64
|
-
|
|
65
|
-
---
|
|
66
|
-
|
|
67
|
-
### timezone
|
|
68
|
-
|
|
69
|
-
- IANA timezone string
|
|
70
|
-
- Interprets input in given timezone
|
|
71
|
-
|
|
72
|
-
---
|
|
73
|
-
|
|
74
|
-
### utc
|
|
75
|
-
|
|
76
|
-
- Forces UTC mode
|
|
77
|
-
|
|
78
|
-
---
|
|
79
|
-
|
|
80
|
-
### strict
|
|
81
|
-
|
|
82
|
-
- Only applies when format is provided
|
|
83
|
-
- Has no effect on ISO / timestamps
|
|
84
|
-
|
|
85
|
-
---
|
|
86
|
-
|
|
87
|
-
### throwOnInvalid
|
|
88
|
-
|
|
89
|
-
- Throws error if date is invalid
|
|
90
|
-
|
|
91
|
-
---
|
|
92
|
-
|
|
93
|
-
## 📥 Supported Inputs
|
|
94
|
-
|
|
95
|
-
- string
|
|
96
|
-
- number (timestamp)
|
|
97
|
-
- Date object
|
|
98
|
-
- undefined
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
# createDateFactory
|
|
2
|
-
|
|
3
|
-
A **factory function** that creates a `createDate` utility with an optional custom `dayjs` instance.
|
|
4
|
-
|
|
5
|
-
This allows advanced users to:
|
|
6
|
-
|
|
7
|
-
- Inject their own configured `dayjs`
|
|
8
|
-
- Share plugins across multiple libraries
|
|
9
|
-
- Avoid global `dayjs.extend` pollution
|
|
10
|
-
- Create isolated date environments
|
|
11
|
-
|
|
12
|
-
---
|
|
13
|
-
|
|
14
|
-
## 📦 Import
|
|
15
|
-
|
|
16
|
-
```ts
|
|
17
|
-
import { createDateFactory } from '@flightlesslabs/dodo-ui';
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
---
|
|
21
|
-
|
|
22
|
-
## 🚀 Basic Usage
|
|
23
|
-
|
|
24
|
-
### Default Factory
|
|
25
|
-
|
|
26
|
-
```ts
|
|
27
|
-
import { createDateFactory } from '@flightlesslabs/dodo-ui';
|
|
28
|
-
|
|
29
|
-
const { createDate } = createDateFactory();
|
|
30
|
-
|
|
31
|
-
const now = createDate();
|
|
32
|
-
console.log(now.format());
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
---
|
|
36
|
-
|
|
37
|
-
## 🧠 Why Use a Factory?
|
|
38
|
-
|
|
39
|
-
Instead of relying on global `dayjs.extend`, you can:
|
|
40
|
-
|
|
41
|
-
- isolate plugin setups
|
|
42
|
-
- avoid conflicts in monorepos
|
|
43
|
-
- support multiple configurations
|
|
44
|
-
- improve testability
|
|
45
|
-
|
|
46
|
-
---
|
|
47
|
-
|
|
48
|
-
## 🔌 Custom Dayjs Instance
|
|
49
|
-
|
|
50
|
-
### Inject your own configured instance
|
|
51
|
-
|
|
52
|
-
```ts
|
|
53
|
-
import dayjs from 'dayjs';
|
|
54
|
-
import utc from 'dayjs/plugin/utc';
|
|
55
|
-
import timezone from 'dayjs/plugin/timezone';
|
|
56
|
-
|
|
57
|
-
dayjs.extend(utc);
|
|
58
|
-
dayjs.extend(timezone);
|
|
59
|
-
|
|
60
|
-
const { createDate } = createDateFactory(dayjs);
|
|
61
|
-
|
|
62
|
-
const date = createDate("2025-01-01", "YYYY-MM-DD");
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
---
|
|
66
|
-
|
|
67
|
-
## ⚙️ Behavior
|
|
68
|
-
|
|
69
|
-
The factory wraps your `dayjs` instance and preserves:
|
|
70
|
-
|
|
71
|
-
- UTC handling
|
|
72
|
-
- Timezone support
|
|
73
|
-
- Strict parsing
|
|
74
|
-
- Validation options
|
|
75
|
-
|
|
76
|
-
---
|
|
77
|
-
|
|
78
|
-
## 🔁 Priority Order
|
|
79
|
-
|
|
80
|
-
1. utc (highest priority)
|
|
81
|
-
2. timezone
|
|
82
|
-
3. local parsing
|
|
83
|
-
|
|
84
|
-
---
|
|
85
|
-
|
|
86
|
-
## 📥 Returned API
|
|
87
|
-
|
|
88
|
-
```ts
|
|
89
|
-
{
|
|
90
|
-
createDate: Function,
|
|
91
|
-
dayjs: DayjsInstance
|
|
92
|
-
}
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
## 🧪 Example: Multiple Factories
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
```ts
|
|
99
|
-
const factoryA = createDateFactory(dayjsA);
|
|
100
|
-
const factoryB = createDateFactory(dayjsB);
|
|
101
|
-
|
|
102
|
-
factoryA.createDate("2025-01-01");
|
|
103
|
-
factoryB.createDate("2025-01-01");
|
|
104
|
-
```
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
# timeout
|
|
2
|
-
|
|
3
|
-
A simple utility to delay execution using Promises.
|
|
4
|
-
|
|
5
|
-
Useful for **pausing async workflows**, **simulating delays**, or **controlling execution timing**.
|
|
6
|
-
|
|
7
|
-
---
|
|
8
|
-
|
|
9
|
-
## 📦 Import
|
|
10
|
-
|
|
11
|
-
```ts
|
|
12
|
-
import { timeout } from '@flightlesslabs/dodo-ui';
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
---
|
|
16
|
-
|
|
17
|
-
## 🚀 Basic Usage
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
```ts
|
|
22
|
-
await timeout(1000); // waits 1 second
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
---
|
|
26
|
-
|
|
27
|
-
## 🎯 Resolve with Value
|
|
28
|
-
|
|
29
|
-
You can optionally pass a value that will be returned after the delay.
|
|
30
|
-
|
|
31
|
-
```ts
|
|
32
|
-
const result = await timeout(500, "done");
|
|
33
|
-
|
|
34
|
-
console.log(result); // "done"
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
---
|
|
38
|
-
|
|
39
|
-
## ⚙️ API
|
|
40
|
-
|
|
41
|
-
```ts
|
|
42
|
-
function timeout<T = void>(
|
|
43
|
-
milliseconds: number,
|
|
44
|
-
value?: T
|
|
45
|
-
): Promise<T>
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
---
|
|
49
|
-
|
|
50
|
-
### `milliseconds`
|
|
51
|
-
|
|
52
|
-
- Time to wait before resolving (in ms)
|
|
53
|
-
- Must be `>= 0`
|
|
54
|
-
|
|
55
|
-
---
|
|
56
|
-
|
|
57
|
-
### `value`
|
|
58
|
-
|
|
59
|
-
- Optional value to resolve with
|
|
60
|
-
- Defaults to `undefined`
|
|
61
|
-
|
|
62
|
-
---
|
|
63
|
-
|
|
64
|
-
## ⚠️ Error Handling
|
|
65
|
-
|
|
66
|
-
If a negative duration is provided, the promise will reject:
|
|
67
|
-
|
|
68
|
-
```ts
|
|
69
|
-
await timeout(-1); // ❌ throws Error
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
---
|
|
73
|
-
|
|
74
|
-
## 🧠 Use Cases
|
|
75
|
-
|
|
76
|
-
- Delay execution in async functions
|
|
77
|
-
- Simulate API latency in tests
|
|
78
|
-
- Simple throttling or pacing logic
|
|
79
|
-
|
|
80
|
-
---
|
|
81
|
-
|
|
82
|
-
## 🔍 Examples
|
|
83
|
-
|
|
84
|
-
### Async Flow
|
|
85
|
-
|
|
86
|
-
```ts
|
|
87
|
-
async function run() {
|
|
88
|
-
console.log("Start");
|
|
89
|
-
|
|
90
|
-
await timeout(1000);
|
|
91
|
-
|
|
92
|
-
console.log("End");
|
|
93
|
-
}
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
---
|
|
97
|
-
|
|
98
|
-
### With Data
|
|
99
|
-
|
|
100
|
-
<Source
|
|
101
|
-
dark
|
|
102
|
-
language="ts"
|
|
103
|
-
code={`
|
|
104
|
-
const data = await timeout(300, { success: true });
|
|
105
|
-
|
|
106
|
-
console.log(data.success); // true
|
|
107
|
-
`}
|
|
108
|
-
/>
|
|
109
|
-
|
|
110
|
-
```ts
|
|
111
|
-
const data = await timeout(300, { success: true });
|
|
112
|
-
|
|
113
|
-
console.log(data.success); // true
|
|
114
|
-
```
|
package/src/lib/Home.mdx
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import item from '../../package.json?raw';
|
|
2
|
-
|
|
3
|
-
<main style={{ textAlign: 'center' }}>
|
|
4
|
-
|
|
5
|
-
<img src="dodo-circle-6.png" style={{ width: 200, height: 'auto' }} />
|
|
6
|
-
|
|
7
|
-
# Dodo UI
|
|
8
|
-
|
|
9
|
-
<h3 style={{ fontWeight: 500 }}>v{JSON.parse(item)?.version}</h3>
|
|
10
|
-
|
|
11
|
-
<h3 style={{ fontWeight: 400 }}>
|
|
12
|
-
Opinionated UI framework for Svelte, based on [Bits UI](https://bits-ui.com/)
|
|
13
|
-
</h3>
|
|
14
|
-
|
|
15
|
-
### [Github](https://github.com/flightlesslabs/dodo-ui) - [npm](https://www.npmjs.com/package/@flightlesslabs/dodo-ui)
|
|
16
|
-
|
|
17
|
-
</main>
|
|
18
|
-
|
|
19
|
-
<br />
|
|
20
|
-
<br />
|
|
21
|
-
|
|
22
|
-
## 🚀 Installation
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
```bash
|
|
26
|
-
pnpm add bits-ui @internationalized/date @flightlesslabs/dodo-ui
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
We are using **bits-ui@{JSON.parse(item).devDependencies['bits-ui']}** internally
|
|
30
|
-
|
|
31
|
-
## 🎨 Add Styles
|
|
32
|
-
|
|
33
|
-
Import global styles in your root component. use the root layout (`+layout.svelte`) for SvelteKit.
|
|
34
|
-
|
|
35
|
-
```ts
|
|
36
|
-
import '@flightlesslabs/dodo-ui/styles/global.css';
|
|
37
|
-
import '@flightlesslabs/dodo-ui/styles/components.css';
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
## 🌗 Theme Setup
|
|
41
|
-
|
|
42
|
-
Wrap your application with the [Theme](?path=/docs/components-layout-theme--docs) component at the root level.
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
```ts
|
|
46
|
-
import { Theme } from '@flightlesslabs/dodo-ui';
|
|
47
|
-
|
|
48
|
-
<Theme global>
|
|
49
|
-
<!-- Your app -->
|
|
50
|
-
</Theme>
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
Recommended: Place this in your root layout (`+layout.svelte`) for SvelteKit.
|
|
54
|
-
|
|
55
|
-
✨ Usage
|
|
56
|
-
|
|
57
|
-
Start by importing components like [Button](?path=/docs/components-form-button--docs).
|
|
58
|
-
|
|
59
|
-
```ts
|
|
60
|
-
import { Button } '@flightlesslabs/dodo-ui';
|
|
61
|
-
|
|
62
|
-
<Button>Hello</Button>
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
## Explore more
|
|
66
|
-
|
|
67
|
-
- [Button](?path=/docs/components-form-button--docs)
|
|
68
|
-
- [TextInput](?path=/docs/components-form-textinput--docs)
|
|
69
|
-
- [Tailwind CSS Color Generator](https://uicolors.app/generate/1cc049)
|
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
<script module lang="ts">
|
|
2
|
-
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
-
import Button from './Button.svelte';
|
|
4
|
-
import type { ButtonProps } from './Button.svelte';
|
|
5
|
-
import type { ArgTypes } from 'storybook/internal/csf';
|
|
6
|
-
import { componentColorOptions } from '$lib/attributes/color.js';
|
|
7
|
-
import { componentVariantOptions } from '$lib/attributes/variant.js';
|
|
8
|
-
import { componentSizeOptions } from '$lib/attributes/size.js';
|
|
9
|
-
import { componentRoundnessOptions } from '$lib/attributes/roundness.js';
|
|
10
|
-
import Theme from '$lib/components/Layout/Theme/Theme.svelte';
|
|
11
|
-
|
|
12
|
-
const description = `
|
|
13
|
-
A flexible Button component based on bits-ui [button](https://bits-ui.com/docs/components/button).
|
|
14
|
-
\`\`\`ts
|
|
15
|
-
import { Button } from '@flightlesslabs/dodo-ui';
|
|
16
|
-
\`\`\`
|
|
17
|
-
`;
|
|
18
|
-
|
|
19
|
-
// ------------------------------
|
|
20
|
-
// Storybook ArgTypes
|
|
21
|
-
// ------------------------------
|
|
22
|
-
export const storyButtonArgTypes: Partial<ArgTypes<ButtonProps>> = {
|
|
23
|
-
// ------------------------------
|
|
24
|
-
// Core
|
|
25
|
-
// ------------------------------
|
|
26
|
-
children: { table: { category: 'API', subcategory: 'Base' } },
|
|
27
|
-
href: {
|
|
28
|
-
control: { type: 'text' },
|
|
29
|
-
description: 'Render as Anchor when provided',
|
|
30
|
-
table: { category: 'API', subcategory: 'Base' },
|
|
31
|
-
},
|
|
32
|
-
disabled: {
|
|
33
|
-
control: { type: 'boolean' },
|
|
34
|
-
description: 'Disable interactions',
|
|
35
|
-
table: { category: 'API', subcategory: 'Base' },
|
|
36
|
-
},
|
|
37
|
-
class: { table: { category: 'API', subcategory: 'Base' } },
|
|
38
|
-
type: { table: { category: 'API', subcategory: 'Base' } },
|
|
39
|
-
|
|
40
|
-
// ------------------------------
|
|
41
|
-
// Appearance
|
|
42
|
-
// ------------------------------
|
|
43
|
-
color: {
|
|
44
|
-
control: { type: 'select' },
|
|
45
|
-
options: componentColorOptions,
|
|
46
|
-
description: 'Color theme token',
|
|
47
|
-
table: { category: 'API', subcategory: 'Appearance', defaultValue: { summary: 'primary' } },
|
|
48
|
-
},
|
|
49
|
-
variant: {
|
|
50
|
-
control: { type: 'select' },
|
|
51
|
-
options: componentVariantOptions,
|
|
52
|
-
description: 'Visual variant of the button',
|
|
53
|
-
table: { category: 'API', subcategory: 'Appearance', defaultValue: { summary: 'solid' } },
|
|
54
|
-
},
|
|
55
|
-
size: {
|
|
56
|
-
control: { type: 'select' },
|
|
57
|
-
options: componentSizeOptions,
|
|
58
|
-
description: 'Visual size token',
|
|
59
|
-
table: { category: 'API', subcategory: 'Appearance', defaultValue: { summary: 'normal' } },
|
|
60
|
-
},
|
|
61
|
-
roundness: {
|
|
62
|
-
control: { type: 'select' },
|
|
63
|
-
options: componentRoundnessOptions,
|
|
64
|
-
description: 'Border radius token',
|
|
65
|
-
table: { category: 'API', subcategory: 'Appearance' },
|
|
66
|
-
},
|
|
67
|
-
fullWidth: {
|
|
68
|
-
control: { type: 'boolean' },
|
|
69
|
-
description: 'Stretch button to full container width',
|
|
70
|
-
table: { category: 'API', subcategory: 'Appearance' },
|
|
71
|
-
},
|
|
72
|
-
compact: {
|
|
73
|
-
control: { type: 'boolean' },
|
|
74
|
-
description: 'Compact spacing (icon buttons)',
|
|
75
|
-
table: { category: 'API', subcategory: 'Appearance' },
|
|
76
|
-
},
|
|
77
|
-
outline: {
|
|
78
|
-
control: { type: 'boolean' },
|
|
79
|
-
description: 'Render outlined style',
|
|
80
|
-
table: { category: 'API', subcategory: 'Appearance' },
|
|
81
|
-
},
|
|
82
|
-
|
|
83
|
-
// ------------------------------
|
|
84
|
-
// Accessibility
|
|
85
|
-
// ------------------------------
|
|
86
|
-
'aria-label': {
|
|
87
|
-
control: { type: 'text' },
|
|
88
|
-
description: 'Accessible label (required for icon-only buttons)',
|
|
89
|
-
table: { category: 'API', subcategory: 'Accessibility' },
|
|
90
|
-
},
|
|
91
|
-
|
|
92
|
-
// ------------------------------
|
|
93
|
-
// Events (Svelte-style)
|
|
94
|
-
// ------------------------------
|
|
95
|
-
onclick: { table: { category: 'API', subcategory: 'Events' }, action: 'click' },
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
// ------------------------------
|
|
99
|
-
// Storybook Meta
|
|
100
|
-
// ------------------------------
|
|
101
|
-
const { Story } = defineMeta({
|
|
102
|
-
component: Button,
|
|
103
|
-
tags: ['autodocs'],
|
|
104
|
-
argTypes: storyButtonArgTypes,
|
|
105
|
-
parameters: {
|
|
106
|
-
docs: {
|
|
107
|
-
description: {
|
|
108
|
-
component: description,
|
|
109
|
-
},
|
|
110
|
-
},
|
|
111
|
-
},
|
|
112
|
-
});
|
|
113
|
-
</script>
|
|
114
|
-
|
|
115
|
-
<!-- ------------------------------ -->
|
|
116
|
-
<!-- Stories -->
|
|
117
|
-
<!-- ------------------------------ -->
|
|
118
|
-
|
|
119
|
-
<Story name="Default">Click me!</Story>
|
|
120
|
-
|
|
121
|
-
<Story
|
|
122
|
-
name="Link Button"
|
|
123
|
-
args={{
|
|
124
|
-
href: 'https://www.w3schools.com/tags/tag_a.asp',
|
|
125
|
-
target: '_blank',
|
|
126
|
-
}}
|
|
127
|
-
>
|
|
128
|
-
Click me!
|
|
129
|
-
</Story>
|
|
130
|
-
|
|
131
|
-
<Story
|
|
132
|
-
name="OnClick (Actions)"
|
|
133
|
-
args={{
|
|
134
|
-
onclick: (e: Event) => {
|
|
135
|
-
const target = e.target as HTMLButtonElement;
|
|
136
|
-
alert('Button Clicked');
|
|
137
|
-
console.log('Button Clicked', target);
|
|
138
|
-
},
|
|
139
|
-
}}
|
|
140
|
-
>
|
|
141
|
-
Click me
|
|
142
|
-
</Story>
|
|
143
|
-
|
|
144
|
-
<Story name="Color" args={{ color: 'safe' }}>Click me</Story>
|
|
145
|
-
|
|
146
|
-
<Story name="Text" args={{ variant: 'text' }}>Click me!</Story>
|
|
147
|
-
|
|
148
|
-
<Story name="Outline" args={{ variant: 'text', outline: true }}>Click me!</Story>
|
|
149
|
-
|
|
150
|
-
<Story name="Size" args={{ size: 'large' }}>Click me!</Story>
|
|
151
|
-
|
|
152
|
-
<Story name="Disabled" args={{ disabled: true }}>Click me!</Story>
|
|
153
|
-
|
|
154
|
-
<Story name="Submit Button" args={{ type: 'submit' }}>Click me!</Story>
|
|
155
|
-
|
|
156
|
-
<Story name="Full Width" args={{ fullWidth: true }}>Click me!</Story>
|
|
157
|
-
|
|
158
|
-
<Story
|
|
159
|
-
name="Compact"
|
|
160
|
-
args={{
|
|
161
|
-
compact: true,
|
|
162
|
-
'aria-label': 'Add item',
|
|
163
|
-
}}
|
|
164
|
-
>
|
|
165
|
-
+
|
|
166
|
-
</Story>
|
|
167
|
-
|
|
168
|
-
<Story name="Light Theme" asChild>
|
|
169
|
-
<Theme type="light">
|
|
170
|
-
<Button>Click me!</Button>
|
|
171
|
-
</Theme>
|
|
172
|
-
</Story>
|
|
173
|
-
|
|
174
|
-
<Story name="Dark Theme" asChild globals={{ backgrounds: { value: 'dark' } }}>
|
|
175
|
-
<Theme type="dark">
|
|
176
|
-
<Button>Click me!</Button>
|
|
177
|
-
</Theme>
|
|
178
|
-
</Story>
|
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
<script module lang="ts">
|
|
2
|
-
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
-
import Checkbox from './Checkbox.svelte';
|
|
4
|
-
import type { CheckboxProps } from './Checkbox.svelte';
|
|
5
|
-
import type { ArgTypes } from 'storybook/internal/csf';
|
|
6
|
-
import { componentColorOptions } from '$lib/attributes/color.js';
|
|
7
|
-
import { componentSizeOptions } from '$lib/attributes/size.js';
|
|
8
|
-
import { componenRoundnessShapeOptions } from '$lib/attributes/roundness.js';
|
|
9
|
-
import Theme from '$lib/components/Layout/Theme/Theme.svelte';
|
|
10
|
-
import { componentVariantOptions } from '$lib/attributes/variant.js';
|
|
11
|
-
|
|
12
|
-
const description = `
|
|
13
|
-
A simple Checkbox component based on bits-ui [checkbox](https://bits-ui.com/docs/components/checkbox).
|
|
14
|
-
|
|
15
|
-
\`\`\`ts
|
|
16
|
-
import { Checkbox } from '@flightlesslabs/dodo-ui';
|
|
17
|
-
\`\`\`
|
|
18
|
-
`;
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Storybook controls for Checkbox
|
|
22
|
-
*/
|
|
23
|
-
export const CheckboxArgTypes: Partial<ArgTypes<CheckboxProps>> = {
|
|
24
|
-
// ------------------------------
|
|
25
|
-
// Core
|
|
26
|
-
// ------------------------------
|
|
27
|
-
children: { table: { category: 'API', subcategory: 'Base' } },
|
|
28
|
-
disabled: {
|
|
29
|
-
control: { type: 'boolean' },
|
|
30
|
-
description: 'Disable interactions',
|
|
31
|
-
table: { category: 'API', subcategory: 'Base' },
|
|
32
|
-
},
|
|
33
|
-
class: { table: { category: 'API', subcategory: 'Base' } },
|
|
34
|
-
|
|
35
|
-
// ------------------------------
|
|
36
|
-
// Appearance
|
|
37
|
-
// ------------------------------
|
|
38
|
-
color: {
|
|
39
|
-
control: { type: 'select' },
|
|
40
|
-
options: componentColorOptions,
|
|
41
|
-
description: 'Color theme token',
|
|
42
|
-
table: { category: 'API', subcategory: 'Appearance', defaultValue: { summary: 'neutral' } },
|
|
43
|
-
},
|
|
44
|
-
variant: {
|
|
45
|
-
control: { type: 'select' },
|
|
46
|
-
options: componentVariantOptions,
|
|
47
|
-
description: 'Visual variant of the Checkbox',
|
|
48
|
-
table: { category: 'API', subcategory: 'Appearance', defaultValue: { summary: 'text' } },
|
|
49
|
-
},
|
|
50
|
-
size: {
|
|
51
|
-
control: { type: 'select' },
|
|
52
|
-
options: componentSizeOptions,
|
|
53
|
-
description: 'Visual size token',
|
|
54
|
-
table: { category: 'API', subcategory: 'Appearance', defaultValue: { summary: 'normal' } },
|
|
55
|
-
},
|
|
56
|
-
roundness: {
|
|
57
|
-
control: { type: 'select' },
|
|
58
|
-
options: componenRoundnessShapeOptions,
|
|
59
|
-
description: 'Border radius token',
|
|
60
|
-
table: { category: 'API', subcategory: 'Appearance' },
|
|
61
|
-
},
|
|
62
|
-
outline: {
|
|
63
|
-
control: { type: 'boolean' },
|
|
64
|
-
description: 'Render outlined style',
|
|
65
|
-
table: { category: 'API', subcategory: 'Appearance', defaultValue: { summary: 'true' } },
|
|
66
|
-
},
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
const { Story } = defineMeta({
|
|
70
|
-
component: Checkbox,
|
|
71
|
-
tags: ['autodocs'],
|
|
72
|
-
argTypes: CheckboxArgTypes,
|
|
73
|
-
parameters: {
|
|
74
|
-
docs: {
|
|
75
|
-
description: {
|
|
76
|
-
component: description,
|
|
77
|
-
},
|
|
78
|
-
},
|
|
79
|
-
},
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
let myValue = $state<boolean>(true);
|
|
83
|
-
</script>
|
|
84
|
-
|
|
85
|
-
<!-- ------------------------------ -->
|
|
86
|
-
<!-- Stories -->
|
|
87
|
-
<!-- ------------------------------ -->
|
|
88
|
-
|
|
89
|
-
<Story name="Default" args={{ id: 'Default' }}>Check this text</Story>
|
|
90
|
-
|
|
91
|
-
<Story name="Controlled" asChild>
|
|
92
|
-
<Checkbox id="Checked" bind:checked={myValue}>Check this text</Checkbox>
|
|
93
|
-
</Story>
|
|
94
|
-
|
|
95
|
-
<Story
|
|
96
|
-
name="OnChange (Actions)"
|
|
97
|
-
args={{
|
|
98
|
-
id: 'OnChange_Action',
|
|
99
|
-
onCheckedChange: (checked: boolean) => {
|
|
100
|
-
alert('OnChange');
|
|
101
|
-
console.log('OnChange', checked);
|
|
102
|
-
},
|
|
103
|
-
}}
|
|
104
|
-
>
|
|
105
|
-
Check this text
|
|
106
|
-
</Story>
|
|
107
|
-
|
|
108
|
-
<Story name="Indeterminate" args={{ id: 'indeterminate', indeterminate: true }}>
|
|
109
|
-
Check this text
|
|
110
|
-
</Story>
|
|
111
|
-
|
|
112
|
-
<Story name="Color" args={{ id: 'Safe', color: 'safe' }}>Check this text</Story>
|
|
113
|
-
|
|
114
|
-
<Story name="Solid" args={{ id: 'Solid', variant: 'solid', checked: true }}>Check this text</Story>
|
|
115
|
-
|
|
116
|
-
<Story name="NoOutline" args={{ id: 'Outline', outline: false }}>Check this text</Story>
|
|
117
|
-
|
|
118
|
-
<Story name="Size" args={{ id: 'Size', size: 'large' }}>Check this text</Story>
|
|
119
|
-
|
|
120
|
-
<Story name="Disabled" args={{ disabled: true }}>Check this text</Story>
|
|
121
|
-
|
|
122
|
-
<Story name="Light Theme" asChild>
|
|
123
|
-
<Theme type="light">
|
|
124
|
-
<Checkbox id="Light_Theme">Check this text</Checkbox>
|
|
125
|
-
</Theme>
|
|
126
|
-
</Story>
|
|
127
|
-
|
|
128
|
-
<Story name="Dark Theme" asChild globals={{ backgrounds: { value: 'dark' } }}>
|
|
129
|
-
<Theme type="dark">
|
|
130
|
-
<Checkbox id="Dark_Theme">Check this text</Checkbox>
|
|
131
|
-
</Theme>
|
|
132
|
-
</Story>
|