@flightlesslabs/dodo-ui 0.2.0 → 0.4.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/dist/index.d.ts +15 -0
- package/dist/index.js +12 -0
- package/dist/stories/Home.mdx +1 -1
- package/dist/stories/components/Form/Button/Button.stories.svelte +10 -5
- package/dist/stories/components/Form/Button/Button.svelte +216 -208
- package/dist/stories/components/Form/Button/Button.svelte.d.ts +8 -3
- package/dist/stories/components/Form/Button/Events/Events.stories.svelte +40 -0
- package/dist/stories/components/Form/Button/Events/Events.stories.svelte.d.ts +18 -0
- package/dist/stories/components/Form/Button/utils/scss/mixins.scss +21 -21
- package/dist/stories/components/Form/FormControl/FormControl.stories.svelte +27 -0
- package/dist/stories/components/Form/FormControl/FormControl.stories.svelte.d.ts +19 -0
- package/dist/stories/components/Form/FormControl/FormControl.svelte +34 -0
- package/dist/stories/components/Form/FormControl/FormControl.svelte.d.ts +20 -0
- package/dist/stories/components/Form/Label/Label.stories.svelte +21 -0
- package/dist/stories/components/Form/Label/Label.stories.svelte.d.ts +19 -0
- package/dist/stories/components/Form/Label/Label.svelte +19 -0
- package/dist/stories/components/Form/Label/Label.svelte.d.ts +18 -0
- package/dist/stories/components/Form/Message/Message.stories.svelte +46 -0
- package/dist/stories/components/Form/Message/Message.stories.svelte.d.ts +19 -0
- package/dist/stories/components/Form/Message/Message.svelte +39 -0
- package/dist/stories/components/Form/Message/Message.svelte.d.ts +17 -0
- package/dist/stories/components/Form/PasswordInput/Events/Events.stories.svelte +168 -0
- package/dist/stories/components/Form/PasswordInput/Events/Events.stories.svelte.d.ts +18 -0
- package/dist/stories/components/Form/PasswordInput/PasswordInput.stories.svelte +53 -0
- package/dist/stories/components/Form/PasswordInput/PasswordInput.stories.svelte.d.ts +21 -0
- package/dist/stories/components/Form/PasswordInput/PasswordInput.svelte +196 -0
- package/dist/stories/components/Form/PasswordInput/PasswordInput.svelte.d.ts +63 -0
- package/dist/stories/components/Form/PasswordInput/Roundness/Roundness.stories.svelte +20 -0
- package/dist/stories/components/Form/{ExampleButton/ExampleButton.stories.svelte.d.ts → PasswordInput/Roundness/Roundness.stories.svelte.d.ts} +3 -4
- package/dist/stories/components/Form/PasswordInput/Size/Size.stories.svelte +16 -0
- package/dist/stories/components/Form/PasswordInput/Size/Size.stories.svelte.d.ts +26 -0
- package/dist/stories/components/Form/PasswordInput/WithIcon/WithIcon.stories.svelte +31 -0
- package/dist/stories/components/Form/PasswordInput/WithIcon/WithIcon.stories.svelte.d.ts +26 -0
- package/dist/stories/components/Form/TextInput/Events/Events.stories.svelte +148 -0
- package/dist/stories/components/Form/TextInput/Events/Events.stories.svelte.d.ts +18 -0
- package/dist/stories/components/Form/TextInput/Roundness/Roundness.stories.svelte +21 -0
- package/dist/stories/components/Form/TextInput/Roundness/Roundness.stories.svelte.d.ts +26 -0
- package/dist/stories/components/Form/TextInput/Size/Size.stories.svelte +17 -0
- package/dist/stories/components/Form/TextInput/Size/Size.stories.svelte.d.ts +26 -0
- package/dist/stories/components/Form/TextInput/TextInput.stories.svelte +37 -0
- package/dist/stories/components/Form/TextInput/TextInput.stories.svelte.d.ts +21 -0
- package/dist/stories/components/Form/TextInput/TextInput.svelte +168 -0
- package/dist/stories/components/Form/TextInput/TextInput.svelte.d.ts +60 -0
- package/dist/stories/components/Form/TextInput/WithIcon/WithIcon.stories.svelte +47 -0
- package/dist/stories/components/Form/TextInput/WithIcon/WithIcon.stories.svelte.d.ts +26 -0
- package/dist/stories/developer tools/Intro.mdx +7 -0
- package/dist/stories/developer tools/components/UtilityButton/Size/Size.stories.svelte +27 -0
- package/dist/stories/developer tools/components/UtilityButton/Size/Size.stories.svelte.d.ts +26 -0
- package/dist/stories/developer tools/components/UtilityButton/UtilityButton.stories.svelte +29 -0
- package/dist/stories/developer tools/components/UtilityButton/UtilityButton.stories.svelte.d.ts +21 -0
- package/dist/stories/developer tools/components/UtilityButton/UtilityButton.svelte +79 -0
- package/dist/stories/developer tools/components/UtilityButton/UtilityButton.svelte.d.ts +26 -0
- package/dist/styles/_components.css +8 -7
- package/dist/styles/_minimal-reset.css +3 -0
- package/dist/styles/global.css +1 -0
- package/package.json +30 -30
- package/src/lib/index.ts +26 -0
- package/src/lib/stories/components/Form/Button/Button.stories.svelte +10 -5
- package/src/lib/stories/components/Form/Button/Button.svelte +40 -24
- package/src/lib/stories/components/Form/Button/Events/Events.stories.svelte +42 -0
- package/src/lib/stories/components/Form/Button/utils/scss/mixins.scss +21 -21
- package/src/lib/stories/components/Form/FormControl/FormControl.stories.svelte +29 -0
- package/src/lib/stories/components/Form/FormControl/FormControl.svelte +67 -0
- package/src/lib/stories/components/Form/Label/Label.stories.svelte +23 -0
- package/src/lib/stories/components/Form/Label/Label.svelte +45 -0
- package/src/lib/stories/components/Form/Message/Message.stories.svelte +48 -0
- package/src/lib/stories/components/Form/Message/Message.svelte +71 -0
- package/src/lib/stories/components/Form/PasswordInput/Events/Events.stories.svelte +174 -0
- package/src/lib/stories/components/Form/PasswordInput/PasswordInput.stories.svelte +57 -0
- package/src/lib/stories/components/Form/PasswordInput/PasswordInput.svelte +338 -0
- package/src/lib/stories/components/Form/PasswordInput/Roundness/Roundness.stories.svelte +20 -0
- package/src/lib/stories/components/Form/PasswordInput/Size/Size.stories.svelte +16 -0
- package/src/lib/stories/components/Form/PasswordInput/WithIcon/WithIcon.stories.svelte +31 -0
- package/src/lib/stories/components/Form/TextInput/Events/Events.stories.svelte +153 -0
- package/src/lib/stories/components/Form/TextInput/Roundness/Roundness.stories.svelte +21 -0
- package/src/lib/stories/components/Form/TextInput/Size/Size.stories.svelte +17 -0
- package/src/lib/stories/components/Form/TextInput/TextInput.stories.svelte +41 -0
- package/src/lib/stories/components/Form/TextInput/TextInput.svelte +301 -0
- package/src/lib/stories/components/Form/TextInput/WithIcon/WithIcon.stories.svelte +47 -0
- package/src/lib/stories/developer tools/Intro.mdx +7 -0
- package/src/lib/stories/developer tools/components/UtilityButton/Size/Size.stories.svelte +27 -0
- package/src/lib/stories/developer tools/components/UtilityButton/UtilityButton.stories.svelte +33 -0
- package/src/lib/stories/developer tools/components/UtilityButton/UtilityButton.svelte +128 -0
- package/src/lib/styles/_components.css +8 -7
- package/src/lib/styles/_minimal-reset.css +3 -0
- package/src/lib/styles/global.css +1 -0
- package/dist/stories/components/Form/ExampleButton/ExampleButton.stories.svelte +0 -30
- package/dist/stories/components/Form/ExampleButton/ExampleButton.svelte +0 -14
- package/dist/stories/components/Form/ExampleButton/ExampleButton.svelte.d.ts +0 -16
- package/dist/stories/components/Form/ExampleButton/button.css +0 -30
- package/src/lib/stories/components/Form/ExampleButton/ExampleButton.stories.svelte +0 -30
- package/src/lib/stories/components/Form/ExampleButton/ExampleButton.svelte +0 -29
- package/src/lib/stories/components/Form/ExampleButton/button.css +0 -30
package/dist/styles/global.css
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flightlesslabs/dodo-ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"build": "vite build && pnpm run prepack",
|
|
6
6
|
"preview": "vite preview",
|
|
@@ -48,42 +48,42 @@
|
|
|
48
48
|
"svelte": "^5.0.0"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
|
-
"@chromatic-com/storybook": "^3",
|
|
52
|
-
"@eslint/compat": "^1.2.
|
|
53
|
-
"@eslint/js": "^9.
|
|
54
|
-
"@storybook/addon-essentials": "^8.6.
|
|
55
|
-
"@storybook/addon-svelte-csf": "
|
|
56
|
-
"@storybook/blocks": "^8.6.
|
|
57
|
-
"@storybook/experimental-addon-test": "^8.6.
|
|
51
|
+
"@chromatic-com/storybook": "^3.2.6",
|
|
52
|
+
"@eslint/compat": "^1.2.8",
|
|
53
|
+
"@eslint/js": "^9.24.0",
|
|
54
|
+
"@storybook/addon-essentials": "^8.6.12",
|
|
55
|
+
"@storybook/addon-svelte-csf": "5.0.0-next.28",
|
|
56
|
+
"@storybook/blocks": "^8.6.12",
|
|
57
|
+
"@storybook/experimental-addon-test": "^8.6.12",
|
|
58
58
|
"@storybook/manager-api": "^8.6.12",
|
|
59
|
-
"@storybook/svelte": "^8.6.
|
|
60
|
-
"@storybook/sveltekit": "^8.6.
|
|
61
|
-
"@storybook/test": "^8.6.
|
|
59
|
+
"@storybook/svelte": "^8.6.12",
|
|
60
|
+
"@storybook/sveltekit": "^8.6.12",
|
|
61
|
+
"@storybook/test": "^8.6.12",
|
|
62
62
|
"@storybook/theming": "^8.6.12",
|
|
63
|
-
"@sveltejs/adapter-
|
|
64
|
-
"@sveltejs/kit": "^2.
|
|
65
|
-
"@sveltejs/package": "^2.
|
|
66
|
-
"@sveltejs/vite-plugin-svelte": "^5.0.
|
|
67
|
-
"@vitest/browser": "^3.
|
|
68
|
-
"@vitest/coverage-v8": "^3.
|
|
69
|
-
"eslint": "^9.
|
|
70
|
-
"eslint-config-prettier": "^10.
|
|
71
|
-
"eslint-plugin-svelte": "^3.
|
|
63
|
+
"@sveltejs/adapter-static": "^3.0.8",
|
|
64
|
+
"@sveltejs/kit": "^2.20.5",
|
|
65
|
+
"@sveltejs/package": "^2.3.10",
|
|
66
|
+
"@sveltejs/vite-plugin-svelte": "^5.0.3",
|
|
67
|
+
"@vitest/browser": "^3.1.1",
|
|
68
|
+
"@vitest/coverage-v8": "^3.1.1",
|
|
69
|
+
"eslint": "^9.24.0",
|
|
70
|
+
"eslint-config-prettier": "^10.1.1",
|
|
71
|
+
"eslint-plugin-svelte": "^3.5.1",
|
|
72
72
|
"globals": "^16.0.0",
|
|
73
73
|
"playwright": "^1.51.1",
|
|
74
|
-
"prettier": "^3.
|
|
74
|
+
"prettier": "^3.5.3",
|
|
75
75
|
"prettier-plugin-svelte": "^3.3.3",
|
|
76
|
-
"publint": "^0.3.
|
|
77
|
-
"sass": "^1.86.
|
|
78
|
-
"storybook": "^8.6.
|
|
76
|
+
"publint": "^0.3.11",
|
|
77
|
+
"sass": "^1.86.3",
|
|
78
|
+
"storybook": "^8.6.12",
|
|
79
79
|
"storybook-dark-mode": "^4.0.2",
|
|
80
|
-
"svelte": "^5.
|
|
81
|
-
"svelte-check": "^4.
|
|
80
|
+
"svelte": "^5.25.10",
|
|
81
|
+
"svelte-check": "^4.1.5",
|
|
82
82
|
"svelte-preprocess": "^6.0.3",
|
|
83
|
-
"typescript": "^5.
|
|
84
|
-
"typescript-eslint": "^8.
|
|
85
|
-
"vite": "^6.
|
|
86
|
-
"vitest": "^3.
|
|
83
|
+
"typescript": "^5.8.3",
|
|
84
|
+
"typescript-eslint": "^8.29.1",
|
|
85
|
+
"vite": "^6.2.5",
|
|
86
|
+
"vitest": "^3.1.1"
|
|
87
87
|
},
|
|
88
88
|
"keywords": [
|
|
89
89
|
"svelte"
|
package/src/lib/index.ts
CHANGED
|
@@ -2,6 +2,9 @@ import '$lib/styles/global.css';
|
|
|
2
2
|
|
|
3
3
|
export type { ComponentSize, ComponentRoundness, ComponentRoundnessFull } from './types.js';
|
|
4
4
|
|
|
5
|
+
/** developer tools: components: UtilityButton */
|
|
6
|
+
export { default as UtilityButton } from '$lib/stories/developer tools/components/UtilityButton/UtilityButton.svelte';
|
|
7
|
+
|
|
5
8
|
/** Form: Button */
|
|
6
9
|
export { default as Button } from '$lib/stories/components/Form/Button/Button.svelte';
|
|
7
10
|
export type {
|
|
@@ -10,3 +13,26 @@ export type {
|
|
|
10
13
|
ButtonLinkTarget,
|
|
11
14
|
ButtonLinkReferrerpolicy,
|
|
12
15
|
} from '$lib/stories/components/Form/Button/Button.svelte';
|
|
16
|
+
|
|
17
|
+
/** Form: TextInput */
|
|
18
|
+
export { default as TextInput } from '$lib/stories/components/Form/TextInput/TextInput.svelte';
|
|
19
|
+
export type {
|
|
20
|
+
TextInputRoundness,
|
|
21
|
+
TextInputType,
|
|
22
|
+
TextInputFocusEvent,
|
|
23
|
+
TextInputClipboardEvent,
|
|
24
|
+
} from '$lib/stories/components/Form/TextInput/TextInput.svelte';
|
|
25
|
+
|
|
26
|
+
/** Form: PasswordInput */
|
|
27
|
+
export { default as PasswordInput } from '$lib/stories/components/Form/PasswordInput/PasswordInput.svelte';
|
|
28
|
+
export type { PasswordInputToggleEvent } from '$lib/stories/components/Form/PasswordInput/PasswordInput.svelte';
|
|
29
|
+
|
|
30
|
+
/** Form: Label */
|
|
31
|
+
export { default as Label } from '$lib/stories/components/Form/Label/Label.svelte';
|
|
32
|
+
|
|
33
|
+
/** Form: FormControl */
|
|
34
|
+
export { default as FormControl } from '$lib/stories/components/Form/FormControl/FormControl.svelte';
|
|
35
|
+
|
|
36
|
+
/** Form: Message */
|
|
37
|
+
export { default as Message } from '$lib/stories/components/Form/Message/Message.svelte';
|
|
38
|
+
export type { MessageColor } from '$lib/stories/components/Form/Message/Message.svelte';
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
},
|
|
20
20
|
roundness: {
|
|
21
21
|
control: { type: 'select' },
|
|
22
|
-
options: [false,
|
|
22
|
+
options: [false, '1x', '2x', '3x', 'full'],
|
|
23
23
|
},
|
|
24
24
|
size: {
|
|
25
25
|
control: { type: 'select' },
|
|
@@ -54,20 +54,25 @@
|
|
|
54
54
|
<Button>Click me!</Button>
|
|
55
55
|
</Story>
|
|
56
56
|
|
|
57
|
-
<Story name="Disabled" args={{ disabled: true }}>
|
|
58
|
-
<Button disabled>Click me!</Button>
|
|
59
|
-
</Story>
|
|
60
|
-
|
|
61
57
|
<!-- Button with border around it -->
|
|
62
58
|
<Story name="Outline" args={{ outline: true }}>
|
|
63
59
|
<Button outline>Click me!</Button>
|
|
64
60
|
</Story>
|
|
65
61
|
|
|
62
|
+
<Story name="Disabled" args={{ disabled: true }}>
|
|
63
|
+
<Button disabled>Click me!</Button>
|
|
64
|
+
</Story>
|
|
65
|
+
|
|
66
66
|
<!-- Form submit button -->
|
|
67
67
|
<Story name="Sumbit Button" args={{ type: 'submit' }}>
|
|
68
68
|
<Button type="submit">Submit Form</Button>
|
|
69
69
|
</Story>
|
|
70
70
|
|
|
71
|
+
<!-- Form submit button -->
|
|
72
|
+
<Story name="Full width Button" args={{ fullWidth: true }}>
|
|
73
|
+
<Button fullWidth>Click me!</Button>
|
|
74
|
+
</Story>
|
|
75
|
+
|
|
71
76
|
<!-- Anchor Link styled like a Button -->
|
|
72
77
|
<Story
|
|
73
78
|
name="Link Button"
|
|
@@ -15,14 +15,19 @@
|
|
|
15
15
|
<script lang="ts">
|
|
16
16
|
import type { ComponentRoundness, ComponentRoundnessFull, ComponentSize } from '$lib/types.js';
|
|
17
17
|
import type { Snippet } from 'svelte';
|
|
18
|
+
import type { MouseEventHandler } from 'svelte/elements';
|
|
18
19
|
|
|
19
20
|
interface ButtonProps {
|
|
20
|
-
/** Button contents goes here*/
|
|
21
|
+
/** Button contents goes here */
|
|
21
22
|
children?: Snippet;
|
|
23
|
+
/** Button ref */
|
|
24
|
+
ref?: HTMLButtonElement | HTMLAnchorElement;
|
|
22
25
|
/** Regular button or submit button? */
|
|
23
26
|
type?: 'button' | 'submit';
|
|
24
27
|
/** How large should the button be? */
|
|
25
28
|
size?: ComponentSize;
|
|
29
|
+
/** Full width button? */
|
|
30
|
+
fullWidth?: boolean;
|
|
26
31
|
/** What color to use? */
|
|
27
32
|
color?: ButtonColor;
|
|
28
33
|
/** How round should the border radius be? */
|
|
@@ -48,7 +53,7 @@
|
|
|
48
53
|
/** Custom css class*/
|
|
49
54
|
class?: string;
|
|
50
55
|
/** The onclick event handler */
|
|
51
|
-
onclick?:
|
|
56
|
+
onclick?: MouseEventHandler<HTMLButtonElement>;
|
|
52
57
|
/** Turn Button into link */
|
|
53
58
|
href?: string;
|
|
54
59
|
/** Link button: download */
|
|
@@ -72,7 +77,7 @@
|
|
|
72
77
|
_unsafeChildrenStringForTesting?: string;
|
|
73
78
|
}
|
|
74
79
|
|
|
75
|
-
|
|
80
|
+
let {
|
|
76
81
|
children,
|
|
77
82
|
type = 'button',
|
|
78
83
|
size = 'normal',
|
|
@@ -81,6 +86,7 @@
|
|
|
81
86
|
variant = 'text',
|
|
82
87
|
outline = false,
|
|
83
88
|
compact = false,
|
|
89
|
+
fullWidth = false,
|
|
84
90
|
name,
|
|
85
91
|
id,
|
|
86
92
|
title,
|
|
@@ -99,12 +105,13 @@
|
|
|
99
105
|
anchorMediaType,
|
|
100
106
|
referrerpolicy,
|
|
101
107
|
_unsafeChildrenStringForTesting,
|
|
108
|
+
ref = $bindable<HTMLButtonElement | HTMLAnchorElement>(),
|
|
102
109
|
}: ButtonProps = $props();
|
|
103
110
|
</script>
|
|
104
111
|
|
|
105
112
|
{#snippet buttonContent()}
|
|
106
113
|
{#if before}
|
|
107
|
-
<span class="
|
|
114
|
+
<span class="content--before">
|
|
108
115
|
{@render before()}
|
|
109
116
|
</span>
|
|
110
117
|
{/if}
|
|
@@ -116,7 +123,7 @@
|
|
|
116
123
|
{/if}
|
|
117
124
|
|
|
118
125
|
{#if after}
|
|
119
|
-
<span class="
|
|
126
|
+
<span class="content--after">
|
|
120
127
|
{@render after()}
|
|
121
128
|
</span>
|
|
122
129
|
{/if}
|
|
@@ -138,14 +145,16 @@
|
|
|
138
145
|
class:outline
|
|
139
146
|
class:compact
|
|
140
147
|
class:disabled
|
|
148
|
+
class:fullWidth
|
|
141
149
|
class={[
|
|
142
|
-
'dodo-ui-
|
|
150
|
+
'dodo-ui-Button',
|
|
143
151
|
`size--${size}`,
|
|
144
152
|
`color--${color}`,
|
|
145
153
|
`variant--${variant}`,
|
|
146
154
|
`roundness--${roundness}`,
|
|
147
155
|
className,
|
|
148
156
|
].join(' ')}
|
|
157
|
+
bind:this={ref}
|
|
149
158
|
>
|
|
150
159
|
{@render buttonContent()}
|
|
151
160
|
</a>
|
|
@@ -153,8 +162,9 @@
|
|
|
153
162
|
<button
|
|
154
163
|
class:outline
|
|
155
164
|
class:compact
|
|
165
|
+
class:fullWidth
|
|
156
166
|
class={[
|
|
157
|
-
'dodo-ui-
|
|
167
|
+
'dodo-ui-Button',
|
|
158
168
|
`size--${size}`,
|
|
159
169
|
`color--${color}`,
|
|
160
170
|
`variant--${variant}`,
|
|
@@ -167,6 +177,7 @@
|
|
|
167
177
|
{title}
|
|
168
178
|
{disabled}
|
|
169
179
|
{onclick}
|
|
180
|
+
bind:this={ref}
|
|
170
181
|
>
|
|
171
182
|
{@render buttonContent()}
|
|
172
183
|
</button>
|
|
@@ -176,8 +187,8 @@
|
|
|
176
187
|
@use 'utils/scss/mixins.scss' as *;
|
|
177
188
|
|
|
178
189
|
:global(:root) {
|
|
179
|
-
--dodo-ui-
|
|
180
|
-
--dodo-ui-
|
|
190
|
+
--dodo-ui-Button-disabled-color: var(--dodo-color-default-400);
|
|
191
|
+
--dodo-ui-Button-disabled-bg: var(--dodo-color-default-200);
|
|
181
192
|
|
|
182
193
|
@include generate-dodo-ui-button-colors(default);
|
|
183
194
|
@include generate-dodo-ui-button-colors(primary);
|
|
@@ -188,8 +199,8 @@
|
|
|
188
199
|
}
|
|
189
200
|
|
|
190
201
|
:global(.dodo-theme--dark) {
|
|
191
|
-
--dodo-ui-
|
|
192
|
-
--dodo-ui-
|
|
202
|
+
--dodo-ui-Button-disabled-bg: var(--dodo-color-default-100);
|
|
203
|
+
--dodo-ui-Button-disabled-color: var(--dodo-color-default-500);
|
|
193
204
|
|
|
194
205
|
@include generate-dodo-ui-button-colors-dark(default);
|
|
195
206
|
@include generate-dodo-ui-button-colors-dark(primary);
|
|
@@ -199,7 +210,7 @@
|
|
|
199
210
|
@include generate-dodo-ui-button-colors-dark(info);
|
|
200
211
|
}
|
|
201
212
|
|
|
202
|
-
.dodo-ui-
|
|
213
|
+
.dodo-ui-Button {
|
|
203
214
|
cursor: pointer;
|
|
204
215
|
outline: none;
|
|
205
216
|
transition: all 150ms;
|
|
@@ -209,13 +220,14 @@
|
|
|
209
220
|
justify-content: center;
|
|
210
221
|
align-items: center;
|
|
211
222
|
font-family: inherit;
|
|
212
|
-
font-weight: 500;
|
|
213
223
|
background-color: transparent;
|
|
214
|
-
border:
|
|
224
|
+
border-style: solid;
|
|
225
|
+
border-width: var(--dodo-ui-element-border-width);
|
|
215
226
|
border-color: transparent;
|
|
216
227
|
outline: 0;
|
|
217
228
|
color: inherit;
|
|
218
229
|
letter-spacing: 0.3px;
|
|
230
|
+
font-family: inherit;
|
|
219
231
|
|
|
220
232
|
&.size {
|
|
221
233
|
&--normal {
|
|
@@ -242,15 +254,15 @@
|
|
|
242
254
|
|
|
243
255
|
&.roundness {
|
|
244
256
|
&--1x {
|
|
245
|
-
border-radius: var(--dodo-ui-element-roundness-
|
|
257
|
+
border-radius: var(--dodo-ui-element-roundness-1x);
|
|
246
258
|
}
|
|
247
259
|
|
|
248
260
|
&--2x {
|
|
249
|
-
border-radius: var(--dodo-ui-element-roundness-
|
|
261
|
+
border-radius: var(--dodo-ui-element-roundness-2x);
|
|
250
262
|
}
|
|
251
263
|
|
|
252
264
|
&--3x {
|
|
253
|
-
border-radius: var(--dodo-ui-element-roundness-
|
|
265
|
+
border-radius: var(--dodo-ui-element-roundness-3x);
|
|
254
266
|
}
|
|
255
267
|
|
|
256
268
|
&--full {
|
|
@@ -273,17 +285,17 @@
|
|
|
273
285
|
&.variant {
|
|
274
286
|
&--text,
|
|
275
287
|
&--solid {
|
|
276
|
-
background-color: var(--dodo-ui-
|
|
277
|
-
color: var(--dodo-ui-
|
|
288
|
+
background-color: var(--dodo-ui-Button-disabled-bg);
|
|
289
|
+
color: var(--dodo-ui-Button-disabled-color);
|
|
278
290
|
|
|
279
291
|
&:hover {
|
|
280
|
-
background-color: var(--dodo-ui-
|
|
281
|
-
color: var(--dodo-ui-
|
|
292
|
+
background-color: var(--dodo-ui-Button-disabled-bg);
|
|
293
|
+
color: var(--dodo-ui-Button-disabled-color);
|
|
282
294
|
}
|
|
283
295
|
|
|
284
296
|
&:active {
|
|
285
|
-
background-color: var(--dodo-ui-
|
|
286
|
-
color: var(--dodo-ui-
|
|
297
|
+
background-color: var(--dodo-ui-Button-disabled-bg);
|
|
298
|
+
color: var(--dodo-ui-Button-disabled-color);
|
|
287
299
|
}
|
|
288
300
|
|
|
289
301
|
&.outline {
|
|
@@ -316,7 +328,11 @@
|
|
|
316
328
|
}
|
|
317
329
|
}
|
|
318
330
|
|
|
319
|
-
|
|
331
|
+
&.fullWidth {
|
|
332
|
+
width: 100%;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
.content {
|
|
320
336
|
&--after,
|
|
321
337
|
&--before {
|
|
322
338
|
display: inline-flex;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
+
import { fn } from '@storybook/test';
|
|
4
|
+
import Button from '../Button.svelte';
|
|
5
|
+
import { storyButtonArgTypes } from '../Button.stories.svelte';
|
|
6
|
+
|
|
7
|
+
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories
|
|
8
|
+
const { Story } = defineMeta({
|
|
9
|
+
component: Button,
|
|
10
|
+
tags: ['autodocs'],
|
|
11
|
+
argTypes: storyButtonArgTypes,
|
|
12
|
+
args: {
|
|
13
|
+
onclick: fn(),
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
</script>
|
|
17
|
+
|
|
18
|
+
<Story
|
|
19
|
+
name="Click"
|
|
20
|
+
args={{
|
|
21
|
+
outline: false,
|
|
22
|
+
disabled: false,
|
|
23
|
+
compact: false,
|
|
24
|
+
onclick: (e: Event) => {
|
|
25
|
+
const target = e.target as HTMLButtonElement;
|
|
26
|
+
|
|
27
|
+
alert('Button Clicked');
|
|
28
|
+
console.log('Button Clicked', target);
|
|
29
|
+
},
|
|
30
|
+
}}
|
|
31
|
+
>
|
|
32
|
+
<Button
|
|
33
|
+
onclick={(e: Event) => {
|
|
34
|
+
const target = e.target as HTMLButtonElement;
|
|
35
|
+
|
|
36
|
+
alert('Button Clicked');
|
|
37
|
+
console.log('Button Clicked', target);
|
|
38
|
+
}}
|
|
39
|
+
>
|
|
40
|
+
Click me!
|
|
41
|
+
</Button>
|
|
42
|
+
</Story>
|
|
@@ -3,15 +3,15 @@
|
|
|
3
3
|
/// across different interaction states (default, hover, active).
|
|
4
4
|
/// @param {String} $color-name - The theme color name (e.g., "primary", "safe", etc.)
|
|
5
5
|
@mixin generate-dodo-ui-button-colors($color-name) {
|
|
6
|
-
--dodo-ui-
|
|
6
|
+
--dodo-ui-Button-outline-#{$color-name}: var(--dodo-color-#{$color-name}-400);
|
|
7
7
|
|
|
8
|
-
--dodo-ui-
|
|
9
|
-
--dodo-ui-
|
|
10
|
-
--dodo-ui-
|
|
8
|
+
--dodo-ui-Button-text-#{$color-name}-bg: var(--dodo-color-#{$color-name}-100);
|
|
9
|
+
--dodo-ui-Button-text-#{$color-name}-hover-bg: var(--dodo-color-#{$color-name}-200);
|
|
10
|
+
--dodo-ui-Button-text-#{$color-name}-active-bg: var(--dodo-color-#{$color-name}-300);
|
|
11
11
|
|
|
12
|
-
--dodo-ui-
|
|
13
|
-
--dodo-ui-
|
|
14
|
-
--dodo-ui-
|
|
12
|
+
--dodo-ui-Button-solid-#{$color-name}-bg: var(--dodo-color-#{$color-name}-500);
|
|
13
|
+
--dodo-ui-Button-solid-#{$color-name}-hover-bg: var(--dodo-color-#{$color-name}-600);
|
|
14
|
+
--dodo-ui-Button-solid-#{$color-name}-active-bg: var(--dodo-color-#{$color-name}-700);
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
/// Mixin: generate-dodo-ui-button-colors
|
|
@@ -19,15 +19,15 @@
|
|
|
19
19
|
/// across different interaction states (default, hover, active).
|
|
20
20
|
/// @param {String} $color-name - The theme color name (e.g., "primary", "safe", etc.)
|
|
21
21
|
@mixin generate-dodo-ui-button-colors-dark($color-name) {
|
|
22
|
-
--dodo-ui-
|
|
22
|
+
--dodo-ui-Button-outline-#{$color-name}: var(--dodo-color-#{$color-name}-300);
|
|
23
23
|
|
|
24
|
-
--dodo-ui-
|
|
25
|
-
--dodo-ui-
|
|
26
|
-
--dodo-ui-
|
|
24
|
+
--dodo-ui-Button-text-#{$color-name}-bg: var(--dodo-color-#{$color-name}-50);
|
|
25
|
+
--dodo-ui-Button-text-#{$color-name}-hover-bg: var(--dodo-color-#{$color-name}-100);
|
|
26
|
+
--dodo-ui-Button-text-#{$color-name}-active-bg: var(--dodo-color-#{$color-name}-200);
|
|
27
27
|
|
|
28
|
-
--dodo-ui-
|
|
29
|
-
--dodo-ui-
|
|
30
|
-
--dodo-ui-
|
|
28
|
+
--dodo-ui-Button-solid-#{$color-name}-bg: var(--dodo-color-#{$color-name}-300);
|
|
29
|
+
--dodo-ui-Button-solid-#{$color-name}-hover-bg: var(--dodo-color-#{$color-name}-200);
|
|
30
|
+
--dodo-ui-Button-solid-#{$color-name}-active-bg: var(--dodo-color-#{$color-name}-100);
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
/// Mixin: generate-dodo-ui-button-color
|
|
@@ -38,31 +38,31 @@
|
|
|
38
38
|
&.variant {
|
|
39
39
|
&--text {
|
|
40
40
|
color: var(--dodo-color-#{$theme}-800);
|
|
41
|
-
background-color: var(--dodo-ui-
|
|
41
|
+
background-color: var(--dodo-ui-Button-text-#{$theme}-bg);
|
|
42
42
|
|
|
43
43
|
&:hover {
|
|
44
|
-
background-color: var(--dodo-ui-
|
|
44
|
+
background-color: var(--dodo-ui-Button-text-#{$theme}-hover-bg);
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
&:active {
|
|
48
|
-
background-color: var(--dodo-ui-
|
|
48
|
+
background-color: var(--dodo-ui-Button-text-#{$theme}-active-bg);
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
&.outline {
|
|
52
|
-
border-color: var(--dodo-ui-
|
|
52
|
+
border-color: var(--dodo-ui-Button-outline-#{$theme});
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
&--solid {
|
|
57
57
|
color: var(--dodo-color-constant-white);
|
|
58
|
-
background-color: var(--dodo-ui-
|
|
58
|
+
background-color: var(--dodo-ui-Button-solid-#{$theme}-bg);
|
|
59
59
|
|
|
60
60
|
&:hover {
|
|
61
|
-
background-color: var(--dodo-ui-
|
|
61
|
+
background-color: var(--dodo-ui-Button-solid-#{$theme}-hover-bg);
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
&:active {
|
|
65
|
-
background-color: var(--dodo-ui-
|
|
65
|
+
background-color: var(--dodo-ui-Button-solid-#{$theme}-active-bg);
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
68
|
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
+
import FormControl from './FormControl.svelte';
|
|
4
|
+
import TextInput from '../TextInput/TextInput.svelte';
|
|
5
|
+
|
|
6
|
+
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories
|
|
7
|
+
const { Story } = defineMeta({
|
|
8
|
+
component: FormControl,
|
|
9
|
+
tags: ['autodocs'],
|
|
10
|
+
});
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<Story name="Default" args={{ label: 'Hello there' }} />
|
|
14
|
+
|
|
15
|
+
<Story name="Example TextInput" args={{ label: 'Whats your first name?' }}>
|
|
16
|
+
<FormControl label="Whats your first name?" for="first-name-01">
|
|
17
|
+
<TextInput placeholder="First name" id="first-name-01" />
|
|
18
|
+
</FormControl>
|
|
19
|
+
</Story>
|
|
20
|
+
|
|
21
|
+
<Story name="ErrorMessage" args={{ label: 'Whats your first name?' }}>
|
|
22
|
+
<FormControl
|
|
23
|
+
label="Whats your first name?"
|
|
24
|
+
for="first-name-02"
|
|
25
|
+
errorMessage="This is an error message"
|
|
26
|
+
>
|
|
27
|
+
<TextInput value="John Smith" id="first-name-02" error />
|
|
28
|
+
</FormControl>
|
|
29
|
+
</Story>
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
import Label from '../Label/Label.svelte';
|
|
4
|
+
import Message from '../Message/Message.svelte';
|
|
5
|
+
|
|
6
|
+
interface FormControlProps {
|
|
7
|
+
/** FormControl contents goes here */
|
|
8
|
+
children?: Snippet;
|
|
9
|
+
/** Label for FormControl */
|
|
10
|
+
label?: string;
|
|
11
|
+
/** is there any associated Error Message ? */
|
|
12
|
+
errorMessage?: string;
|
|
13
|
+
/** Label ref */
|
|
14
|
+
ref?: HTMLDivElement;
|
|
15
|
+
/** id of the form element the label should be bound to */
|
|
16
|
+
for?: string;
|
|
17
|
+
/** Specifies which form the label belongs to */
|
|
18
|
+
form?: string;
|
|
19
|
+
/** Custom css class*/
|
|
20
|
+
class?: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
let {
|
|
24
|
+
children,
|
|
25
|
+
label,
|
|
26
|
+
class: className = '',
|
|
27
|
+
for: htmlFor,
|
|
28
|
+
form,
|
|
29
|
+
ref = $bindable<HTMLDivElement>(),
|
|
30
|
+
errorMessage,
|
|
31
|
+
}: FormControlProps = $props();
|
|
32
|
+
</script>
|
|
33
|
+
|
|
34
|
+
<div class={['dodo-ui-FormControl', className].join(' ')} bind:this={ref}>
|
|
35
|
+
{#if label}
|
|
36
|
+
<div class="LabelSection">
|
|
37
|
+
<Label for={htmlFor} {form}>{label}</Label>
|
|
38
|
+
</div>
|
|
39
|
+
{/if}
|
|
40
|
+
<div class="content">
|
|
41
|
+
{#if children}
|
|
42
|
+
{@render children()}
|
|
43
|
+
{/if}
|
|
44
|
+
</div>
|
|
45
|
+
{#if errorMessage}
|
|
46
|
+
<div class="errorMessage">
|
|
47
|
+
<Message color="danger">{errorMessage}</Message>
|
|
48
|
+
</div>
|
|
49
|
+
{/if}
|
|
50
|
+
</div>
|
|
51
|
+
|
|
52
|
+
<style lang="scss">
|
|
53
|
+
:global(:root) {
|
|
54
|
+
--dodo-ui-FormControl-LabelSection-gap: 8px;
|
|
55
|
+
--dodo-ui-FormControl-errorMessage-gap: 16px;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.dodo-ui-FormControl {
|
|
59
|
+
.LabelSection {
|
|
60
|
+
margin-bottom: var(--dodo-ui-FormControl-LabelSection-gap);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.errorMessage {
|
|
64
|
+
margin-top: var(--dodo-ui-FormControl-errorMessage-gap);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
</style>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
+
import Label from './Label.svelte';
|
|
4
|
+
|
|
5
|
+
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories
|
|
6
|
+
const { Story } = defineMeta({
|
|
7
|
+
component: Label,
|
|
8
|
+
tags: ['autodocs'],
|
|
9
|
+
});
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<!-- ⚠️ Test Label: Do not use! -->
|
|
13
|
+
<Story
|
|
14
|
+
name="Test Label"
|
|
15
|
+
args={{
|
|
16
|
+
_unsafeChildrenStringForTesting: 'This is a form label',
|
|
17
|
+
}}
|
|
18
|
+
/>
|
|
19
|
+
|
|
20
|
+
<!-- Label with default style -->
|
|
21
|
+
<Story name="Default">
|
|
22
|
+
<Label>This is a form label</Label>
|
|
23
|
+
</Story>
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
|
|
4
|
+
interface LabelProps {
|
|
5
|
+
/** Label contents goes here */
|
|
6
|
+
children?: Snippet;
|
|
7
|
+
/** Label ref */
|
|
8
|
+
ref?: HTMLLabelElement;
|
|
9
|
+
/** id of the form element the label should be bound to */
|
|
10
|
+
for?: string;
|
|
11
|
+
/** Specifies which form the label belongs to */
|
|
12
|
+
form?: string;
|
|
13
|
+
/** Custom css class*/
|
|
14
|
+
class?: string;
|
|
15
|
+
/** Test: ⚠️ Unsafe Children String. Do Not use*/
|
|
16
|
+
_unsafeChildrenStringForTesting?: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
let {
|
|
20
|
+
children,
|
|
21
|
+
class: className = '',
|
|
22
|
+
for: htmlFor,
|
|
23
|
+
form,
|
|
24
|
+
_unsafeChildrenStringForTesting,
|
|
25
|
+
ref = $bindable<HTMLLabelElement>(),
|
|
26
|
+
}: LabelProps = $props();
|
|
27
|
+
</script>
|
|
28
|
+
|
|
29
|
+
<label class={['dodo-ui-Label', className].join(' ')} for={htmlFor} {form} bind:this={ref}>
|
|
30
|
+
{#if children}
|
|
31
|
+
{@render children()}
|
|
32
|
+
{:else if _unsafeChildrenStringForTesting}
|
|
33
|
+
{_unsafeChildrenStringForTesting}
|
|
34
|
+
{/if}
|
|
35
|
+
</label>
|
|
36
|
+
|
|
37
|
+
<style lang="scss">
|
|
38
|
+
.dodo-ui-Label {
|
|
39
|
+
font-size: 0.95rem;
|
|
40
|
+
color: var(--dodo-color-default-700);
|
|
41
|
+
display: flex;
|
|
42
|
+
align-items: center;
|
|
43
|
+
font-family: inherit;
|
|
44
|
+
}
|
|
45
|
+
</style>
|