@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.
Files changed (74) hide show
  1. package/README.md +1 -9
  2. package/dist/index.d.ts +4 -0
  3. package/dist/index.js +4 -0
  4. package/package.json +25 -35
  5. package/src/lib/index.ts +5 -0
  6. package/src/lib/utils/time/date-creator/createDate/createDate.test.ts +109 -0
  7. package/src/lib/utils/time/date-creator/createDateFactory/createDateFactory.test.ts +146 -0
  8. package/dist/Home.mdx +0 -69
  9. package/dist/components/Form/Button/Button.stories.svelte +0 -178
  10. package/dist/components/Form/Button/Button.stories.svelte.d.ts +0 -22
  11. package/dist/components/Form/Checkbox/Checkbox.stories.svelte +0 -132
  12. package/dist/components/Form/Checkbox/Checkbox.stories.svelte.d.ts +0 -25
  13. package/dist/components/Form/DatePicker/DatePicker.stories.svelte +0 -139
  14. package/dist/components/Form/DatePicker/DatePicker.stories.svelte.d.ts +0 -22
  15. package/dist/components/Form/FormField/FormField.stories.svelte +0 -48
  16. package/dist/components/Form/FormField/FormField.stories.svelte.d.ts +0 -25
  17. package/dist/components/Form/InputEnclosure/InputEnclosure.stories.svelte +0 -166
  18. package/dist/components/Form/InputEnclosure/InputEnclosure.stories.svelte.d.ts +0 -22
  19. package/dist/components/Form/Label/Label.stories.svelte +0 -31
  20. package/dist/components/Form/Label/Label.stories.svelte.d.ts +0 -25
  21. package/dist/components/Form/RadioGroup/Radio/Radio.stories.svelte +0 -78
  22. package/dist/components/Form/RadioGroup/Radio/Radio.stories.svelte.d.ts +0 -25
  23. package/dist/components/Form/RadioGroup/RadioGroup.stories.svelte +0 -172
  24. package/dist/components/Form/RadioGroup/RadioGroup.stories.svelte.d.ts +0 -25
  25. package/dist/components/Form/Select/Select.stories.svelte +0 -175
  26. package/dist/components/Form/Select/Select.stories.svelte.d.ts +0 -22
  27. package/dist/components/Form/Switch/Switch.stories.svelte +0 -128
  28. package/dist/components/Form/Switch/Switch.stories.svelte.d.ts +0 -25
  29. package/dist/components/Form/TextInput/TextInput.stories.svelte +0 -162
  30. package/dist/components/Form/TextInput/TextInput.stories.svelte.d.ts +0 -22
  31. package/dist/components/Form/UtilityButton/UtilityButton.stories.svelte +0 -163
  32. package/dist/components/Form/UtilityButton/UtilityButton.stories.svelte.d.ts +0 -22
  33. package/dist/components/Info/Calendar/Calendar.stories.svelte +0 -134
  34. package/dist/components/Info/Calendar/Calendar.stories.svelte.d.ts +0 -22
  35. package/dist/components/Layout/Card/Card.stories.svelte +0 -113
  36. package/dist/components/Layout/Card/Card.stories.svelte.d.ts +0 -22
  37. package/dist/components/Layout/Grid/Column/Column.stories.svelte +0 -66
  38. package/dist/components/Layout/Grid/Column/Column.stories.svelte.d.ts +0 -22
  39. package/dist/components/Layout/Grid/Grid.stories.svelte +0 -192
  40. package/dist/components/Layout/Grid/Grid.stories.svelte.d.ts +0 -22
  41. package/dist/components/Layout/Grid/Row/Row.stories.svelte +0 -39
  42. package/dist/components/Layout/Grid/Row/Row.stories.svelte.d.ts +0 -22
  43. package/dist/components/Layout/Theme/Theme.stories.svelte +0 -54
  44. package/dist/components/Layout/Theme/Theme.stories.svelte.d.ts +0 -25
  45. package/dist/components/Layout/Theme/ThemeSystem/index.mdx +0 -35
  46. package/dist/storybook-types.d.ts +0 -129
  47. package/dist/storybook-types.js +0 -1
  48. package/dist/utils/time/date-creator/createDate/createDate.mdx +0 -98
  49. package/dist/utils/time/date-creator/createDateFactory/createDateFactory.mdx +0 -104
  50. package/dist/utils/time/timeout/timeout.mdx +0 -114
  51. package/src/lib/Home.mdx +0 -69
  52. package/src/lib/components/Form/Button/Button.stories.svelte +0 -178
  53. package/src/lib/components/Form/Checkbox/Checkbox.stories.svelte +0 -132
  54. package/src/lib/components/Form/DatePicker/DatePicker.stories.svelte +0 -139
  55. package/src/lib/components/Form/FormField/FormField.stories.svelte +0 -48
  56. package/src/lib/components/Form/InputEnclosure/InputEnclosure.stories.svelte +0 -166
  57. package/src/lib/components/Form/Label/Label.stories.svelte +0 -31
  58. package/src/lib/components/Form/RadioGroup/Radio/Radio.stories.svelte +0 -78
  59. package/src/lib/components/Form/RadioGroup/RadioGroup.stories.svelte +0 -172
  60. package/src/lib/components/Form/Select/Select.stories.svelte +0 -175
  61. package/src/lib/components/Form/Switch/Switch.stories.svelte +0 -128
  62. package/src/lib/components/Form/TextInput/TextInput.stories.svelte +0 -162
  63. package/src/lib/components/Form/UtilityButton/UtilityButton.stories.svelte +0 -163
  64. package/src/lib/components/Info/Calendar/Calendar.stories.svelte +0 -134
  65. package/src/lib/components/Layout/Card/Card.stories.svelte +0 -113
  66. package/src/lib/components/Layout/Grid/Column/Column.stories.svelte +0 -66
  67. package/src/lib/components/Layout/Grid/Grid.stories.svelte +0 -192
  68. package/src/lib/components/Layout/Grid/Row/Row.stories.svelte +0 -39
  69. package/src/lib/components/Layout/Theme/Theme.stories.svelte +0 -54
  70. package/src/lib/components/Layout/Theme/ThemeSystem/index.mdx +0 -35
  71. package/src/lib/storybook-types.ts +0 -182
  72. package/src/lib/utils/time/date-creator/createDate/createDate.mdx +0 -98
  73. package/src/lib/utils/time/date-creator/createDateFactory/createDateFactory.mdx +0 -104
  74. package/src/lib/utils/time/timeout/timeout.mdx +0 -114
