@flightlesslabs/dodo-ui 0.22.2 → 0.24.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. package/README.md +1 -9
  2. package/dist/index.d.ts +4 -10
  3. package/dist/index.js +5 -10
  4. package/dist/styles/components.css +0 -154
  5. package/dist/styles/components.css.map +1 -1
  6. package/dist/styles/components.scss +0 -2
  7. package/package.json +27 -41
  8. package/src/lib/index.ts +6 -19
  9. package/src/lib/styles/components.scss +0 -2
  10. package/src/lib/utils/time/date-creator/createDate/createDate.test.ts +109 -0
  11. package/src/lib/utils/time/date-creator/createDateFactory/createDateFactory.test.ts +146 -0
  12. package/dist/Home.mdx +0 -69
  13. package/dist/components/Form/Button/Button.stories.svelte +0 -178
  14. package/dist/components/Form/Button/Button.stories.svelte.d.ts +0 -22
  15. package/dist/components/Form/Checkbox/Checkbox.stories.svelte +0 -132
  16. package/dist/components/Form/Checkbox/Checkbox.stories.svelte.d.ts +0 -25
  17. package/dist/components/Form/DatePicker/DatePicker.scss +0 -55
  18. package/dist/components/Form/DatePicker/DatePicker.stories.svelte +0 -139
  19. package/dist/components/Form/DatePicker/DatePicker.stories.svelte.d.ts +0 -22
  20. package/dist/components/Form/DatePicker/DatePicker.svelte +0 -136
  21. package/dist/components/Form/DatePicker/DatePicker.svelte.d.ts +0 -64
  22. package/dist/components/Form/DatePicker/DatePickerInput/DatePickerInput.svelte +0 -96
  23. package/dist/components/Form/DatePicker/DatePickerInput/DatePickerInput.svelte.d.ts +0 -23
  24. package/dist/components/Form/DatePicker/DatePickerInput/Segments.svelte +0 -17
  25. package/dist/components/Form/DatePicker/DatePickerInput/Segments.svelte.d.ts +0 -8
  26. package/dist/components/Form/DatePicker/DatePickerInput/utils.d.ts +0 -10
  27. package/dist/components/Form/DatePicker/DatePickerInput/utils.js +0 -26
  28. package/dist/components/Form/DatePicker/DatePickerPopup/CalendarGrid.svelte +0 -35
  29. package/dist/components/Form/DatePicker/DatePickerPopup/CalendarGrid.svelte.d.ts +0 -4
  30. package/dist/components/Form/DatePicker/DatePickerPopup/DatePickerPopup.svelte +0 -52
  31. package/dist/components/Form/DatePicker/DatePickerPopup/DatePickerPopup.svelte.d.ts +0 -6
  32. package/dist/components/Form/DatePicker/DatePickerPopup/Header.svelte +0 -25
  33. package/dist/components/Form/DatePicker/DatePickerPopup/Header.svelte.d.ts +0 -3
  34. package/dist/components/Form/FormField/FormField.stories.svelte +0 -48
  35. package/dist/components/Form/FormField/FormField.stories.svelte.d.ts +0 -25
  36. package/dist/components/Form/InputEnclosure/InputEnclosure.stories.svelte +0 -166
  37. package/dist/components/Form/InputEnclosure/InputEnclosure.stories.svelte.d.ts +0 -22
  38. package/dist/components/Form/Label/Label.stories.svelte +0 -31
  39. package/dist/components/Form/Label/Label.stories.svelte.d.ts +0 -25
  40. package/dist/components/Form/RadioGroup/Radio/Radio.stories.svelte +0 -78
  41. package/dist/components/Form/RadioGroup/Radio/Radio.stories.svelte.d.ts +0 -25
  42. package/dist/components/Form/RadioGroup/RadioGroup.stories.svelte +0 -172
  43. package/dist/components/Form/RadioGroup/RadioGroup.stories.svelte.d.ts +0 -25
  44. package/dist/components/Form/Select/Select.stories.svelte +0 -175
  45. package/dist/components/Form/Select/Select.stories.svelte.d.ts +0 -22
  46. package/dist/components/Form/Switch/Switch.stories.svelte +0 -128
  47. package/dist/components/Form/Switch/Switch.stories.svelte.d.ts +0 -25
  48. package/dist/components/Form/TextInput/TextInput.stories.svelte +0 -162
  49. package/dist/components/Form/TextInput/TextInput.stories.svelte.d.ts +0 -22
  50. package/dist/components/Form/UtilityButton/UtilityButton.stories.svelte +0 -163
  51. package/dist/components/Form/UtilityButton/UtilityButton.stories.svelte.d.ts +0 -22
  52. package/dist/components/Info/Calendar/Calendar.scss +0 -147
  53. package/dist/components/Info/Calendar/Calendar.stories.svelte +0 -134
  54. package/dist/components/Info/Calendar/Calendar.stories.svelte.d.ts +0 -22
  55. package/dist/components/Info/Calendar/Calendar.svelte +0 -61
  56. package/dist/components/Info/Calendar/Calendar.svelte.d.ts +0 -6
  57. package/dist/components/Info/Calendar/CalendarGrid/CalendarGrid.svelte +0 -16
  58. package/dist/components/Info/Calendar/CalendarGrid/CalendarGrid.svelte.d.ts +0 -4
  59. package/dist/components/Info/Calendar/CalendarGrid/TableBody.svelte +0 -25
  60. package/dist/components/Info/Calendar/CalendarGrid/TableBody.svelte.d.ts +0 -8
  61. package/dist/components/Info/Calendar/CalendarGrid/TableHead.svelte +0 -19
  62. package/dist/components/Info/Calendar/CalendarGrid/TableHead.svelte.d.ts +0 -6
  63. package/dist/components/Info/Calendar/Header.svelte +0 -25
  64. package/dist/components/Info/Calendar/Header.svelte.d.ts +0 -3
  65. package/dist/components/Layout/Card/Card.stories.svelte +0 -113
  66. package/dist/components/Layout/Card/Card.stories.svelte.d.ts +0 -22
  67. package/dist/components/Layout/Grid/Column/Column.stories.svelte +0 -66
  68. package/dist/components/Layout/Grid/Column/Column.stories.svelte.d.ts +0 -22
  69. package/dist/components/Layout/Grid/Grid.stories.svelte +0 -192
  70. package/dist/components/Layout/Grid/Grid.stories.svelte.d.ts +0 -22
  71. package/dist/components/Layout/Grid/Row/Row.stories.svelte +0 -39
  72. package/dist/components/Layout/Grid/Row/Row.stories.svelte.d.ts +0 -22
  73. package/dist/components/Layout/Theme/Theme.stories.svelte +0 -54
  74. package/dist/components/Layout/Theme/Theme.stories.svelte.d.ts +0 -25
  75. package/dist/components/Layout/Theme/ThemeSystem/index.mdx +0 -35
  76. package/dist/storybook-types.d.ts +0 -129
  77. package/dist/storybook-types.js +0 -1
  78. package/dist/utils/time/date-creator/createDate/createDate.mdx +0 -98
  79. package/dist/utils/time/date-creator/createDateFactory/createDateFactory.mdx +0 -104
  80. package/dist/utils/time/timeout/timeout.mdx +0 -114
  81. package/src/lib/Home.mdx +0 -69
  82. package/src/lib/components/Form/Button/Button.stories.svelte +0 -178
  83. package/src/lib/components/Form/Checkbox/Checkbox.stories.svelte +0 -132
  84. package/src/lib/components/Form/DatePicker/DatePicker.scss +0 -55
  85. package/src/lib/components/Form/DatePicker/DatePicker.stories.svelte +0 -139
  86. package/src/lib/components/Form/DatePicker/DatePicker.svelte +0 -136
  87. package/src/lib/components/Form/DatePicker/DatePickerInput/DatePickerInput.svelte +0 -96
  88. package/src/lib/components/Form/DatePicker/DatePickerInput/Segments.svelte +0 -17
  89. package/src/lib/components/Form/DatePicker/DatePickerInput/utils.ts +0 -55
  90. package/src/lib/components/Form/DatePicker/DatePickerPopup/CalendarGrid.svelte +0 -35
  91. package/src/lib/components/Form/DatePicker/DatePickerPopup/DatePickerPopup.svelte +0 -52
  92. package/src/lib/components/Form/DatePicker/DatePickerPopup/Header.svelte +0 -25
  93. package/src/lib/components/Form/FormField/FormField.stories.svelte +0 -48
  94. package/src/lib/components/Form/InputEnclosure/InputEnclosure.stories.svelte +0 -166
  95. package/src/lib/components/Form/Label/Label.stories.svelte +0 -31
  96. package/src/lib/components/Form/RadioGroup/Radio/Radio.stories.svelte +0 -78
  97. package/src/lib/components/Form/RadioGroup/RadioGroup.stories.svelte +0 -172
  98. package/src/lib/components/Form/Select/Select.stories.svelte +0 -175
  99. package/src/lib/components/Form/Switch/Switch.stories.svelte +0 -128
  100. package/src/lib/components/Form/TextInput/TextInput.stories.svelte +0 -162
  101. package/src/lib/components/Form/UtilityButton/UtilityButton.stories.svelte +0 -163
  102. package/src/lib/components/Info/Calendar/Calendar.scss +0 -147
  103. package/src/lib/components/Info/Calendar/Calendar.stories.svelte +0 -134
  104. package/src/lib/components/Info/Calendar/Calendar.svelte +0 -61
  105. package/src/lib/components/Info/Calendar/CalendarGrid/CalendarGrid.svelte +0 -16
  106. package/src/lib/components/Info/Calendar/CalendarGrid/TableBody.svelte +0 -25
  107. package/src/lib/components/Info/Calendar/CalendarGrid/TableHead.svelte +0 -19
  108. package/src/lib/components/Info/Calendar/Header.svelte +0 -25
  109. package/src/lib/components/Layout/Card/Card.stories.svelte +0 -113
  110. package/src/lib/components/Layout/Grid/Column/Column.stories.svelte +0 -66
  111. package/src/lib/components/Layout/Grid/Grid.stories.svelte +0 -192
  112. package/src/lib/components/Layout/Grid/Row/Row.stories.svelte +0 -39
  113. package/src/lib/components/Layout/Theme/Theme.stories.svelte +0 -54
  114. package/src/lib/components/Layout/Theme/ThemeSystem/index.mdx +0 -35
  115. package/src/lib/storybook-types.ts +0 -182
  116. package/src/lib/utils/time/date-creator/createDate/createDate.mdx +0 -98
  117. package/src/lib/utils/time/date-creator/createDateFactory/createDateFactory.mdx +0 -104
  118. package/src/lib/utils/time/timeout/timeout.mdx +0 -114
