@flightlesslabs/dodo-ui 0.1.5 → 0.3.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 +6 -0
- package/dist/index.js +4 -0
- package/dist/stories/Home.mdx +57 -7
- package/dist/stories/assets/dark-theme-toggle.png +0 -0
- package/dist/stories/components/Form/Button/Button.stories.svelte +10 -5
- package/dist/stories/components/Form/Button/Button.svelte +213 -211
- package/dist/stories/components/Form/Button/Button.svelte.d.ts +4 -1
- 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/Roundness/Roundness.stories.svelte +14 -11
- package/dist/stories/components/Form/Button/utils/scss/mixins.scss +21 -21
- 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 +37 -0
- package/dist/stories/components/Form/PasswordInput/PasswordInput.stories.svelte.d.ts +21 -0
- package/dist/stories/components/Form/PasswordInput/PasswordInput.svelte +219 -0
- package/dist/stories/components/Form/PasswordInput/PasswordInput.svelte.d.ts +59 -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 +35 -0
- package/dist/stories/components/Form/TextInput/TextInput.stories.svelte.d.ts +21 -0
- package/dist/stories/components/Form/TextInput/TextInput.svelte +166 -0
- package/dist/stories/components/Form/TextInput/TextInput.svelte.d.ts +56 -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/philosophy/Colors/Colors.mdx +43 -0
- package/dist/stories/philosophy/Colors/Colors.stories.svelte +20 -0
- package/dist/stories/philosophy/Colors/Colors.stories.svelte.d.ts +19 -0
- package/dist/stories/philosophy/Colors/Colors.svelte +33 -0
- package/dist/stories/philosophy/Colors/Colors.svelte.d.ts +6 -0
- package/dist/stories/philosophy/Colors/Opacity.stories.svelte +9 -0
- package/dist/stories/philosophy/Colors/Opacity.stories.svelte.d.ts +19 -0
- package/dist/stories/philosophy/Colors/Opacity.svelte +20 -0
- package/dist/stories/philosophy/Colors/Opacity.svelte.d.ts +18 -0
- package/dist/stories/philosophy/Colors/Swatches/Palette.svelte +15 -0
- package/dist/stories/philosophy/Colors/Swatches/Palette.svelte.d.ts +6 -0
- package/dist/stories/philosophy/Colors/Swatches/Swatch.svelte +18 -0
- package/dist/stories/philosophy/Colors/Swatches/Swatch.svelte.d.ts +8 -0
- package/dist/stories/philosophy/Colors/Swatches/Swatches.svelte +39 -0
- package/dist/stories/philosophy/Colors/Swatches/Swatches.svelte.d.ts +8 -0
- package/dist/stories/philosophy/Colors/utils/color.d.ts +4 -0
- package/dist/stories/philosophy/Colors/utils/color.js +38 -0
- package/dist/stories/philosophy/Themes.mdx +23 -0
- package/dist/styles/_colors.css +2 -2
- package/dist/styles/_components.css +7 -6
- package/dist/styles/_minimal-reset.css +3 -0
- package/dist/styles/global.css +1 -0
- package/dist/types.d.ts +1 -1
- package/package.json +3 -2
- package/src/lib/index.ts +13 -0
- package/src/lib/stories/components/Form/Button/Button.stories.svelte +10 -5
- package/src/lib/stories/components/Form/Button/Button.svelte +36 -30
- package/src/lib/stories/components/Form/Button/Events/Events.stories.svelte +42 -0
- package/src/lib/stories/components/Form/Button/Roundness/Roundness.stories.svelte +14 -11
- package/src/lib/stories/components/Form/Button/utils/scss/mixins.scss +21 -21
- package/src/lib/stories/components/Form/PasswordInput/Events/Events.stories.svelte +174 -0
- package/src/lib/stories/components/Form/PasswordInput/PasswordInput.stories.svelte +41 -0
- package/src/lib/stories/components/Form/PasswordInput/PasswordInput.svelte +361 -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 +39 -0
- package/src/lib/stories/components/Form/TextInput/TextInput.svelte +293 -0
- package/src/lib/stories/components/Form/TextInput/WithIcon/WithIcon.stories.svelte +47 -0
- package/src/lib/styles/_colors.css +2 -2
- package/src/lib/styles/_components.css +7 -6
- package/src/lib/styles/_minimal-reset.css +3 -0
- package/src/lib/styles/global.css +1 -0
- package/src/lib/types.ts +1 -1
- package/dist/stories/Getting Started.mdx +0 -13
- 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
|
@@ -15,6 +15,7 @@
|
|
|
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
21
|
/** Button contents goes here*/
|
|
@@ -23,6 +24,8 @@
|
|
|
23
24
|
type?: 'button' | 'submit';
|
|
24
25
|
/** How large should the button be? */
|
|
25
26
|
size?: ComponentSize;
|
|
27
|
+
/** Full width button? */
|
|
28
|
+
fullWidth?: boolean;
|
|
26
29
|
/** What color to use? */
|
|
27
30
|
color?: ButtonColor;
|
|
28
31
|
/** How round should the border radius be? */
|
|
@@ -48,7 +51,7 @@
|
|
|
48
51
|
/** Custom css class*/
|
|
49
52
|
class?: string;
|
|
50
53
|
/** The onclick event handler */
|
|
51
|
-
onclick?:
|
|
54
|
+
onclick?: MouseEventHandler<HTMLButtonElement>;
|
|
52
55
|
/** Turn Button into link */
|
|
53
56
|
href?: string;
|
|
54
57
|
/** Link button: download */
|
|
@@ -77,10 +80,11 @@
|
|
|
77
80
|
type = 'button',
|
|
78
81
|
size = 'normal',
|
|
79
82
|
color = 'default',
|
|
80
|
-
roundness =
|
|
83
|
+
roundness = '1x',
|
|
81
84
|
variant = 'text',
|
|
82
85
|
outline = false,
|
|
83
86
|
compact = false,
|
|
87
|
+
fullWidth = false,
|
|
84
88
|
name,
|
|
85
89
|
id,
|
|
86
90
|
title,
|
|
@@ -104,7 +108,7 @@
|
|
|
104
108
|
|
|
105
109
|
{#snippet buttonContent()}
|
|
106
110
|
{#if before}
|
|
107
|
-
<span class="
|
|
111
|
+
<span class="content--before">
|
|
108
112
|
{@render before()}
|
|
109
113
|
</span>
|
|
110
114
|
{/if}
|
|
@@ -116,7 +120,7 @@
|
|
|
116
120
|
{/if}
|
|
117
121
|
|
|
118
122
|
{#if after}
|
|
119
|
-
<span class="
|
|
123
|
+
<span class="content--after">
|
|
120
124
|
{@render after()}
|
|
121
125
|
</span>
|
|
122
126
|
{/if}
|
|
@@ -138,8 +142,9 @@
|
|
|
138
142
|
class:outline
|
|
139
143
|
class:compact
|
|
140
144
|
class:disabled
|
|
145
|
+
class:fullWidth
|
|
141
146
|
class={[
|
|
142
|
-
'dodo-ui-
|
|
147
|
+
'dodo-ui-Button',
|
|
143
148
|
`size--${size}`,
|
|
144
149
|
`color--${color}`,
|
|
145
150
|
`variant--${variant}`,
|
|
@@ -153,8 +158,9 @@
|
|
|
153
158
|
<button
|
|
154
159
|
class:outline
|
|
155
160
|
class:compact
|
|
161
|
+
class:fullWidth
|
|
156
162
|
class={[
|
|
157
|
-
'dodo-ui-
|
|
163
|
+
'dodo-ui-Button',
|
|
158
164
|
`size--${size}`,
|
|
159
165
|
`color--${color}`,
|
|
160
166
|
`variant--${variant}`,
|
|
@@ -176,8 +182,8 @@
|
|
|
176
182
|
@use 'utils/scss/mixins.scss' as *;
|
|
177
183
|
|
|
178
184
|
:global(:root) {
|
|
179
|
-
--dodo-ui-
|
|
180
|
-
--dodo-ui-
|
|
185
|
+
--dodo-ui-Button-disabled-color: var(--dodo-color-default-400);
|
|
186
|
+
--dodo-ui-Button-disabled-bg: var(--dodo-color-default-200);
|
|
181
187
|
|
|
182
188
|
@include generate-dodo-ui-button-colors(default);
|
|
183
189
|
@include generate-dodo-ui-button-colors(primary);
|
|
@@ -188,8 +194,8 @@
|
|
|
188
194
|
}
|
|
189
195
|
|
|
190
196
|
:global(.dodo-theme--dark) {
|
|
191
|
-
--dodo-ui-
|
|
192
|
-
--dodo-ui-
|
|
197
|
+
--dodo-ui-Button-disabled-bg: var(--dodo-color-default-100);
|
|
198
|
+
--dodo-ui-Button-disabled-color: var(--dodo-color-default-500);
|
|
193
199
|
|
|
194
200
|
@include generate-dodo-ui-button-colors-dark(default);
|
|
195
201
|
@include generate-dodo-ui-button-colors-dark(primary);
|
|
@@ -199,7 +205,7 @@
|
|
|
199
205
|
@include generate-dodo-ui-button-colors-dark(info);
|
|
200
206
|
}
|
|
201
207
|
|
|
202
|
-
.dodo-ui-
|
|
208
|
+
.dodo-ui-Button {
|
|
203
209
|
cursor: pointer;
|
|
204
210
|
outline: none;
|
|
205
211
|
transition: all 150ms;
|
|
@@ -209,9 +215,9 @@
|
|
|
209
215
|
justify-content: center;
|
|
210
216
|
align-items: center;
|
|
211
217
|
font-family: inherit;
|
|
212
|
-
font-weight: 500;
|
|
213
218
|
background-color: transparent;
|
|
214
|
-
border:
|
|
219
|
+
border-style: solid;
|
|
220
|
+
border-width: var(--dodo-ui-element-border-width);
|
|
215
221
|
border-color: transparent;
|
|
216
222
|
outline: 0;
|
|
217
223
|
color: inherit;
|
|
@@ -241,20 +247,16 @@
|
|
|
241
247
|
}
|
|
242
248
|
|
|
243
249
|
&.roundness {
|
|
244
|
-
&--
|
|
245
|
-
border-radius: var(--dodo-ui-element-roundness-
|
|
250
|
+
&--1x {
|
|
251
|
+
border-radius: var(--dodo-ui-element-roundness-1x);
|
|
246
252
|
}
|
|
247
253
|
|
|
248
|
-
&--
|
|
249
|
-
border-radius: var(--dodo-ui-element-roundness-
|
|
254
|
+
&--2x {
|
|
255
|
+
border-radius: var(--dodo-ui-element-roundness-2x);
|
|
250
256
|
}
|
|
251
257
|
|
|
252
|
-
&--
|
|
253
|
-
border-radius: var(--dodo-ui-element-roundness-
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
&--4 {
|
|
257
|
-
border-radius: var(--dodo-ui-element-roundness-4);
|
|
258
|
+
&--3x {
|
|
259
|
+
border-radius: var(--dodo-ui-element-roundness-3x);
|
|
258
260
|
}
|
|
259
261
|
|
|
260
262
|
&--full {
|
|
@@ -277,17 +279,17 @@
|
|
|
277
279
|
&.variant {
|
|
278
280
|
&--text,
|
|
279
281
|
&--solid {
|
|
280
|
-
background-color: var(--dodo-ui-
|
|
281
|
-
color: var(--dodo-ui-
|
|
282
|
+
background-color: var(--dodo-ui-Button-disabled-bg);
|
|
283
|
+
color: var(--dodo-ui-Button-disabled-color);
|
|
282
284
|
|
|
283
285
|
&:hover {
|
|
284
|
-
background-color: var(--dodo-ui-
|
|
285
|
-
color: var(--dodo-ui-
|
|
286
|
+
background-color: var(--dodo-ui-Button-disabled-bg);
|
|
287
|
+
color: var(--dodo-ui-Button-disabled-color);
|
|
286
288
|
}
|
|
287
289
|
|
|
288
290
|
&:active {
|
|
289
|
-
background-color: var(--dodo-ui-
|
|
290
|
-
color: var(--dodo-ui-
|
|
291
|
+
background-color: var(--dodo-ui-Button-disabled-bg);
|
|
292
|
+
color: var(--dodo-ui-Button-disabled-color);
|
|
291
293
|
}
|
|
292
294
|
|
|
293
295
|
&.outline {
|
|
@@ -320,7 +322,11 @@
|
|
|
320
322
|
}
|
|
321
323
|
}
|
|
322
324
|
|
|
323
|
-
|
|
325
|
+
&.fullWidth {
|
|
326
|
+
width: 100%;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
.content {
|
|
324
330
|
&--after,
|
|
325
331
|
&--before {
|
|
326
332
|
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>
|
|
@@ -15,23 +15,26 @@
|
|
|
15
15
|
});
|
|
16
16
|
</script>
|
|
17
17
|
|
|
18
|
-
<Story
|
|
19
|
-
|
|
20
|
-
args={{ outline: false, disabled: false, compact: false, roundness: 'full' }}
|
|
21
|
-
>
|
|
22
|
-
<Button roundness="full">Click me!</Button>
|
|
18
|
+
<Story name="Roundness 1x" args={{ outline: false, disabled: false, compact: false }}>
|
|
19
|
+
<Button>Click me!</Button>
|
|
23
20
|
</Story>
|
|
24
21
|
|
|
25
|
-
<Story
|
|
26
|
-
|
|
22
|
+
<Story
|
|
23
|
+
name="Roundness 2x"
|
|
24
|
+
args={{ outline: false, disabled: false, compact: false, roundness: '2x' }}
|
|
25
|
+
>
|
|
26
|
+
<Button roundness="2x">Click me!</Button>
|
|
27
27
|
</Story>
|
|
28
28
|
|
|
29
|
-
<Story
|
|
30
|
-
|
|
29
|
+
<Story
|
|
30
|
+
name="Roundness 3x"
|
|
31
|
+
args={{ outline: false, disabled: false, compact: false, roundness: '3x' }}
|
|
32
|
+
>
|
|
33
|
+
<Button roundness="3x">Click me!</Button>
|
|
31
34
|
</Story>
|
|
32
35
|
|
|
33
36
|
<Story
|
|
34
|
-
name="
|
|
37
|
+
name="Roundness False"
|
|
35
38
|
args={{ outline: false, disabled: false, compact: false, roundness: false }}
|
|
36
39
|
>
|
|
37
40
|
<Button roundness={false}>Click me!</Button>
|
|
@@ -39,7 +42,7 @@
|
|
|
39
42
|
|
|
40
43
|
<!-- Button with 50% roundness usefull for icon (Compact) buttons -->
|
|
41
44
|
<Story
|
|
42
|
-
name="
|
|
45
|
+
name="Roundness Full"
|
|
43
46
|
args={{ outline: false, disabled: false, compact: false, roundness: 'full' }}
|
|
44
47
|
>
|
|
45
48
|
<Button roundness="full">C</Button>
|
|
@@ -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,174 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
+
import { storyPasswordInputArgTypes } from '../PasswordInput.stories.svelte';
|
|
4
|
+
import PasswordInput, { type PasswordInputToggleEvent } from '../PasswordInput.svelte';
|
|
5
|
+
import type {
|
|
6
|
+
TextInputFocusEvent,
|
|
7
|
+
TextInputClipboardEvent,
|
|
8
|
+
} from '../../TextInput/TextInput.svelte';
|
|
9
|
+
|
|
10
|
+
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories
|
|
11
|
+
const { Story } = defineMeta({
|
|
12
|
+
component: PasswordInput,
|
|
13
|
+
tags: ['autodocs'],
|
|
14
|
+
argTypes: storyPasswordInputArgTypes,
|
|
15
|
+
});
|
|
16
|
+
</script>
|
|
17
|
+
|
|
18
|
+
<Story
|
|
19
|
+
name="Input"
|
|
20
|
+
args={{
|
|
21
|
+
oninput: (e: Event) => {
|
|
22
|
+
const target = e.target as HTMLInputElement;
|
|
23
|
+
|
|
24
|
+
console.log('Input Event', target.value);
|
|
25
|
+
},
|
|
26
|
+
}}
|
|
27
|
+
>
|
|
28
|
+
<PasswordInput
|
|
29
|
+
oninput={(e: Event) => {
|
|
30
|
+
const target = e.target as HTMLInputElement;
|
|
31
|
+
|
|
32
|
+
console.log('Input Event', target.value);
|
|
33
|
+
}}
|
|
34
|
+
/>
|
|
35
|
+
</Story>
|
|
36
|
+
|
|
37
|
+
<Story
|
|
38
|
+
name="Change"
|
|
39
|
+
args={{
|
|
40
|
+
onchange: (e: Event) => {
|
|
41
|
+
const target = e.target as HTMLInputElement;
|
|
42
|
+
|
|
43
|
+
console.log('onChange Event', target.value);
|
|
44
|
+
},
|
|
45
|
+
}}
|
|
46
|
+
>
|
|
47
|
+
<PasswordInput
|
|
48
|
+
onchange={(e: Event) => {
|
|
49
|
+
const target = e.target as HTMLInputElement;
|
|
50
|
+
|
|
51
|
+
console.log('onchange Event', target.value);
|
|
52
|
+
}}
|
|
53
|
+
/>
|
|
54
|
+
</Story>
|
|
55
|
+
|
|
56
|
+
<!-- `e: PasswordInputToggleEvent` -->
|
|
57
|
+
<Story
|
|
58
|
+
name="Toggle"
|
|
59
|
+
args={{
|
|
60
|
+
ontoggle: (e: PasswordInputToggleEvent) => {
|
|
61
|
+
const target = e.event.target as HTMLButtonElement;
|
|
62
|
+
|
|
63
|
+
console.log('ontoggle Event', e, target);
|
|
64
|
+
},
|
|
65
|
+
}}
|
|
66
|
+
>
|
|
67
|
+
<PasswordInput
|
|
68
|
+
ontoggle={(e: PasswordInputToggleEvent) => {
|
|
69
|
+
const target = e.event.target as HTMLButtonElement;
|
|
70
|
+
|
|
71
|
+
console.log('ontoggle Event', e, target);
|
|
72
|
+
}}
|
|
73
|
+
/>
|
|
74
|
+
</Story>
|
|
75
|
+
|
|
76
|
+
<!-- `e: TextInputFocusEvent` -->
|
|
77
|
+
<Story
|
|
78
|
+
name="Focus"
|
|
79
|
+
args={{
|
|
80
|
+
onfocus: (e: TextInputFocusEvent) => {
|
|
81
|
+
const target = e.target as HTMLInputElement;
|
|
82
|
+
|
|
83
|
+
console.log('onfocus Event', target);
|
|
84
|
+
},
|
|
85
|
+
}}
|
|
86
|
+
>
|
|
87
|
+
<PasswordInput
|
|
88
|
+
onfocus={(e: TextInputFocusEvent) => {
|
|
89
|
+
const target = e.target as HTMLInputElement;
|
|
90
|
+
|
|
91
|
+
console.log('onfocus Event', target);
|
|
92
|
+
}}
|
|
93
|
+
/>
|
|
94
|
+
</Story>
|
|
95
|
+
|
|
96
|
+
<!-- `e: TextInputFocusEvent` -->
|
|
97
|
+
<Story
|
|
98
|
+
name="Blur"
|
|
99
|
+
args={{
|
|
100
|
+
onblur: (e: TextInputFocusEvent) => {
|
|
101
|
+
const target = e.target as HTMLInputElement;
|
|
102
|
+
|
|
103
|
+
console.log('onblur Event', target);
|
|
104
|
+
},
|
|
105
|
+
}}
|
|
106
|
+
>
|
|
107
|
+
<PasswordInput
|
|
108
|
+
onblur={(e: TextInputFocusEvent) => {
|
|
109
|
+
const target = e.target as HTMLInputElement;
|
|
110
|
+
|
|
111
|
+
console.log('onblur Event', target);
|
|
112
|
+
}}
|
|
113
|
+
/>
|
|
114
|
+
</Story>
|
|
115
|
+
|
|
116
|
+
<!-- `e: TextInputClipboardEvent` -->
|
|
117
|
+
<Story
|
|
118
|
+
name="Copy"
|
|
119
|
+
args={{
|
|
120
|
+
oncopy: (e: TextInputClipboardEvent) => {
|
|
121
|
+
const target = e.target as HTMLInputElement;
|
|
122
|
+
|
|
123
|
+
console.log('oncopy Event', target);
|
|
124
|
+
},
|
|
125
|
+
}}
|
|
126
|
+
>
|
|
127
|
+
<PasswordInput
|
|
128
|
+
oncopy={(e: TextInputClipboardEvent) => {
|
|
129
|
+
const target = e.target as HTMLInputElement;
|
|
130
|
+
|
|
131
|
+
console.log('oncopy Event', target);
|
|
132
|
+
}}
|
|
133
|
+
/>
|
|
134
|
+
</Story>
|
|
135
|
+
|
|
136
|
+
<!-- `e: TextInputClipboardEvent` -->
|
|
137
|
+
<Story
|
|
138
|
+
name="Cut"
|
|
139
|
+
args={{
|
|
140
|
+
oncut: (e: TextInputClipboardEvent) => {
|
|
141
|
+
const target = e.target as HTMLInputElement;
|
|
142
|
+
|
|
143
|
+
console.log('oncut Event', target);
|
|
144
|
+
},
|
|
145
|
+
}}
|
|
146
|
+
>
|
|
147
|
+
<PasswordInput
|
|
148
|
+
oncut={(e: TextInputClipboardEvent) => {
|
|
149
|
+
const target = e.target as HTMLInputElement;
|
|
150
|
+
|
|
151
|
+
console.log('oncut Event', target);
|
|
152
|
+
}}
|
|
153
|
+
/>
|
|
154
|
+
</Story>
|
|
155
|
+
|
|
156
|
+
<!-- `e: TextInputClipboardEvent` -->
|
|
157
|
+
<Story
|
|
158
|
+
name="Paste"
|
|
159
|
+
args={{
|
|
160
|
+
onpaste: (e: TextInputClipboardEvent) => {
|
|
161
|
+
const target = e.target as HTMLInputElement;
|
|
162
|
+
|
|
163
|
+
console.log('onpaste Event', target);
|
|
164
|
+
},
|
|
165
|
+
}}
|
|
166
|
+
>
|
|
167
|
+
<PasswordInput
|
|
168
|
+
onpaste={(e: TextInputClipboardEvent) => {
|
|
169
|
+
const target = e.target as HTMLInputElement;
|
|
170
|
+
|
|
171
|
+
console.log('onpaste Event', target);
|
|
172
|
+
}}
|
|
173
|
+
/>
|
|
174
|
+
</Story>
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
+
import PasswordInput from './PasswordInput.svelte';
|
|
4
|
+
import type { StoryBookArgTypes } from '$lib/storybook-types.js';
|
|
5
|
+
|
|
6
|
+
export const storyPasswordInputArgTypes: StoryBookArgTypes = {
|
|
7
|
+
roundness: {
|
|
8
|
+
control: { type: 'select' },
|
|
9
|
+
options: [false, '1x', '2x', '3x'],
|
|
10
|
+
},
|
|
11
|
+
size: {
|
|
12
|
+
control: { type: 'select' },
|
|
13
|
+
options: ['normal', 'small', 'large'],
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories
|
|
18
|
+
const { Story } = defineMeta({
|
|
19
|
+
component: PasswordInput,
|
|
20
|
+
tags: ['autodocs'],
|
|
21
|
+
argTypes: storyPasswordInputArgTypes,
|
|
22
|
+
args: { value: 'Hello world!' },
|
|
23
|
+
});
|
|
24
|
+
</script>
|
|
25
|
+
|
|
26
|
+
<!-- PasswordInput with default style -->
|
|
27
|
+
<Story name="Default" />
|
|
28
|
+
|
|
29
|
+
<Story name="Placeholder" args={{ value: '', placeholder: 'Type something...' }} />
|
|
30
|
+
|
|
31
|
+
<Story name="No Outline" args={{ outline: false }} />
|
|
32
|
+
|
|
33
|
+
<Story name="Error" args={{ error: true }} />
|
|
34
|
+
|
|
35
|
+
<Story name="Disabled" args={{ disabled: true }} />
|
|
36
|
+
|
|
37
|
+
<!-- Disable password toggle -->
|
|
38
|
+
<Story name="No toggle" args={{ passwordToggle: false }} />
|
|
39
|
+
|
|
40
|
+
<!-- Show Password by default -->
|
|
41
|
+
<Story name="Show Password" args={{ defaultPasswordToggleState: true }} />
|