package/README.md CHANGED
@@ -1,9 +1 @@
1
- ![Dodo logo](https://flightlesslabs.github.io/dodo-ui/og.png)
2
-
3
- Opinionated UI framework for Svelte, based on [Bits UI](https://bits-ui.com/)
4
-
5
- [Github](https://github.com/flightlesslabs/dodo-ui) | [npm](https://www.npmjs.com/package/@flightlesslabs/dodo-ui)
6
-
7
-
8
- * [Develop](./docs/Develop.md)
9
- * [Library Guide](./docs/LibraryGuide.md)
1
+ # @flightlesslabs/dodo-ui
package/dist/index.d.ts CHANGED
@@ -10,6 +10,10 @@ export { default as TextInput, type TextInputEvent, type TextInputFocusEvent, ty
10
10
  * InputEnclosure component and related prop types.
11
11
  */
12
12
  export { default as InputEnclosure, type InputEnclosureProps, } from './components/Form/InputEnclosure/InputEnclosure.svelte';
13
+ /**
14
+ * Label component and related prop types.
15
+ */
16
+ export { default as Label, type LabelProps } from './components/Form/Label/Label.svelte';
13
17
  /**
14
18
  * FormField component and related prop types.
15
19
  */
package/dist/index.js CHANGED
@@ -13,6 +13,10 @@ export { default as TextInput, } from './components/Form/TextInput/TextInput.sve
13
13
  * InputEnclosure component and related prop types.
14
14
  */
15
15
  export { default as InputEnclosure, } from './components/Form/InputEnclosure/InputEnclosure.svelte';
16
+ /**
17
+ * Label component and related prop types.
18
+ */
19
+ export { default as Label } from './components/Form/Label/Label.svelte';
16
20
  /**
17
21
  * FormField component and related prop types.
18
22
  */
package/package.json CHANGED
@@ -1,23 +1,8 @@
1
1
  {
2
2
  "name": "@flightlesslabs/dodo-ui",
3
- "version": "0.22.1",
4
- "scripts": {
5
- "scss:global": "sh -c \"mkdir -p dist/styles && sass src/lib/styles/global/index.scss dist/styles/global.css\"",
6
- "scss:components": "sh -c \"mkdir -p dist/styles && sass src/lib/styles/components.scss dist/styles/components.css\"",
7
- "scss": "pnpm scss:global && pnpm scss:components",
8
- "build": "vite build && pnpm run prepack",
9
- "preview": "vite preview",
10
- "prepare": "svelte-kit sync || echo ''",
11
- "prepack": "svelte-kit sync && svelte-package && pnpm run scss && publint",
12
- "svelte-check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
13
- "format": "prettier --write .",
14
- "lint": "prettier --check . && eslint .",
15
- "dev": "storybook dev -p 6006",
16
- "build-storybook": "storybook build && touch ./storybook-static/.nojekyll",
17
- "check": "pnpm run svelte-check && eslint . && pnpm run lint",
18
- "check:fix": "pnpm run svelte-check && eslint . && pnpm run format",
19
- "create:component": "node --experimental-strip-types scripts/create-component/create-component.ts",
20
- "test": "vitest run"
3
+ "version": "0.23.0",
4
+ "publishConfig": {
5
+ "access": "public"
21
6
  },
22
7
  "homepage": "https://flightlesslabs.github.io/dodo-ui",
23
8
  "repository": {
@@ -31,12 +16,7 @@
31
16
  "!dist/**/*.spec.*",
32
17
  "src/lib",
33
18
  "!src/lib/**/*.test.*",
34
- "!src/lib/**/*.spec.*",
35
- "!src/lib/stories/**/*.stories.*",
36
- "!src/lib/stories/**/*.mdx",
37
- "!src/lib/stories/assets/**/*.png",
38
- "!src/lib/stories/assets/**/*.jpg",
39
- "!src/lib/stories/philosophy"
19
+ "!src/lib/**/*.spec.*"
40
20
  ],
41
21
  "sideEffects": [
42
22
  "**/*.css"
@@ -50,7 +30,11 @@
50
30
  "svelte": "./dist/index.js"
51
31
  },
52
32
  "./styles/global.css": "./dist/styles/global.css",
53
- "./styles/components.css": "./dist/styles/components.css"
33
+ "./styles/components.css": "./dist/styles/components.css",
34
+ "./styles/*": {
35
+ "sass": "./dist/styles/*",
36
+ "default": "./dist/styles/*"
37
+ }
54
38
  },
55
39
  "peerDependencies": {
56
40
  "@internationalized/date": "^3.0.0",
@@ -63,11 +47,6 @@
63
47
  "@eslint/js": "^10.0.1",
64
48
  "@iconify/svelte": "^5.2.1",
65
49
  "@internationalized/date": "^3.12.0",
66
- "@storybook/addon-a11y": "^10.3.5",
67
- "@storybook/addon-docs": "^10.3.5",
68
- "@storybook/addon-svelte-csf": "^5.1.2",
69
- "@storybook/addon-vitest": "^10.3.5",
70
- "@storybook/sveltekit": "^10.3.5",
71
50
  "@sveltejs/adapter-auto": "^7.0.1",
72
51
  "@sveltejs/adapter-static": "^3.0.10",
73
52
  "@sveltejs/kit": "^2.57.0",
@@ -79,7 +58,6 @@
79
58
  "@types/file-saver": "^2.0.7",
80
59
  "@types/node": "^24",
81
60
  "@vitest/browser": "^4.1.3",
82
- "@vitest/browser-playwright": "^4.1.3",
83
61
  "@vitest/coverage-v8": "^4.1.3",
84
62
  "bits-ui": "^2.17.2",
85
63
  "dayjs": "^1.11.20",
@@ -91,12 +69,10 @@
91
69
  "file-saver": "^2.0.5",
92
70
  "globals": "^17.4.0",
93
71
  "jsdom": "^29.0.2",
94
- "playwright": "^1.59.1",
95
72
  "prettier": "^3.8.1",
96
73
  "prettier-plugin-svelte": "^3.5.1",
97
74
  "publint": "^0.3.18",
98
75
  "sass": "^1.99.0",
99
- "storybook": "^10.3.5",
100
76
  "svelte": "^5.55.2",
101
77
  "svelte-check": "^4.4.6",
102
78
  "typescript": "^6.0.2",
@@ -106,5 +82,19 @@
106
82
  },
107
83
  "keywords": [
108
84
  "svelte"
109
- ]
110
- }
85
+ ],
86
+ "scripts": {
87
+ "scss:global": "sh -c \"mkdir -p dist/styles && sass src/lib/styles/global/index.scss dist/styles/global.css\"",
88
+ "scss:components": "sh -c \"mkdir -p dist/styles && sass src/lib/styles/components.scss dist/styles/components.css\"",
89
+ "scss": "pnpm scss:global && pnpm scss:components",
90
+ "build": "vite build && pnpm run prepack",
91
+ "preview": "vite preview",
92
+ "svelte-check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
93
+ "format": "prettier --write .",
94
+ "lint": "prettier --check . && eslint .",
95
+ "check": "pnpm run svelte-check && eslint . && pnpm run lint",
96
+ "check:fix": "pnpm run svelte-check && eslint . && pnpm run format",
97
+ "create:component": "node --experimental-strip-types scripts/create-component/create-component.ts",
98
+ "test": "vitest run"
99
+ }
100
+ }
package/src/lib/index.ts CHANGED
@@ -30,6 +30,11 @@ export {
30
30
  type InputEnclosureProps,
31
31
  } from './components/Form/InputEnclosure/InputEnclosure.svelte';
32
32
 
33
+ /**
34
+ * Label component and related prop types.
35
+ */
36
+ export { default as Label, type LabelProps } from './components/Form/Label/Label.svelte';
37
+
33
38
  /**
34
39
  * FormField component and related prop types.
35
40
  */
@@ -0,0 +1,109 @@
1
+ import { describe, it, expect } from 'vitest';
2
+ import dayjs from 'dayjs';
3
+ import { createDate } from './createDate.js';
4
+
5
+ describe('createDate', () => {
6
+ it('should return current date when no args provided', () => {
7
+ const now = createDate();
8
+
9
+ expect(now.isValid()).toBe(true);
10
+
11
+ const diff = Math.abs(now.valueOf() - dayjs().valueOf());
12
+ expect(diff).toBeLessThan(1000);
13
+ });
14
+
15
+ it('should parse ISO string without format', () => {
16
+ const date = createDate('2025-01-01');
17
+
18
+ expect(date.isValid()).toBe(true);
19
+ expect(date.year()).toBe(2025);
20
+ });
21
+
22
+ it('should parse formatted date string', () => {
23
+ const date = createDate('01-02-2025', 'DD-MM-YYYY');
24
+
25
+ expect(date.isValid()).toBe(true);
26
+ expect(date.year()).toBe(2025);
27
+ expect(date.month()).toBe(1); // February (0-based)
28
+ });
29
+
30
+ it('should respect strict parsing (valid case)', () => {
31
+ const date = createDate('01-02-2025', 'DD-MM-YYYY', {
32
+ strict: true,
33
+ });
34
+
35
+ expect(date.isValid()).toBe(true);
36
+ });
37
+
38
+ it('should respect strict parsing (invalid case)', () => {
39
+ const date = createDate('1-2-2025', 'DD-MM-YYYY', {
40
+ strict: true,
41
+ });
42
+
43
+ expect(date.isValid()).toBe(false);
44
+ });
45
+
46
+ it('should throw when throwOnInvalid is true', () => {
47
+ expect(() => createDate('invalid-date', undefined, { throwOnInvalid: true })).toThrow(
48
+ 'Invalid date input',
49
+ );
50
+ });
51
+
52
+ it('should NOT throw when throwOnInvalid is false', () => {
53
+ const date = createDate('invalid-date');
54
+
55
+ expect(date.isValid()).toBe(false);
56
+ });
57
+
58
+ it('should create UTC date when utc is true', () => {
59
+ const date = createDate('2025-01-01T00:00:00Z', undefined, {
60
+ utc: true,
61
+ });
62
+
63
+ expect(date.isValid()).toBe(true);
64
+ expect(date.isUTC()).toBe(true);
65
+ });
66
+
67
+ it('should prioritize UTC over timezone', () => {
68
+ const date = createDate('2025-01-01T00:00:00Z', undefined, {
69
+ utc: true,
70
+ timezone: 'Asia/Kolkata',
71
+ });
72
+
73
+ expect(date.isUTC()).toBe(true);
74
+ });
75
+
76
+ it('should handle timestamp input', () => {
77
+ const timestamp = Date.now();
78
+ const date = createDate(timestamp);
79
+
80
+ expect(date.isValid()).toBe(true);
81
+ expect(Math.abs(date.valueOf() - timestamp)).toBeLessThan(5);
82
+ });
83
+
84
+ it('should handle native Date object', () => {
85
+ const now = new Date();
86
+ const date = createDate(now);
87
+
88
+ expect(date.isValid()).toBe(true);
89
+ expect(Math.abs(date.valueOf() - now.valueOf())).toBeLessThan(5);
90
+ });
91
+
92
+ it('should apply timezone when provided', () => {
93
+ const date = createDate('01-01-2025', 'DD-MM-YYYY', {
94
+ timezone: 'Asia/Kolkata',
95
+ });
96
+
97
+ expect(date.isValid()).toBe(true);
98
+
99
+ // avoid fragile string checks; just ensure offset exists
100
+ expect(typeof date.utcOffset()).toBe('number');
101
+ });
102
+
103
+ it('should default to local time when no options provided', () => {
104
+ const date = createDate('2025-01-01');
105
+
106
+ expect(date.isValid()).toBe(true);
107
+ expect(date.isUTC()).toBe(false);
108
+ });
109
+ });
@@ -0,0 +1,146 @@
1
+ import { describe, it, expect } from 'vitest';
2
+ import dayjs from 'dayjs';
3
+ import utc from 'dayjs/plugin/utc.js';
4
+ import timezone from 'dayjs/plugin/timezone.js';
5
+ import customParseFormat from 'dayjs/plugin/customParseFormat.js';
6
+
7
+ import { createDateFactory } from './createDateFactory.js';
8
+
9
+ // extend test dayjs (important for factory injection tests)
10
+ dayjs.extend(utc);
11
+ dayjs.extend(timezone);
12
+ dayjs.extend(customParseFormat);
13
+
14
+ describe('createDateFactory', () => {
15
+ it('should create a date with default factory', () => {
16
+ const { createDate } = createDateFactory();
17
+
18
+ const date = createDate();
19
+
20
+ expect(date.isValid()).toBe(true);
21
+ });
22
+
23
+ it('should parse ISO string', () => {
24
+ const { createDate } = createDateFactory();
25
+
26
+ const date = createDate('2025-01-01');
27
+
28
+ expect(date.isValid()).toBe(true);
29
+ expect(date.year()).toBe(2025);
30
+ });
31
+
32
+ it('should parse formatted date', () => {
33
+ const { createDate } = createDateFactory();
34
+
35
+ const date = createDate('01-02-2025', 'DD-MM-YYYY');
36
+
37
+ expect(date.isValid()).toBe(true);
38
+ expect(date.year()).toBe(2025);
39
+ expect(date.month()).toBe(1);
40
+ });
41
+
42
+ it('should respect strict parsing (valid)', () => {
43
+ const { createDate } = createDateFactory();
44
+
45
+ const date = createDate('01-02-2025', 'DD-MM-YYYY', {
46
+ strict: true,
47
+ });
48
+
49
+ expect(date.isValid()).toBe(true);
50
+ });
51
+
52
+ it('should respect strict parsing (invalid)', () => {
53
+ const { createDate } = createDateFactory();
54
+
55
+ const date = createDate('1-2-2025', 'DD-MM-YYYY', {
56
+ strict: true,
57
+ });
58
+
59
+ expect(date.isValid()).toBe(false);
60
+ });
61
+
62
+ it('should throw on invalid date when enabled', () => {
63
+ const { createDate } = createDateFactory();
64
+
65
+ expect(() => createDate('invalid-date', undefined, { throwOnInvalid: true })).toThrow(
66
+ 'Invalid date input',
67
+ );
68
+ });
69
+
70
+ it('should NOT throw on invalid date when disabled', () => {
71
+ const { createDate } = createDateFactory();
72
+
73
+ const date = createDate('invalid-date');
74
+
75
+ expect(date.isValid()).toBe(false);
76
+ });
77
+
78
+ it('should handle UTC mode', () => {
79
+ const { createDate } = createDateFactory();
80
+
81
+ const date = createDate('2025-01-01T00:00:00Z', undefined, {
82
+ utc: true,
83
+ });
84
+
85
+ expect(date.isUTC()).toBe(true);
86
+ });
87
+
88
+ it('should prioritize UTC over timezone', () => {
89
+ const { createDate } = createDateFactory();
90
+
91
+ const date = createDate('2025-01-01T00:00:00Z', undefined, {
92
+ utc: true,
93
+ timezone: 'Asia/Kolkata',
94
+ });
95
+
96
+ expect(date.isUTC()).toBe(true);
97
+ });
98
+
99
+ it('should apply timezone when provided', () => {
100
+ const { createDate } = createDateFactory();
101
+
102
+ const date = createDate('01-01-2025', 'DD-MM-YYYY', {
103
+ timezone: 'Asia/Kolkata',
104
+ });
105
+
106
+ expect(date.isValid()).toBe(true);
107
+ expect(typeof date.utcOffset()).toBe('number');
108
+ });
109
+
110
+ it('should handle timestamp input', () => {
111
+ const { createDate } = createDateFactory();
112
+
113
+ const ts = Date.now();
114
+ const date = createDate(ts);
115
+
116
+ expect(date.isValid()).toBe(true);
117
+ expect(Math.abs(date.valueOf() - ts)).toBeLessThan(5);
118
+ });
119
+
120
+ it('should handle native Date object', () => {
121
+ const { createDate } = createDateFactory();
122
+
123
+ const now = new Date();
124
+ const date = createDate(now);
125
+
126
+ expect(date.isValid()).toBe(true);
127
+ expect(Math.abs(date.valueOf() - now.valueOf())).toBeLessThan(5);
128
+ });
129
+
130
+ it('should work with custom Dayjs instance', () => {
131
+ const custom = dayjs;
132
+
133
+ const { createDate } = createDateFactory(custom);
134
+
135
+ const date = createDate('2025-01-01');
136
+
137
+ expect(date.isValid()).toBe(true);
138
+ });
139
+
140
+ it('should return same underlying dayjs instance from factory', () => {
141
+ const { dayjs: d1 } = createDateFactory();
142
+ const { dayjs: d2 } = createDateFactory();
143
+
144
+ expect(d1).toBe(d2);
145
+ });
146
+ });
package/dist/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 '../../../attributes/color.js';
7
- import { componentVariantOptions } from '../../../attributes/variant.js';
8
- import { componentSizeOptions } from '../../../attributes/size.js';
9
- import { componentRoundnessOptions } from '../../../attributes/roundness.js';
10
- import Theme from '../../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,22 +0,0 @@
1
- import Button from './Button.svelte';
2
- import type { ButtonProps } from './Button.svelte';
3
- import type { ArgTypes } from 'storybook/internal/csf';
4
- export declare const storyButtonArgTypes: Partial<ArgTypes<ButtonProps>>;
5
- interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
6
- new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
7
- $$bindings?: Bindings;
8
- } & Exports;
9
- (internal: unknown, props: {
10
- $$events?: Events;
11
- $$slots?: Slots;
12
- }): Exports & {
13
- $set?: any;
14
- $on?: any;
15
- };
16
- z_$$bindings?: Bindings;
17
- }
18
- declare const Button: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
19
- [evt: string]: CustomEvent<any>;
20
- }, {}, {}, string>;
21
- type Button = InstanceType<typeof Button>;
22
- export default Button;