@@ -1,129 +0,0 @@
1
- type ControlType = 'object' | 'boolean' | 'check' | 'inline-check' | 'radio' | 'inline-radio' | 'select' | 'multi-select' | 'number' | 'range' | 'file' | 'color' | 'date' | 'text';
2
- interface ControlBase {
3
- [key: string]: any;
4
- /** @see https://storybook.js.org/docs/api/arg-types#controltype */
5
- type?: ControlType;
6
- disable?: boolean;
7
- }
8
- type Control = ControlType | false | (ControlBase & (ControlBase | {
9
- type: 'color';
10
- /** @see https://storybook.js.org/docs/api/arg-types#controlpresetcolors */
11
- presetColors?: string[];
12
- } | {
13
- type: 'file';
14
- /** @see https://storybook.js.org/docs/api/arg-types#controlaccept */
15
- accept?: string;
16
- } | {
17
- type: 'inline-check' | 'radio' | 'inline-radio' | 'select' | 'multi-select';
18
- /** @see https://storybook.js.org/docs/api/arg-types#controllabels */
19
- labels?: {
20
- [options: string]: string;
21
- };
22
- } | {
23
- type: 'number' | 'range';
24
- /** @see https://storybook.js.org/docs/api/arg-types#controlmax */
25
- max?: number;
26
- /** @see https://storybook.js.org/docs/api/arg-types#controlmin */
27
- min?: number;
28
- /** @see https://storybook.js.org/docs/api/arg-types#controlstep */
29
- step?: number;
30
- }));
31
- type ConditionalTest = {
32
- truthy?: boolean;
33
- } | {
34
- exists: boolean;
35
- } | {
36
- eq: any;
37
- } | {
38
- neq: any;
39
- };
40
- type ConditionalValue = {
41
- arg: string;
42
- } | {
43
- global: string;
44
- };
45
- type Conditional = ConditionalValue & ConditionalTest;
46
- interface Args {
47
- [name: string]: any;
48
- }
49
- interface SBBaseType {
50
- required?: boolean;
51
- raw?: string;
52
- }
53
- type SBScalarType = SBBaseType & {
54
- name: 'boolean' | 'string' | 'number' | 'function' | 'symbol';
55
- };
56
- type SBArrayType = SBBaseType & {
57
- name: 'array';
58
- value: SBType;
59
- };
60
- type SBObjectType = SBBaseType & {
61
- name: 'object';
62
- value: Record<string, SBType>;
63
- };
64
- type SBEnumType = SBBaseType & {
65
- name: 'enum';
66
- value: (string | number)[];
67
- };
68
- type SBIntersectionType = SBBaseType & {
69
- name: 'intersection';
70
- value: SBType[];
71
- };
72
- type SBUnionType = SBBaseType & {
73
- name: 'union';
74
- value: SBType[];
75
- };
76
- type SBOtherType = SBBaseType & {
77
- name: 'other';
78
- value: string;
79
- };
80
- type SBType = SBScalarType | SBEnumType | SBArrayType | SBObjectType | SBIntersectionType | SBUnionType | SBOtherType;
81
- interface InputType {
82
- /** @see https://storybook.js.org/docs/api/arg-types#control */
83
- control?: Control;
84
- /** @see https://storybook.js.org/docs/api/arg-types#description */
85
- description?: string;
86
- /** @see https://storybook.js.org/docs/api/arg-types#if */
87
- if?: Conditional;
88
- /** @see https://storybook.js.org/docs/api/arg-types#mapping */
89
- mapping?: {
90
- [key: string]: any;
91
- };
92
- /** @see https://storybook.js.org/docs/api/arg-types#name */
93
- name?: string;
94
- /** @see https://storybook.js.org/docs/api/arg-types#options */
95
- options?: readonly any[];
96
- /** @see https://storybook.js.org/docs/api/arg-types#table */
97
- table?: {
98
- [key: string]: unknown;
99
- /** @see https://storybook.js.org/docs/api/arg-types#tablecategory */
100
- category?: string;
101
- /** @see https://storybook.js.org/docs/api/arg-types#tabledefaultvalue */
102
- defaultValue?: {
103
- summary?: string;
104
- detail?: string;
105
- };
106
- /** @see https://storybook.js.org/docs/api/arg-types#tabledisable */
107
- disable?: boolean;
108
- /** @see https://storybook.js.org/docs/api/arg-types#tablesubcategory */
109
- subcategory?: string;
110
- /** @see https://storybook.js.org/docs/api/arg-types#tabletype */
111
- type?: {
112
- summary?: string;
113
- detail?: string;
114
- };
115
- };
116
- /** @see https://storybook.js.org/docs/api/arg-types#type */
117
- type?: SBType | SBScalarType['name'];
118
- /**
119
- * @deprecated Use `table.defaultValue.summary` instead.
120
- * @see https://storybook.js.org/docs/api/arg-types#defaultvalue
121
- */
122
- defaultValue?: any;
123
- [key: string]: any;
124
- }
125
- export type ArgTypes<TArgs = Args> = {
126
- [name in keyof TArgs]: InputType;
127
- };
128
- export type StoryBookArgTypes = Partial<ArgTypes<Args>>;
129
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -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>