@flightlesslabs/dodo-ui 0.1.1 → 0.1.3
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 +3 -1
- package/dist/index.js +1 -0
- package/dist/stories/components/Form/Button/Button.stories.svelte +17 -5
- package/dist/stories/components/Form/Button/Button.stories.svelte.d.ts +2 -26
- package/dist/stories/components/Form/Button/Button.svelte +335 -4
- package/dist/stories/components/Form/Button/Button.svelte.d.ts +13 -5
- package/dist/stories/components/Form/Button/Color/Color.stories.svelte +42 -4
- package/dist/stories/components/Form/Button/IconButton/IconButton.stories.svelte +11 -5
- package/dist/stories/components/Form/Button/Roundness/Roundness.stories.svelte +46 -0
- package/dist/stories/components/Form/Button/Roundness/Roundness.stories.svelte.d.ts +26 -0
- package/dist/stories/components/Form/Button/Size/Size.stories.svelte +1 -4
- package/dist/stories/components/Form/Button/Variant/Variant.stories.svelte +1 -4
- package/dist/stories/components/Form/Button/utils/scss/mixins.scss +70 -0
- package/dist/storybook-types.d.ts +129 -0
- package/dist/storybook-types.js +1 -0
- package/dist/styles/_colors.css +171 -0
- package/dist/styles/_components.css +10 -0
- package/dist/styles/global.css +1 -0
- package/dist/types.d.ts +4 -1
- package/package.json +15 -13
- package/src/lib/index.ts +8 -1
- package/src/lib/stories/components/Form/Button/Button.stories.svelte +19 -6
- package/src/lib/stories/components/Form/Button/Button.svelte +197 -8
- package/src/lib/stories/components/Form/Button/Color/Color.stories.svelte +42 -4
- package/src/lib/stories/components/Form/Button/IconButton/IconButton.stories.svelte +11 -5
- package/src/lib/stories/components/Form/Button/Roundness/Roundness.stories.svelte +46 -0
- package/src/lib/stories/components/Form/Button/Size/Size.stories.svelte +1 -4
- package/src/lib/stories/components/Form/Button/Variant/Variant.stories.svelte +1 -4
- package/src/lib/stories/components/Form/Button/utils/scss/mixins.scss +70 -0
- package/src/lib/storybook-types.ts +182 -0
- package/src/lib/styles/_colors.css +171 -0
- package/src/lib/styles/_components.css +10 -0
- package/src/lib/styles/global.css +1 -0
- package/src/lib/types.ts +5 -1
- package/src/lib/stories/Getting Started.mdx +0 -13
- package/src/lib/stories/Home.mdx +0 -10
|
@@ -1,5 +1,19 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
export type ButtonColor = 'default' | 'primary' | 'safe' | 'warning' | 'danger' | 'info';
|
|
3
|
+
export type ButtonRoundness = ComponentRoundness | false | ComponentRoundnessFull;
|
|
4
|
+
export type ButtonLinkTarget =
|
|
5
|
+
| '_self'
|
|
6
|
+
| '_blank'
|
|
7
|
+
| '_parent'
|
|
8
|
+
| '_top'
|
|
9
|
+
| (string & {})
|
|
10
|
+
| undefined
|
|
11
|
+
| null;
|
|
12
|
+
export type ButtonLinkReferrerpolicy = ReferrerPolicy | undefined | null;
|
|
13
|
+
</script>
|
|
14
|
+
|
|
1
15
|
<script lang="ts">
|
|
2
|
-
import type { ComponentSize } from '$lib/types.js';
|
|
16
|
+
import type { ComponentRoundness, ComponentRoundnessFull, ComponentSize } from '$lib/types.js';
|
|
3
17
|
import type { Snippet } from 'svelte';
|
|
4
18
|
|
|
5
19
|
interface ButtonProps {
|
|
@@ -10,7 +24,9 @@
|
|
|
10
24
|
/** How large should the button be? */
|
|
11
25
|
size?: ComponentSize;
|
|
12
26
|
/** What color to use? */
|
|
13
|
-
color?:
|
|
27
|
+
color?: ButtonColor;
|
|
28
|
+
/** How round should the border radius be? */
|
|
29
|
+
roundness?: ButtonRoundness;
|
|
14
30
|
/** How should the button appear? */
|
|
15
31
|
variant?: 'text' | 'solid';
|
|
16
32
|
/** Add a border around the button */
|
|
@@ -34,8 +50,9 @@
|
|
|
34
50
|
/** The onclick event handler */
|
|
35
51
|
onclick?: (e: MouseEvent) => void;
|
|
36
52
|
/** Turn Button into link */
|
|
37
|
-
href?: string
|
|
53
|
+
href?: string;
|
|
38
54
|
/** Link button: download */
|
|
55
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
39
56
|
download?: any;
|
|
40
57
|
/** Link button: hreflang */
|
|
41
58
|
hreflang?: string | undefined | null;
|
|
@@ -46,18 +63,21 @@
|
|
|
46
63
|
/** Link button: rel */
|
|
47
64
|
rel?: string | undefined | null;
|
|
48
65
|
/** Link button: target */
|
|
49
|
-
target?:
|
|
66
|
+
target?: ButtonLinkTarget;
|
|
50
67
|
/** Link button: Type */
|
|
51
68
|
anchorMediaType?: string | undefined | null;
|
|
52
69
|
/** Link button: referrerpolicy */
|
|
53
|
-
referrerpolicy?:
|
|
70
|
+
referrerpolicy?: ButtonLinkReferrerpolicy;
|
|
71
|
+
/** Test: ⚠️ Unsafe Children String. Do Not use*/
|
|
72
|
+
_unsafeChildrenStringForTesting?: string;
|
|
54
73
|
}
|
|
55
74
|
|
|
56
75
|
const {
|
|
57
76
|
children,
|
|
58
77
|
type = 'button',
|
|
59
78
|
size = 'normal',
|
|
60
|
-
color = '
|
|
79
|
+
color = 'default',
|
|
80
|
+
roundness = 1,
|
|
61
81
|
variant = 'text',
|
|
62
82
|
outline = false,
|
|
63
83
|
compact = false,
|
|
@@ -78,6 +98,7 @@
|
|
|
78
98
|
target,
|
|
79
99
|
anchorMediaType,
|
|
80
100
|
referrerpolicy,
|
|
101
|
+
_unsafeChildrenStringForTesting,
|
|
81
102
|
}: ButtonProps = $props();
|
|
82
103
|
</script>
|
|
83
104
|
|
|
@@ -90,6 +111,8 @@
|
|
|
90
111
|
|
|
91
112
|
{#if children}
|
|
92
113
|
{@render children()}
|
|
114
|
+
{:else if _unsafeChildrenStringForTesting}
|
|
115
|
+
{_unsafeChildrenStringForTesting}
|
|
93
116
|
{/if}
|
|
94
117
|
|
|
95
118
|
{#if after}
|
|
@@ -116,10 +139,11 @@
|
|
|
116
139
|
class:compact
|
|
117
140
|
class:disabled
|
|
118
141
|
class={[
|
|
119
|
-
'dodo-button',
|
|
142
|
+
'dodo-ui-button',
|
|
120
143
|
`size--${size}`,
|
|
121
144
|
`color--${color}`,
|
|
122
145
|
`variant--${variant}`,
|
|
146
|
+
`roundness--${roundness}`,
|
|
123
147
|
className,
|
|
124
148
|
].join(' ')}
|
|
125
149
|
>
|
|
@@ -130,10 +154,11 @@
|
|
|
130
154
|
class:outline
|
|
131
155
|
class:compact
|
|
132
156
|
class={[
|
|
133
|
-
'dodo-button',
|
|
157
|
+
'dodo-ui-button',
|
|
134
158
|
`size--${size}`,
|
|
135
159
|
`color--${color}`,
|
|
136
160
|
`variant--${variant}`,
|
|
161
|
+
`roundness--${roundness}`,
|
|
137
162
|
className,
|
|
138
163
|
].join(' ')}
|
|
139
164
|
{type}
|
|
@@ -148,4 +173,168 @@
|
|
|
148
173
|
{/if}
|
|
149
174
|
|
|
150
175
|
<style lang="scss">
|
|
176
|
+
@use 'utils/scss/mixins.scss' as *;
|
|
177
|
+
|
|
178
|
+
:global(:root) {
|
|
179
|
+
--dodo-ui-button-disabled-color: var(--dodo-color-default-400);
|
|
180
|
+
--dodo-ui-button-disabled-bg: var(--dodo-color-default-200);
|
|
181
|
+
|
|
182
|
+
@include generate-dodo-ui-button-colors(default);
|
|
183
|
+
@include generate-dodo-ui-button-colors(primary);
|
|
184
|
+
@include generate-dodo-ui-button-colors(safe);
|
|
185
|
+
@include generate-dodo-ui-button-colors(warning);
|
|
186
|
+
@include generate-dodo-ui-button-colors(danger);
|
|
187
|
+
@include generate-dodo-ui-button-colors(info);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
:global(.dodo-theme--dark) {
|
|
191
|
+
--dodo-ui-button-disabled-bg: var(--dodo-color-default-100);
|
|
192
|
+
--dodo-ui-button-disabled-color: var(--dodo-color-default-500);
|
|
193
|
+
|
|
194
|
+
@include generate-dodo-ui-button-colors-dark(default);
|
|
195
|
+
@include generate-dodo-ui-button-colors-dark(primary);
|
|
196
|
+
@include generate-dodo-ui-button-colors-dark(safe);
|
|
197
|
+
@include generate-dodo-ui-button-colors-dark(warning);
|
|
198
|
+
@include generate-dodo-ui-button-colors-dark(danger);
|
|
199
|
+
@include generate-dodo-ui-button-colors-dark(info);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
.dodo-ui-button {
|
|
203
|
+
cursor: pointer;
|
|
204
|
+
outline: none;
|
|
205
|
+
transition: all 150ms;
|
|
206
|
+
text-decoration: none;
|
|
207
|
+
margin: 0;
|
|
208
|
+
display: inline-flex;
|
|
209
|
+
justify-content: center;
|
|
210
|
+
align-items: center;
|
|
211
|
+
font-family: inherit;
|
|
212
|
+
font-weight: 500;
|
|
213
|
+
background-color: transparent;
|
|
214
|
+
border: 1px solid;
|
|
215
|
+
border-color: transparent;
|
|
216
|
+
outline: 0;
|
|
217
|
+
color: inherit;
|
|
218
|
+
letter-spacing: 0.3px;
|
|
219
|
+
|
|
220
|
+
&.size {
|
|
221
|
+
&--normal {
|
|
222
|
+
height: var(--dodo-ui-element-height-normal);
|
|
223
|
+
font-size: 1rem;
|
|
224
|
+
padding: 0 12px;
|
|
225
|
+
min-width: 45px;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
&--small {
|
|
229
|
+
height: var(--dodo-ui-element-height-small);
|
|
230
|
+
padding: 0 8px;
|
|
231
|
+
font-size: 0.9rem;
|
|
232
|
+
min-width: 35px;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
&--large {
|
|
236
|
+
height: var(--dodo-ui-element-height-large);
|
|
237
|
+
font-size: 1.1rem;
|
|
238
|
+
padding: 0 16px;
|
|
239
|
+
min-width: 85px;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
&.roundness {
|
|
244
|
+
&--1 {
|
|
245
|
+
border-radius: var(--dodo-ui-element-roundness-1);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
&--2 {
|
|
249
|
+
border-radius: var(--dodo-ui-element-roundness-2);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
&--3 {
|
|
253
|
+
border-radius: var(--dodo-ui-element-roundness-3);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
&--4 {
|
|
257
|
+
border-radius: var(--dodo-ui-element-roundness-4);
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
&--full {
|
|
261
|
+
border-radius: 50%;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
&.color {
|
|
266
|
+
@include generate-dodo-ui-button-color(default);
|
|
267
|
+
@include generate-dodo-ui-button-color(primary);
|
|
268
|
+
@include generate-dodo-ui-button-color(safe);
|
|
269
|
+
@include generate-dodo-ui-button-color(warning);
|
|
270
|
+
@include generate-dodo-ui-button-color(danger);
|
|
271
|
+
@include generate-dodo-ui-button-color(info);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
&[disabled] {
|
|
275
|
+
cursor: initial;
|
|
276
|
+
|
|
277
|
+
&.variant {
|
|
278
|
+
&--text,
|
|
279
|
+
&--solid {
|
|
280
|
+
background-color: var(--dodo-ui-button-disabled-bg);
|
|
281
|
+
color: var(--dodo-ui-button-disabled-color);
|
|
282
|
+
|
|
283
|
+
&:hover {
|
|
284
|
+
background-color: var(--dodo-ui-button-disabled-bg);
|
|
285
|
+
color: var(--dodo-ui-button-disabled-color);
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
&:active {
|
|
289
|
+
background-color: var(--dodo-ui-button-disabled-bg);
|
|
290
|
+
color: var(--dodo-ui-button-disabled-color);
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
&.outline {
|
|
294
|
+
border-color: transparent;
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
&.compact {
|
|
301
|
+
&.size {
|
|
302
|
+
&--normal,
|
|
303
|
+
&--small,
|
|
304
|
+
&--large {
|
|
305
|
+
min-width: initial;
|
|
306
|
+
padding: 0;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
&--normal {
|
|
310
|
+
width: var(--dodo-ui-element-height-normal);
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
&--small {
|
|
314
|
+
width: var(--dodo-ui-element-height-small);
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
&--large {
|
|
318
|
+
width: var(--dodo-ui-element-height-large);
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
.button-content {
|
|
324
|
+
&--after,
|
|
325
|
+
&--before {
|
|
326
|
+
display: inline-flex;
|
|
327
|
+
height: 100%;
|
|
328
|
+
align-items: center;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
&--before {
|
|
332
|
+
margin-right: 6px;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
&--after {
|
|
336
|
+
margin-left: 6px;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
}
|
|
151
340
|
</style>
|
|
@@ -8,10 +8,7 @@
|
|
|
8
8
|
const { Story } = defineMeta({
|
|
9
9
|
component: Button,
|
|
10
10
|
tags: ['autodocs'],
|
|
11
|
-
|
|
12
|
-
argTypes: {
|
|
13
|
-
...storyButtonArgTypes,
|
|
14
|
-
},
|
|
11
|
+
argTypes: storyButtonArgTypes,
|
|
15
12
|
args: {
|
|
16
13
|
onclick: fn(),
|
|
17
14
|
},
|
|
@@ -26,3 +23,44 @@
|
|
|
26
23
|
<Story name="Warning" args={{ color: 'warning' }}><Button color="warning">Click me!</Button></Story>
|
|
27
24
|
<Story name="Danger" args={{ color: 'danger' }}><Button color="danger">Click me!</Button></Story>
|
|
28
25
|
<Story name="Info" args={{ color: 'info' }}><Button color="info">Click me!</Button></Story>
|
|
26
|
+
|
|
27
|
+
<Story
|
|
28
|
+
name="Default Solid"
|
|
29
|
+
args={{ outline: false, disabled: false, compact: false, variant: 'solid' }}
|
|
30
|
+
>
|
|
31
|
+
<Button variant="solid">Click me!</Button>
|
|
32
|
+
</Story>
|
|
33
|
+
<Story name="Primary Solid" args={{ color: 'primary', variant: 'solid' }}>
|
|
34
|
+
<Button color="primary" variant="solid">Click me!</Button>
|
|
35
|
+
</Story>
|
|
36
|
+
<Story name="Safe Solid" args={{ color: 'safe', variant: 'solid' }}>
|
|
37
|
+
<Button color="safe" variant="solid">Click me!</Button>
|
|
38
|
+
</Story>
|
|
39
|
+
<Story name="Warning Solid" args={{ color: 'warning', variant: 'solid' }}>
|
|
40
|
+
<Button color="warning" variant="solid">Click me!</Button>
|
|
41
|
+
</Story>
|
|
42
|
+
<Story name="Danger Solid" args={{ color: 'danger', variant: 'solid' }}>
|
|
43
|
+
<Button color="danger" variant="solid">Click me!</Button>
|
|
44
|
+
</Story>
|
|
45
|
+
<Story name="Info Solid" args={{ color: 'info', variant: 'solid' }}>
|
|
46
|
+
<Button color="info" variant="solid">Click me!</Button>
|
|
47
|
+
</Story>
|
|
48
|
+
|
|
49
|
+
<Story name="Default Outline" args={{ outline: true, disabled: false, compact: false }}>
|
|
50
|
+
<Button outline>Click me!</Button>
|
|
51
|
+
</Story>
|
|
52
|
+
<Story name="Primary Outline" args={{ outline: true, color: 'primary' }}>
|
|
53
|
+
<Button color="primary" outline>Click me!</Button>
|
|
54
|
+
</Story>
|
|
55
|
+
<Story name="Safe Outline" args={{ outline: true, color: 'safe' }}>
|
|
56
|
+
<Button color="safe" outline>Click me!</Button>
|
|
57
|
+
</Story>
|
|
58
|
+
<Story name="Warning Outline" args={{ outline: true, color: 'warning' }}>
|
|
59
|
+
<Button color="warning" outline>Click me!</Button>
|
|
60
|
+
</Story>
|
|
61
|
+
<Story name="Danger Outline" args={{ outline: true, color: 'danger' }}>
|
|
62
|
+
<Button color="danger" outline>Click me!</Button>
|
|
63
|
+
</Story>
|
|
64
|
+
<Story name="Info Outline" args={{ outline: true, color: 'info' }}>
|
|
65
|
+
<Button color="info" outline>Click me!</Button>
|
|
66
|
+
</Story>
|
|
@@ -9,10 +9,7 @@
|
|
|
9
9
|
const { Story } = defineMeta({
|
|
10
10
|
component: Button,
|
|
11
11
|
tags: ['autodocs'],
|
|
12
|
-
|
|
13
|
-
argTypes: {
|
|
14
|
-
...storyButtonArgTypes,
|
|
15
|
-
},
|
|
12
|
+
argTypes: storyButtonArgTypes,
|
|
16
13
|
args: {
|
|
17
14
|
onclick: fn(),
|
|
18
15
|
},
|
|
@@ -21,7 +18,16 @@
|
|
|
21
18
|
|
|
22
19
|
<!-- Compact button with paddings stripped out and fixed size. We are using this icon library https://iconify.design/docs/icon-components/svelte/ -->
|
|
23
20
|
<Story name="Icon Button" args={{ compact: true }}>
|
|
24
|
-
<Button compact
|
|
21
|
+
<Button compact>
|
|
22
|
+
<Icon icon="material-symbols:app-badging" width="18" height="18" />
|
|
23
|
+
</Button>
|
|
24
|
+
</Story>
|
|
25
|
+
|
|
26
|
+
<!-- Circualr Icon button. -->
|
|
27
|
+
<Story name="Icon Button Circular" args={{ compact: true, roundness: 'full' }}>
|
|
28
|
+
<Button roundness="full" compact>
|
|
29
|
+
<Icon icon="material-symbols:app-badging" width="18" height="18" />
|
|
30
|
+
</Button>
|
|
25
31
|
</Story>
|
|
26
32
|
|
|
27
33
|
<!-- Button with an icon in front. -->
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
<script module>
|
|
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="Roundness1"
|
|
20
|
+
args={{ outline: false, disabled: false, compact: false, roundness: 'full' }}
|
|
21
|
+
>
|
|
22
|
+
<Button roundness="full">Click me!</Button>
|
|
23
|
+
</Story>
|
|
24
|
+
|
|
25
|
+
<Story name="Roundness2" args={{ outline: false, disabled: false, compact: false, roundness: 2 }}>
|
|
26
|
+
<Button roundness={2}>Click me!</Button>
|
|
27
|
+
</Story>
|
|
28
|
+
|
|
29
|
+
<Story name="Roundness3" args={{ outline: false, disabled: false, compact: false, roundness: 3 }}>
|
|
30
|
+
<Button roundness={3}>Click me!</Button>
|
|
31
|
+
</Story>
|
|
32
|
+
|
|
33
|
+
<Story
|
|
34
|
+
name="RoundnessFalse"
|
|
35
|
+
args={{ outline: false, disabled: false, compact: false, roundness: false }}
|
|
36
|
+
>
|
|
37
|
+
<Button roundness={false}>Click me!</Button>
|
|
38
|
+
</Story>
|
|
39
|
+
|
|
40
|
+
<!-- Button with 50% roundness usefull for icon (Compact) buttons -->
|
|
41
|
+
<Story
|
|
42
|
+
name="RoundnessFull"
|
|
43
|
+
args={{ outline: false, disabled: false, compact: false, roundness: 'full' }}
|
|
44
|
+
>
|
|
45
|
+
<Button roundness="full">C</Button>
|
|
46
|
+
</Story>
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/// Mixin: generate-dodo-ui-button-colors
|
|
2
|
+
/// Generates CSS custom properties for Dodo UI button styles (text & solid)
|
|
3
|
+
/// across different interaction states (default, hover, active).
|
|
4
|
+
/// @param {String} $color-name - The theme color name (e.g., "primary", "safe", etc.)
|
|
5
|
+
@mixin generate-dodo-ui-button-colors($color-name) {
|
|
6
|
+
--dodo-ui-button-outline-#{$color-name}: var(--dodo-color-#{$color-name}-400);
|
|
7
|
+
|
|
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
|
+
|
|
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
|
+
}
|
|
16
|
+
|
|
17
|
+
/// Mixin: generate-dodo-ui-button-colors
|
|
18
|
+
/// Generates CSS custom properties for Dodo UI button styles (text & solid)
|
|
19
|
+
/// across different interaction states (default, hover, active).
|
|
20
|
+
/// @param {String} $color-name - The theme color name (e.g., "primary", "safe", etc.)
|
|
21
|
+
@mixin generate-dodo-ui-button-colors-dark($color-name) {
|
|
22
|
+
--dodo-ui-button-outline-#{$color-name}: var(--dodo-color-#{$color-name}-300);
|
|
23
|
+
|
|
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
|
+
|
|
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
|
+
}
|
|
32
|
+
|
|
33
|
+
/// Mixin: generate-dodo-ui-button-color
|
|
34
|
+
/// Auto-generates .color--[theme] > .variant--text & .variant--solid styles
|
|
35
|
+
/// @param {String} $theme - e.g., default, safe, danger, etc.
|
|
36
|
+
@mixin generate-dodo-ui-button-color($theme) {
|
|
37
|
+
&--#{$theme} {
|
|
38
|
+
&.variant {
|
|
39
|
+
&--text {
|
|
40
|
+
color: var(--dodo-color-#{$theme}-800);
|
|
41
|
+
background-color: var(--dodo-ui-button-text-#{$theme}-bg);
|
|
42
|
+
|
|
43
|
+
&:hover {
|
|
44
|
+
background-color: var(--dodo-ui-button-text-#{$theme}-hover-bg);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
&:active {
|
|
48
|
+
background-color: var(--dodo-ui-button-text-#{$theme}-active-bg);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
&.outline {
|
|
52
|
+
border-color: var(--dodo-ui-button-outline-#{$theme});
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
&--solid {
|
|
57
|
+
color: var(--dodo-color-constant-white);
|
|
58
|
+
background-color: var(--dodo-ui-button-solid-#{$theme}-bg);
|
|
59
|
+
|
|
60
|
+
&:hover {
|
|
61
|
+
background-color: var(--dodo-ui-button-solid-#{$theme}-hover-bg);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
&:active {
|
|
65
|
+
background-color: var(--dodo-ui-button-solid-#{$theme}-active-bg);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
type ControlType =
|
|
2
|
+
| 'object'
|
|
3
|
+
| 'boolean'
|
|
4
|
+
| 'check'
|
|
5
|
+
| 'inline-check'
|
|
6
|
+
| 'radio'
|
|
7
|
+
| 'inline-radio'
|
|
8
|
+
| 'select'
|
|
9
|
+
| 'multi-select'
|
|
10
|
+
| 'number'
|
|
11
|
+
| 'range'
|
|
12
|
+
| 'file'
|
|
13
|
+
| 'color'
|
|
14
|
+
| 'date'
|
|
15
|
+
| 'text';
|
|
16
|
+
|
|
17
|
+
interface ControlBase {
|
|
18
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
19
|
+
[key: string]: any;
|
|
20
|
+
/** @see https://storybook.js.org/docs/api/arg-types#controltype */
|
|
21
|
+
type?: ControlType;
|
|
22
|
+
disable?: boolean;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
type Control =
|
|
26
|
+
| ControlType
|
|
27
|
+
| false
|
|
28
|
+
| (ControlBase &
|
|
29
|
+
(
|
|
30
|
+
| ControlBase
|
|
31
|
+
| {
|
|
32
|
+
type: 'color';
|
|
33
|
+
/** @see https://storybook.js.org/docs/api/arg-types#controlpresetcolors */
|
|
34
|
+
presetColors?: string[];
|
|
35
|
+
}
|
|
36
|
+
| {
|
|
37
|
+
type: 'file';
|
|
38
|
+
/** @see https://storybook.js.org/docs/api/arg-types#controlaccept */
|
|
39
|
+
accept?: string;
|
|
40
|
+
}
|
|
41
|
+
| {
|
|
42
|
+
type: 'inline-check' | 'radio' | 'inline-radio' | 'select' | 'multi-select';
|
|
43
|
+
/** @see https://storybook.js.org/docs/api/arg-types#controllabels */
|
|
44
|
+
labels?: {
|
|
45
|
+
[options: string]: string;
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
| {
|
|
49
|
+
type: 'number' | 'range';
|
|
50
|
+
/** @see https://storybook.js.org/docs/api/arg-types#controlmax */
|
|
51
|
+
max?: number;
|
|
52
|
+
/** @see https://storybook.js.org/docs/api/arg-types#controlmin */
|
|
53
|
+
min?: number;
|
|
54
|
+
/** @see https://storybook.js.org/docs/api/arg-types#controlstep */
|
|
55
|
+
step?: number;
|
|
56
|
+
}
|
|
57
|
+
));
|
|
58
|
+
|
|
59
|
+
type ConditionalTest =
|
|
60
|
+
| {
|
|
61
|
+
truthy?: boolean;
|
|
62
|
+
}
|
|
63
|
+
| {
|
|
64
|
+
exists: boolean;
|
|
65
|
+
}
|
|
66
|
+
| {
|
|
67
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
68
|
+
eq: any;
|
|
69
|
+
}
|
|
70
|
+
| {
|
|
71
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
72
|
+
neq: any;
|
|
73
|
+
};
|
|
74
|
+
type ConditionalValue =
|
|
75
|
+
| {
|
|
76
|
+
arg: string;
|
|
77
|
+
}
|
|
78
|
+
| {
|
|
79
|
+
global: string;
|
|
80
|
+
};
|
|
81
|
+
type Conditional = ConditionalValue & ConditionalTest;
|
|
82
|
+
|
|
83
|
+
interface Args {
|
|
84
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
85
|
+
[name: string]: any;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
interface SBBaseType {
|
|
89
|
+
required?: boolean;
|
|
90
|
+
raw?: string;
|
|
91
|
+
}
|
|
92
|
+
type SBScalarType = SBBaseType & {
|
|
93
|
+
name: 'boolean' | 'string' | 'number' | 'function' | 'symbol';
|
|
94
|
+
};
|
|
95
|
+
type SBArrayType = SBBaseType & {
|
|
96
|
+
name: 'array';
|
|
97
|
+
value: SBType;
|
|
98
|
+
};
|
|
99
|
+
type SBObjectType = SBBaseType & {
|
|
100
|
+
name: 'object';
|
|
101
|
+
value: Record<string, SBType>;
|
|
102
|
+
};
|
|
103
|
+
type SBEnumType = SBBaseType & {
|
|
104
|
+
name: 'enum';
|
|
105
|
+
value: (string | number)[];
|
|
106
|
+
};
|
|
107
|
+
type SBIntersectionType = SBBaseType & {
|
|
108
|
+
name: 'intersection';
|
|
109
|
+
value: SBType[];
|
|
110
|
+
};
|
|
111
|
+
type SBUnionType = SBBaseType & {
|
|
112
|
+
name: 'union';
|
|
113
|
+
value: SBType[];
|
|
114
|
+
};
|
|
115
|
+
type SBOtherType = SBBaseType & {
|
|
116
|
+
name: 'other';
|
|
117
|
+
value: string;
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
type SBType =
|
|
121
|
+
| SBScalarType
|
|
122
|
+
| SBEnumType
|
|
123
|
+
| SBArrayType
|
|
124
|
+
| SBObjectType
|
|
125
|
+
| SBIntersectionType
|
|
126
|
+
| SBUnionType
|
|
127
|
+
| SBOtherType;
|
|
128
|
+
|
|
129
|
+
interface InputType {
|
|
130
|
+
/** @see https://storybook.js.org/docs/api/arg-types#control */
|
|
131
|
+
control?: Control;
|
|
132
|
+
/** @see https://storybook.js.org/docs/api/arg-types#description */
|
|
133
|
+
description?: string;
|
|
134
|
+
/** @see https://storybook.js.org/docs/api/arg-types#if */
|
|
135
|
+
if?: Conditional;
|
|
136
|
+
/** @see https://storybook.js.org/docs/api/arg-types#mapping */
|
|
137
|
+
mapping?: {
|
|
138
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
139
|
+
[key: string]: any;
|
|
140
|
+
};
|
|
141
|
+
/** @see https://storybook.js.org/docs/api/arg-types#name */
|
|
142
|
+
name?: string;
|
|
143
|
+
/** @see https://storybook.js.org/docs/api/arg-types#options */
|
|
144
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
145
|
+
options?: readonly any[];
|
|
146
|
+
/** @see https://storybook.js.org/docs/api/arg-types#table */
|
|
147
|
+
table?: {
|
|
148
|
+
[key: string]: unknown;
|
|
149
|
+
/** @see https://storybook.js.org/docs/api/arg-types#tablecategory */
|
|
150
|
+
category?: string;
|
|
151
|
+
/** @see https://storybook.js.org/docs/api/arg-types#tabledefaultvalue */
|
|
152
|
+
defaultValue?: {
|
|
153
|
+
summary?: string;
|
|
154
|
+
detail?: string;
|
|
155
|
+
};
|
|
156
|
+
/** @see https://storybook.js.org/docs/api/arg-types#tabledisable */
|
|
157
|
+
disable?: boolean;
|
|
158
|
+
/** @see https://storybook.js.org/docs/api/arg-types#tablesubcategory */
|
|
159
|
+
subcategory?: string;
|
|
160
|
+
/** @see https://storybook.js.org/docs/api/arg-types#tabletype */
|
|
161
|
+
type?: {
|
|
162
|
+
summary?: string;
|
|
163
|
+
detail?: string;
|
|
164
|
+
};
|
|
165
|
+
};
|
|
166
|
+
/** @see https://storybook.js.org/docs/api/arg-types#type */
|
|
167
|
+
type?: SBType | SBScalarType['name'];
|
|
168
|
+
/**
|
|
169
|
+
* @deprecated Use `table.defaultValue.summary` instead.
|
|
170
|
+
* @see https://storybook.js.org/docs/api/arg-types#defaultvalue
|
|
171
|
+
*/
|
|
172
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
173
|
+
defaultValue?: any;
|
|
174
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
175
|
+
[key: string]: any;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
export type ArgTypes<TArgs = Args> = {
|
|
179
|
+
[name in keyof TArgs]: InputType;
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
export type StoryBookArgTypes = Partial<ArgTypes<Args>>;
|