@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
|
@@ -0,0 +1,361 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
export type PasswordInputToggleEvent = {
|
|
3
|
+
event: Event;
|
|
4
|
+
toggle: boolean;
|
|
5
|
+
};
|
|
6
|
+
</script>
|
|
7
|
+
|
|
8
|
+
<script lang="ts">
|
|
9
|
+
import type { ComponentSize } from '$lib/types.js';
|
|
10
|
+
import type { Snippet } from 'svelte';
|
|
11
|
+
import type {
|
|
12
|
+
ChangeEventHandler,
|
|
13
|
+
ClipboardEventHandler,
|
|
14
|
+
FocusEventHandler,
|
|
15
|
+
FormEventHandler,
|
|
16
|
+
} from 'svelte/elements';
|
|
17
|
+
import type { TextInputFocusEvent, TextInputRoundness } from '../TextInput/TextInput.svelte';
|
|
18
|
+
import Icon from '@iconify/svelte';
|
|
19
|
+
|
|
20
|
+
interface PasswordInputProps {
|
|
21
|
+
/** How large should the button be? */
|
|
22
|
+
size?: ComponentSize;
|
|
23
|
+
/** Toggle Password */
|
|
24
|
+
passwordToggle?: boolean;
|
|
25
|
+
/** Default Password Toggle State */
|
|
26
|
+
defaultPasswordToggleState?: boolean;
|
|
27
|
+
/** Toggle Password Icon */
|
|
28
|
+
passwordToggleIcon?: Snippet;
|
|
29
|
+
/** How round should the border radius be? */
|
|
30
|
+
roundness?: TextInputRoundness;
|
|
31
|
+
/** Add a border around the button. Default True */
|
|
32
|
+
outline?: boolean;
|
|
33
|
+
/** Input value */
|
|
34
|
+
value?: string;
|
|
35
|
+
/** How round should the border radius be? */
|
|
36
|
+
placeholder?: string;
|
|
37
|
+
/** Button disabled state */
|
|
38
|
+
disabled?: boolean;
|
|
39
|
+
/** is there any associated Error ? */
|
|
40
|
+
error?: boolean;
|
|
41
|
+
/** Name */
|
|
42
|
+
name?: string;
|
|
43
|
+
/** Id */
|
|
44
|
+
id?: string;
|
|
45
|
+
/** Icon before button content */
|
|
46
|
+
before?: Snippet;
|
|
47
|
+
/** Icon after button content */
|
|
48
|
+
after?: Snippet;
|
|
49
|
+
/** Custom css class*/
|
|
50
|
+
class?: string;
|
|
51
|
+
/** oninput event handler */
|
|
52
|
+
oninput?: FormEventHandler<HTMLInputElement>;
|
|
53
|
+
/** onchange event handler */
|
|
54
|
+
onchange?: ChangeEventHandler<HTMLInputElement>;
|
|
55
|
+
/** onblur event handler */
|
|
56
|
+
onblur?: FocusEventHandler<HTMLInputElement>;
|
|
57
|
+
/** onfocus event handler */
|
|
58
|
+
onfocus?: FocusEventHandler<HTMLInputElement>;
|
|
59
|
+
/** onpaste event handler */
|
|
60
|
+
onpaste?: ClipboardEventHandler<HTMLInputElement>;
|
|
61
|
+
/** oncopy event handler */
|
|
62
|
+
oncopy?: ClipboardEventHandler<HTMLInputElement>;
|
|
63
|
+
/** oncut event handler */
|
|
64
|
+
oncut?: ClipboardEventHandler<HTMLInputElement>;
|
|
65
|
+
/** ontoggle event handler */
|
|
66
|
+
ontoggle?: (e: PasswordInputToggleEvent) => void;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
let {
|
|
70
|
+
size = 'normal',
|
|
71
|
+
roundness = '1x',
|
|
72
|
+
outline = true,
|
|
73
|
+
name,
|
|
74
|
+
id,
|
|
75
|
+
class: className = '',
|
|
76
|
+
disabled = false,
|
|
77
|
+
oninput,
|
|
78
|
+
onchange,
|
|
79
|
+
onblur,
|
|
80
|
+
onfocus,
|
|
81
|
+
onpaste,
|
|
82
|
+
oncopy,
|
|
83
|
+
oncut,
|
|
84
|
+
before,
|
|
85
|
+
after,
|
|
86
|
+
passwordToggleIcon,
|
|
87
|
+
error = false,
|
|
88
|
+
passwordToggle = true,
|
|
89
|
+
defaultPasswordToggleState = false,
|
|
90
|
+
value = $bindable<string>(),
|
|
91
|
+
placeholder,
|
|
92
|
+
ontoggle,
|
|
93
|
+
}: PasswordInputProps = $props();
|
|
94
|
+
|
|
95
|
+
let focused: boolean = $state(false);
|
|
96
|
+
let toggle: boolean = $state(defaultPasswordToggleState);
|
|
97
|
+
|
|
98
|
+
function onfocusMod(e: TextInputFocusEvent) {
|
|
99
|
+
focused = true;
|
|
100
|
+
|
|
101
|
+
if (onfocus) {
|
|
102
|
+
onfocus(e);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function onblurMod(e: TextInputFocusEvent) {
|
|
107
|
+
focused = false;
|
|
108
|
+
|
|
109
|
+
if (onblur) {
|
|
110
|
+
onblur(e);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function ontoggleMod(e: Event) {
|
|
115
|
+
toggle = !toggle;
|
|
116
|
+
|
|
117
|
+
const customEvent: PasswordInputToggleEvent = {
|
|
118
|
+
event: e,
|
|
119
|
+
toggle,
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
if (ontoggle) {
|
|
123
|
+
ontoggle(customEvent);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
</script>
|
|
127
|
+
|
|
128
|
+
<div
|
|
129
|
+
class:outline
|
|
130
|
+
class:disabled
|
|
131
|
+
class:error
|
|
132
|
+
class:focused
|
|
133
|
+
class:toggle
|
|
134
|
+
class={['dodo-ui-PasswordInput', `size--${size}`, `roundness--${roundness}`, className].join(' ')}
|
|
135
|
+
>
|
|
136
|
+
{#if before}
|
|
137
|
+
<span class="content--before">
|
|
138
|
+
{@render before()}
|
|
139
|
+
</span>
|
|
140
|
+
{/if}
|
|
141
|
+
<input
|
|
142
|
+
type={passwordToggle && toggle ? 'text' : 'password'}
|
|
143
|
+
{name}
|
|
144
|
+
{id}
|
|
145
|
+
{disabled}
|
|
146
|
+
{oninput}
|
|
147
|
+
{onchange}
|
|
148
|
+
onfocus={onfocusMod}
|
|
149
|
+
onblur={onblurMod}
|
|
150
|
+
{onpaste}
|
|
151
|
+
{oncopy}
|
|
152
|
+
{oncut}
|
|
153
|
+
{placeholder}
|
|
154
|
+
bind:value
|
|
155
|
+
/>
|
|
156
|
+
|
|
157
|
+
{#if passwordToggle && !disabled}
|
|
158
|
+
<button class="passwordToggle" title="Toggle password" onclick={ontoggleMod} class:toggle>
|
|
159
|
+
{#if passwordToggleIcon}
|
|
160
|
+
{@render passwordToggleIcon()}
|
|
161
|
+
{:else if toggle}
|
|
162
|
+
<Icon icon="mdi:eye-off" width="24" height="24" />
|
|
163
|
+
{:else}
|
|
164
|
+
<Icon icon="mdi:eye" width="24" height="24" />
|
|
165
|
+
{/if}
|
|
166
|
+
</button>
|
|
167
|
+
{/if}
|
|
168
|
+
|
|
169
|
+
{#if after}
|
|
170
|
+
<span class="content--after">
|
|
171
|
+
{@render after()}
|
|
172
|
+
</span>
|
|
173
|
+
{/if}
|
|
174
|
+
</div>
|
|
175
|
+
|
|
176
|
+
<style lang="scss">
|
|
177
|
+
:global(:root) {
|
|
178
|
+
--dodo-ui-PasswordInput-border-color: var(--dodo-color-default-500);
|
|
179
|
+
--dodo-ui-PasswordInput-focus-border-color: var(--dodo-color-primary-500);
|
|
180
|
+
--dodo-ui-PasswordInput-error-border-color: var(--dodo-color-danger-500);
|
|
181
|
+
|
|
182
|
+
--dodo-ui-PasswordInput-disabled-color: var(--dodo-color-default-400);
|
|
183
|
+
--dodo-ui-PasswordInput-disabled-bg: var(--dodo-color-default-200);
|
|
184
|
+
|
|
185
|
+
--dodo-ui-PasswordInput-ToggleButton-hover: var(--dodo-color-primary-700);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
:global(.dodo-theme--dark) {
|
|
189
|
+
--dodo-ui-PasswordInput-border-color: var(--dodo-color-default-600);
|
|
190
|
+
--dodo-ui-PasswordInput-focus-border-color: var(--dodo-color-primary-600);
|
|
191
|
+
--dodo-ui-PasswordInput-error-border-color: var(--dodo-color-danger-600);
|
|
192
|
+
|
|
193
|
+
--dodo-ui-PasswordInput-disabled-bg: var(--dodo-color-default-100);
|
|
194
|
+
--dodo-ui-PasswordInput-disabled-color: var(--dodo-color-default-500);
|
|
195
|
+
|
|
196
|
+
--dodo-ui-PasswordInput-ToggleButton-hover: var(--dodo-color-primary-600);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
.dodo-ui-PasswordInput {
|
|
200
|
+
display: flex;
|
|
201
|
+
overflow: hidden;
|
|
202
|
+
color: var(--dodo-color-default-800);
|
|
203
|
+
transition: all 150ms;
|
|
204
|
+
border: 0;
|
|
205
|
+
|
|
206
|
+
input {
|
|
207
|
+
flex: 1;
|
|
208
|
+
border: 0;
|
|
209
|
+
outline: 0;
|
|
210
|
+
height: 100%;
|
|
211
|
+
background-color: transparent;
|
|
212
|
+
font-family: inherit;
|
|
213
|
+
color: inherit;
|
|
214
|
+
letter-spacing: 0.3px;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
&.outline {
|
|
218
|
+
border-style: solid;
|
|
219
|
+
border-width: var(--dodo-ui-element-border-width);
|
|
220
|
+
border-color: var(--dodo-ui-PasswordInput-border-color);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
&.focused {
|
|
224
|
+
border-color: var(--dodo-ui-PasswordInput-focus-border-color);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
&.error {
|
|
228
|
+
border-color: var(--dodo-ui-PasswordInput-error-border-color);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
&.disabled {
|
|
232
|
+
cursor: initial;
|
|
233
|
+
background-color: var(--dodo-ui-PasswordInput-disabled-bg);
|
|
234
|
+
color: var(--dodo-ui-PasswordInput-disabled-color);
|
|
235
|
+
border-color: var(--dodo-ui-PasswordInput-disabled-bg);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
.content {
|
|
239
|
+
&--after,
|
|
240
|
+
&--before {
|
|
241
|
+
&:empty {
|
|
242
|
+
display: none;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
&--after,
|
|
247
|
+
&--before {
|
|
248
|
+
display: inline-flex;
|
|
249
|
+
height: 100%;
|
|
250
|
+
align-items: center;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
&.size {
|
|
255
|
+
&--normal {
|
|
256
|
+
height: var(--dodo-ui-element-height-normal);
|
|
257
|
+
input {
|
|
258
|
+
font-size: 1rem;
|
|
259
|
+
padding: 0 12px;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
.content {
|
|
263
|
+
&--before {
|
|
264
|
+
margin-left: 12px;
|
|
265
|
+
margin-right: -4px;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
&--after {
|
|
269
|
+
margin-right: 12px;
|
|
270
|
+
margin-left: -4px;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
.passwordToggle {
|
|
275
|
+
width: var(--dodo-ui-element-height-normal);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
&--small {
|
|
280
|
+
height: var(--dodo-ui-element-height-small);
|
|
281
|
+
input {
|
|
282
|
+
padding: 0 8px;
|
|
283
|
+
font-size: 0.9rem;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
.content {
|
|
287
|
+
&--before {
|
|
288
|
+
margin-left: 8px;
|
|
289
|
+
margin-right: -2px;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
&--after {
|
|
293
|
+
margin-right: 8px;
|
|
294
|
+
margin-left: -2px;
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
.passwordToggle {
|
|
299
|
+
width: var(--dodo-ui-element-height-small);
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
&--large {
|
|
304
|
+
height: var(--dodo-ui-element-height-large);
|
|
305
|
+
input {
|
|
306
|
+
font-size: 1.1rem;
|
|
307
|
+
padding: 0 14px;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
.content {
|
|
311
|
+
&--before {
|
|
312
|
+
margin-left: 14px;
|
|
313
|
+
margin-right: -4px;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
&--after {
|
|
317
|
+
margin-right: 14px;
|
|
318
|
+
margin-left: -4px;
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
.passwordToggle {
|
|
323
|
+
width: var(--dodo-ui-element-height-large);
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
&.roundness {
|
|
329
|
+
&--1x {
|
|
330
|
+
border-radius: var(--dodo-ui-element-roundness-1x);
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
&--2x {
|
|
334
|
+
border-radius: var(--dodo-ui-element-roundness-2x);
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
&--3x {
|
|
338
|
+
border-radius: var(--dodo-ui-element-roundness-3x);
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
.passwordToggle {
|
|
343
|
+
background-color: transparent;
|
|
344
|
+
outline: 0;
|
|
345
|
+
border: 0;
|
|
346
|
+
display: inline-flex;
|
|
347
|
+
justify-content: center;
|
|
348
|
+
align-items: center;
|
|
349
|
+
height: 100%;
|
|
350
|
+
cursor: pointer;
|
|
351
|
+
padding: 0;
|
|
352
|
+
margin-right: 4px;
|
|
353
|
+
color: var(--dodo-color-default-700);
|
|
354
|
+
transition: all 150ms;
|
|
355
|
+
|
|
356
|
+
&:hover {
|
|
357
|
+
color: var(--dodo-ui-PasswordInput-ToggleButton-hover);
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
</style>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<script module>
|
|
2
|
+
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
+
import PasswordInput from '../PasswordInput.svelte';
|
|
4
|
+
import { storyPasswordInputArgTypes } from '../PasswordInput.stories.svelte';
|
|
5
|
+
|
|
6
|
+
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories
|
|
7
|
+
const { Story } = defineMeta({
|
|
8
|
+
component: PasswordInput,
|
|
9
|
+
tags: ['autodocs'],
|
|
10
|
+
argTypes: storyPasswordInputArgTypes,
|
|
11
|
+
});
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
<Story name="Roundness 1x" />
|
|
15
|
+
|
|
16
|
+
<Story name="Roundness 2x" args={{ roundness: '2x' }} />
|
|
17
|
+
|
|
18
|
+
<Story name="Roundness 3x" args={{ roundness: '3x' }} />
|
|
19
|
+
|
|
20
|
+
<Story name="Roundness False" args={{ roundness: false }} />
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<script module>
|
|
2
|
+
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
+
import PasswordInput from '../PasswordInput.svelte';
|
|
4
|
+
import { storyPasswordInputArgTypes } from '../PasswordInput.stories.svelte';
|
|
5
|
+
|
|
6
|
+
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories
|
|
7
|
+
const { Story } = defineMeta({
|
|
8
|
+
component: PasswordInput,
|
|
9
|
+
tags: ['autodocs'],
|
|
10
|
+
argTypes: storyPasswordInputArgTypes,
|
|
11
|
+
});
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
<Story name="Normal" />
|
|
15
|
+
<Story name="Small" args={{ size: 'small' }} />
|
|
16
|
+
<Story name="Large" args={{ size: 'large' }} />
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
<script module>
|
|
2
|
+
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
+
import PasswordInput from '../PasswordInput.svelte';
|
|
4
|
+
import { storyPasswordInputArgTypes } from '../PasswordInput.stories.svelte';
|
|
5
|
+
import Icon from '@iconify/svelte';
|
|
6
|
+
|
|
7
|
+
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories
|
|
8
|
+
const { Story } = defineMeta({
|
|
9
|
+
component: PasswordInput,
|
|
10
|
+
tags: ['autodocs'],
|
|
11
|
+
argTypes: storyPasswordInputArgTypes,
|
|
12
|
+
});
|
|
13
|
+
</script>
|
|
14
|
+
|
|
15
|
+
<!-- PasswordInput icon in front. -->
|
|
16
|
+
<Story name="Icon Before">
|
|
17
|
+
<PasswordInput>
|
|
18
|
+
{#snippet before()}
|
|
19
|
+
<Icon icon="material-symbols:content-copy" />
|
|
20
|
+
{/snippet}
|
|
21
|
+
</PasswordInput>
|
|
22
|
+
</Story>
|
|
23
|
+
|
|
24
|
+
<!-- PasswordInput icon in front. -->
|
|
25
|
+
<Story name="Icon After">
|
|
26
|
+
<PasswordInput>
|
|
27
|
+
{#snippet after()}
|
|
28
|
+
<Icon icon="material-symbols:download-2" />
|
|
29
|
+
{/snippet}
|
|
30
|
+
</PasswordInput>
|
|
31
|
+
</Story>
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
+
import TextInput, {
|
|
4
|
+
type TextInputClipboardEvent,
|
|
5
|
+
type TextInputFocusEvent,
|
|
6
|
+
} from '../TextInput.svelte';
|
|
7
|
+
import { storyTextInputArgTypes } from '../TextInput.stories.svelte';
|
|
8
|
+
|
|
9
|
+
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories
|
|
10
|
+
const { Story } = defineMeta({
|
|
11
|
+
component: TextInput,
|
|
12
|
+
tags: ['autodocs'],
|
|
13
|
+
argTypes: storyTextInputArgTypes,
|
|
14
|
+
});
|
|
15
|
+
</script>
|
|
16
|
+
|
|
17
|
+
<Story
|
|
18
|
+
name="Input"
|
|
19
|
+
args={{
|
|
20
|
+
oninput: (e: Event) => {
|
|
21
|
+
const target = e.target as HTMLInputElement;
|
|
22
|
+
|
|
23
|
+
console.log('Input Event', target.value);
|
|
24
|
+
},
|
|
25
|
+
}}
|
|
26
|
+
>
|
|
27
|
+
<TextInput
|
|
28
|
+
oninput={(e: Event) => {
|
|
29
|
+
const target = e.target as HTMLInputElement;
|
|
30
|
+
|
|
31
|
+
console.log('Input Event', target.value);
|
|
32
|
+
}}
|
|
33
|
+
/>
|
|
34
|
+
</Story>
|
|
35
|
+
|
|
36
|
+
<Story
|
|
37
|
+
name="Change"
|
|
38
|
+
args={{
|
|
39
|
+
onchange: (e: Event) => {
|
|
40
|
+
const target = e.target as HTMLInputElement;
|
|
41
|
+
|
|
42
|
+
console.log('onChange Event', target.value);
|
|
43
|
+
},
|
|
44
|
+
}}
|
|
45
|
+
>
|
|
46
|
+
<TextInput
|
|
47
|
+
onchange={(e: Event) => {
|
|
48
|
+
const target = e.target as HTMLInputElement;
|
|
49
|
+
|
|
50
|
+
console.log('onchange Event', target.value);
|
|
51
|
+
}}
|
|
52
|
+
/>
|
|
53
|
+
</Story>
|
|
54
|
+
|
|
55
|
+
<!-- `e: TextInputFocusEvent` -->
|
|
56
|
+
<Story
|
|
57
|
+
name="Focus"
|
|
58
|
+
args={{
|
|
59
|
+
onfocus: (e: TextInputFocusEvent) => {
|
|
60
|
+
const target = e.target as HTMLInputElement;
|
|
61
|
+
|
|
62
|
+
console.log('onfocus Event', target);
|
|
63
|
+
},
|
|
64
|
+
}}
|
|
65
|
+
>
|
|
66
|
+
<TextInput
|
|
67
|
+
onfocus={(e: TextInputFocusEvent) => {
|
|
68
|
+
const target = e.target as HTMLInputElement;
|
|
69
|
+
|
|
70
|
+
console.log('onfocus Event', target);
|
|
71
|
+
}}
|
|
72
|
+
/>
|
|
73
|
+
</Story>
|
|
74
|
+
|
|
75
|
+
<!-- `e: TextInputFocusEvent` -->
|
|
76
|
+
<Story
|
|
77
|
+
name="Blur"
|
|
78
|
+
args={{
|
|
79
|
+
onblur: (e: TextInputFocusEvent) => {
|
|
80
|
+
const target = e.target as HTMLInputElement;
|
|
81
|
+
|
|
82
|
+
console.log('onblur Event', target);
|
|
83
|
+
},
|
|
84
|
+
}}
|
|
85
|
+
>
|
|
86
|
+
<TextInput
|
|
87
|
+
onblur={(e: TextInputFocusEvent) => {
|
|
88
|
+
const target = e.target as HTMLInputElement;
|
|
89
|
+
|
|
90
|
+
console.log('onblur Event', target);
|
|
91
|
+
}}
|
|
92
|
+
/>
|
|
93
|
+
</Story>
|
|
94
|
+
|
|
95
|
+
<!-- `e: TextInputClipboardEvent` -->
|
|
96
|
+
<Story
|
|
97
|
+
name="Copy"
|
|
98
|
+
args={{
|
|
99
|
+
oncopy: (e: TextInputClipboardEvent) => {
|
|
100
|
+
const target = e.target as HTMLInputElement;
|
|
101
|
+
|
|
102
|
+
console.log('oncopy Event', target);
|
|
103
|
+
},
|
|
104
|
+
}}
|
|
105
|
+
>
|
|
106
|
+
<TextInput
|
|
107
|
+
oncopy={(e: TextInputClipboardEvent) => {
|
|
108
|
+
const target = e.target as HTMLInputElement;
|
|
109
|
+
|
|
110
|
+
console.log('oncopy Event', target);
|
|
111
|
+
}}
|
|
112
|
+
/>
|
|
113
|
+
</Story>
|
|
114
|
+
|
|
115
|
+
<!-- `e: TextInputClipboardEvent` -->
|
|
116
|
+
<Story
|
|
117
|
+
name="Cut"
|
|
118
|
+
args={{
|
|
119
|
+
oncut: (e: TextInputClipboardEvent) => {
|
|
120
|
+
const target = e.target as HTMLInputElement;
|
|
121
|
+
|
|
122
|
+
console.log('oncut Event', target);
|
|
123
|
+
},
|
|
124
|
+
}}
|
|
125
|
+
>
|
|
126
|
+
<TextInput
|
|
127
|
+
oncut={(e: TextInputClipboardEvent) => {
|
|
128
|
+
const target = e.target as HTMLInputElement;
|
|
129
|
+
|
|
130
|
+
console.log('oncut Event', target);
|
|
131
|
+
}}
|
|
132
|
+
/>
|
|
133
|
+
</Story>
|
|
134
|
+
|
|
135
|
+
<!-- `e: TextInputClipboardEvent` -->
|
|
136
|
+
<Story
|
|
137
|
+
name="Paste"
|
|
138
|
+
args={{
|
|
139
|
+
onpaste: (e: TextInputClipboardEvent) => {
|
|
140
|
+
const target = e.target as HTMLInputElement;
|
|
141
|
+
|
|
142
|
+
console.log('onpaste Event', target);
|
|
143
|
+
},
|
|
144
|
+
}}
|
|
145
|
+
>
|
|
146
|
+
<TextInput
|
|
147
|
+
onpaste={(e: TextInputClipboardEvent) => {
|
|
148
|
+
const target = e.target as HTMLInputElement;
|
|
149
|
+
|
|
150
|
+
console.log('onpaste Event', target);
|
|
151
|
+
}}
|
|
152
|
+
/>
|
|
153
|
+
</Story>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<script module>
|
|
2
|
+
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
+
import TextInput from '../TextInput.svelte';
|
|
4
|
+
import { storyTextInputArgTypes } from '../TextInput.stories.svelte';
|
|
5
|
+
|
|
6
|
+
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories
|
|
7
|
+
const { Story } = defineMeta({
|
|
8
|
+
component: TextInput,
|
|
9
|
+
tags: ['autodocs'],
|
|
10
|
+
argTypes: storyTextInputArgTypes,
|
|
11
|
+
args: { value: 'Hello world!' },
|
|
12
|
+
});
|
|
13
|
+
</script>
|
|
14
|
+
|
|
15
|
+
<Story name="Roundness 1x" />
|
|
16
|
+
|
|
17
|
+
<Story name="Roundness 2x" args={{ roundness: '2x' }} />
|
|
18
|
+
|
|
19
|
+
<Story name="Roundness 3x" args={{ roundness: '3x' }} />
|
|
20
|
+
|
|
21
|
+
<Story name="Roundness False" args={{ roundness: false }} />
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<script module>
|
|
2
|
+
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
+
import TextInput from '../TextInput.svelte';
|
|
4
|
+
import { storyTextInputArgTypes } from '../TextInput.stories.svelte';
|
|
5
|
+
|
|
6
|
+
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories
|
|
7
|
+
const { Story } = defineMeta({
|
|
8
|
+
component: TextInput,
|
|
9
|
+
tags: ['autodocs'],
|
|
10
|
+
argTypes: storyTextInputArgTypes,
|
|
11
|
+
args: { value: 'Hello world!' },
|
|
12
|
+
});
|
|
13
|
+
</script>
|
|
14
|
+
|
|
15
|
+
<Story name="Normal" />
|
|
16
|
+
<Story name="Small" args={{ size: 'small' }} />
|
|
17
|
+
<Story name="Large" args={{ size: 'large' }} />
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
+
import TextInput from './TextInput.svelte';
|
|
4
|
+
import type { StoryBookArgTypes } from '$lib/storybook-types.js';
|
|
5
|
+
|
|
6
|
+
export const storyTextInputArgTypes: StoryBookArgTypes = {
|
|
7
|
+
type: {
|
|
8
|
+
control: { type: 'select' },
|
|
9
|
+
options: ['text', 'tel', 'email', 'password', 'url', 'number'],
|
|
10
|
+
},
|
|
11
|
+
roundness: {
|
|
12
|
+
control: { type: 'select' },
|
|
13
|
+
options: [false, '1x', '2x', '3x'],
|
|
14
|
+
},
|
|
15
|
+
size: {
|
|
16
|
+
control: { type: 'select' },
|
|
17
|
+
options: ['normal', 'small', 'large'],
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories
|
|
22
|
+
const { Story } = defineMeta({
|
|
23
|
+
component: TextInput,
|
|
24
|
+
tags: ['autodocs'],
|
|
25
|
+
argTypes: storyTextInputArgTypes,
|
|
26
|
+
args: { value: 'Hello world!' },
|
|
27
|
+
});
|
|
28
|
+
</script>
|
|
29
|
+
|
|
30
|
+
<!-- TextInput with default style -->
|
|
31
|
+
<Story name="Default" />
|
|
32
|
+
|
|
33
|
+
<Story name="Placeholder" args={{ value: '', placeholder: 'Type something...' }} />
|
|
34
|
+
|
|
35
|
+
<Story name="No Outline" args={{ outline: false }} />
|
|
36
|
+
|
|
37
|
+
<Story name="Error" args={{ error: true }} />
|
|
38
|
+
|
|
39
|
+
<Story name="Disabled" args={{ disabled: true }} />
|