@flightlesslabs/dodo-ui 0.3.0 → 0.5.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 -1
- package/dist/index.js +12 -0
- package/dist/stories/components/Form/Button/Button.svelte +4 -1
- package/dist/stories/components/Form/Button/Button.svelte.d.ts +4 -2
- 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/Color/Color.stories.svelte +36 -0
- package/dist/stories/components/Form/Message/Color/Color.stories.svelte.d.ts +26 -0
- package/dist/stories/components/Form/Message/Message.stories.svelte +31 -0
- package/dist/stories/components/Form/Message/Message.stories.svelte.d.ts +21 -0
- package/dist/stories/components/Form/Message/Message.svelte +50 -0
- package/dist/stories/components/Form/Message/Message.svelte.d.ts +20 -0
- package/dist/stories/components/Form/Message/Size/Size.stories.svelte +24 -0
- package/dist/stories/components/Form/Message/Size/Size.stories.svelte.d.ts +26 -0
- package/dist/stories/components/Form/PasswordInput/PasswordInput.stories.svelte +17 -1
- package/dist/stories/components/Form/PasswordInput/PasswordInput.svelte +37 -158
- package/dist/stories/components/Form/PasswordInput/PasswordInput.svelte.d.ts +10 -7
- package/dist/stories/components/Form/SimpleSelect/Events/Events.stories.svelte +74 -0
- package/dist/stories/components/Form/SimpleSelect/Events/Events.stories.svelte.d.ts +18 -0
- package/dist/stories/components/Form/SimpleSelect/Roundness/Roundness.stories.svelte +24 -0
- package/dist/stories/components/Form/SimpleSelect/Roundness/Roundness.stories.svelte.d.ts +26 -0
- package/dist/stories/components/Form/SimpleSelect/SimpleSelect.stories.svelte +59 -0
- package/dist/stories/components/Form/SimpleSelect/SimpleSelect.stories.svelte.d.ts +23 -0
- package/dist/stories/components/Form/SimpleSelect/SimpleSelect.svelte +69 -0
- package/dist/stories/components/Form/SimpleSelect/SimpleSelect.svelte.d.ts +50 -0
- package/dist/stories/components/Form/SimpleSelect/Size/Size.stories.svelte +20 -0
- package/dist/stories/components/Form/SimpleSelect/Size/Size.stories.svelte.d.ts +26 -0
- package/dist/stories/components/Form/SimpleSelect/WithIcon/WithIcon.stories.svelte +36 -0
- package/dist/stories/components/Form/SimpleSelect/WithIcon/WithIcon.stories.svelte.d.ts +26 -0
- package/dist/stories/components/Form/TextInput/TextInput.stories.svelte +2 -0
- package/dist/stories/components/Form/TextInput/TextInput.svelte +22 -118
- package/dist/stories/components/Form/TextInput/TextInput.svelte.d.ts +7 -4
- package/dist/stories/developer tools/Intro.mdx +7 -0
- package/dist/stories/developer tools/components/InputEnclosure/InputEnclosure.stories.svelte +34 -0
- package/dist/stories/developer tools/components/InputEnclosure/InputEnclosure.stories.svelte.d.ts +21 -0
- package/dist/stories/developer tools/components/InputEnclosure/InputEnclosure.svelte +120 -0
- package/dist/stories/developer tools/components/InputEnclosure/InputEnclosure.svelte.d.ts +29 -0
- package/dist/stories/developer tools/components/InputEnclosure/Roundness/Roundness.stories.svelte +20 -0
- package/dist/stories/developer tools/components/InputEnclosure/Roundness/Roundness.stories.svelte.d.ts +26 -0
- package/dist/stories/developer tools/components/InputEnclosure/Size/Size.stories.svelte +16 -0
- package/dist/stories/developer tools/components/InputEnclosure/Size/Size.stories.svelte.d.ts +26 -0
- package/dist/stories/developer tools/components/InputEnclosure/WithIcon/WithIcon.stories.svelte +47 -0
- package/dist/stories/developer tools/components/InputEnclosure/WithIcon/WithIcon.stories.svelte.d.ts +26 -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/package.json +30 -30
- package/src/lib/index.ts +23 -1
- package/src/lib/stories/components/Form/Button/Button.svelte +8 -2
- 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/Color/Color.stories.svelte +36 -0
- package/src/lib/stories/components/Form/Message/Message.stories.svelte +35 -0
- package/src/lib/stories/components/Form/Message/Message.svelte +92 -0
- package/src/lib/stories/components/Form/Message/Size/Size.stories.svelte +24 -0
- package/src/lib/stories/components/Form/PasswordInput/PasswordInput.stories.svelte +17 -1
- package/src/lib/stories/components/Form/PasswordInput/PasswordInput.svelte +51 -196
- package/src/lib/stories/components/Form/SimpleSelect/Events/Events.stories.svelte +79 -0
- package/src/lib/stories/components/Form/SimpleSelect/Roundness/Roundness.stories.svelte +24 -0
- package/src/lib/stories/components/Form/SimpleSelect/SimpleSelect.stories.svelte +64 -0
- package/src/lib/stories/components/Form/SimpleSelect/SimpleSelect.svelte +159 -0
- package/src/lib/stories/components/Form/SimpleSelect/Size/Size.stories.svelte +20 -0
- package/src/lib/stories/components/Form/SimpleSelect/WithIcon/WithIcon.stories.svelte +36 -0
- package/src/lib/stories/components/Form/TextInput/TextInput.stories.svelte +2 -0
- package/src/lib/stories/components/Form/TextInput/TextInput.svelte +29 -142
- package/src/lib/stories/developer tools/Intro.mdx +7 -0
- package/src/lib/stories/developer tools/components/InputEnclosure/InputEnclosure.stories.svelte +38 -0
- package/src/lib/stories/developer tools/components/InputEnclosure/InputEnclosure.svelte +198 -0
- package/src/lib/stories/developer tools/components/InputEnclosure/Roundness/Roundness.stories.svelte +20 -0
- package/src/lib/stories/developer tools/components/InputEnclosure/Size/Size.stories.svelte +16 -0
- package/src/lib/stories/developer tools/components/InputEnclosure/WithIcon/WithIcon.stories.svelte +47 -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
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
export type MessageColor = 'default' | 'primary' | 'safe' | 'warning' | 'danger' | 'info';
|
|
3
|
+
</script>
|
|
4
|
+
|
|
5
|
+
<script lang="ts">
|
|
6
|
+
import type { ComponentSize } from '$lib/types.js';
|
|
7
|
+
|
|
8
|
+
import type { Snippet } from 'svelte';
|
|
9
|
+
|
|
10
|
+
interface MessageProps {
|
|
11
|
+
/** Message contents goes here */
|
|
12
|
+
children?: Snippet;
|
|
13
|
+
/** Message ref */
|
|
14
|
+
ref?: HTMLDivElement;
|
|
15
|
+
/** What color to use? */
|
|
16
|
+
color?: MessageColor;
|
|
17
|
+
/** Message size */
|
|
18
|
+
size?: ComponentSize;
|
|
19
|
+
/** Custom css class*/
|
|
20
|
+
class?: string;
|
|
21
|
+
/** Test: ⚠️ Unsafe Children String. Do Not use*/
|
|
22
|
+
_unsafeChildrenStringForTesting?: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
let {
|
|
26
|
+
children,
|
|
27
|
+
class: className = '',
|
|
28
|
+
color = 'default',
|
|
29
|
+
ref = $bindable<HTMLDivElement>(),
|
|
30
|
+
_unsafeChildrenStringForTesting,
|
|
31
|
+
size = 'normal',
|
|
32
|
+
}: MessageProps = $props();
|
|
33
|
+
</script>
|
|
34
|
+
|
|
35
|
+
<div
|
|
36
|
+
class={['dodo-ui-Message', `color--${color}`, `size--${size}`, className].join(' ')}
|
|
37
|
+
bind:this={ref}
|
|
38
|
+
>
|
|
39
|
+
{#if children}
|
|
40
|
+
{@render children()}
|
|
41
|
+
{:else if _unsafeChildrenStringForTesting}
|
|
42
|
+
{_unsafeChildrenStringForTesting}
|
|
43
|
+
{/if}
|
|
44
|
+
</div>
|
|
45
|
+
|
|
46
|
+
<style lang="scss">
|
|
47
|
+
.dodo-ui-Message {
|
|
48
|
+
letter-spacing: 0.3px;
|
|
49
|
+
display: flex;
|
|
50
|
+
font-family: inherit;
|
|
51
|
+
|
|
52
|
+
&.size {
|
|
53
|
+
&--normal {
|
|
54
|
+
font-size: 1rem;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
&--small {
|
|
58
|
+
font-size: 0.9rem;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
&--large {
|
|
62
|
+
font-size: 1.1rem;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
&.color {
|
|
67
|
+
&--default {
|
|
68
|
+
color: var(--dodo-color-default-800);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
&--primary {
|
|
72
|
+
color: var(--dodo-color-primary-600);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
&--safe {
|
|
76
|
+
color: var(--dodo-color-safe-600);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
&--warning {
|
|
80
|
+
color: var(--dodo-color-warning-600);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
&--danger {
|
|
84
|
+
color: var(--dodo-color-danger-600);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
&--info {
|
|
88
|
+
color: var(--dodo-color-info-600);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
</style>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<script module>
|
|
2
|
+
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
+
import Message from '../Message.svelte';
|
|
4
|
+
import { storyMessageArgTypes } from '../Message.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: Message,
|
|
9
|
+
tags: ['autodocs'],
|
|
10
|
+
argTypes: storyMessageArgTypes,
|
|
11
|
+
});
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
<Story name="Normal">
|
|
15
|
+
<Message>Lorem ipsum dolor sit amet, consectetur adipiscing elit</Message>
|
|
16
|
+
</Story>
|
|
17
|
+
|
|
18
|
+
<Story name="Small" args={{ size: 'small' }}>
|
|
19
|
+
<Message size="small">Lorem ipsum dolor sit amet, consectetur adipiscing elit</Message>
|
|
20
|
+
</Story>
|
|
21
|
+
|
|
22
|
+
<Story name="Large" args={{ size: 'large' }}>
|
|
23
|
+
<Message size="large">Lorem ipsum dolor sit amet, consectetur adipiscing elit</Message>
|
|
24
|
+
</Story>
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
3
|
import PasswordInput from './PasswordInput.svelte';
|
|
4
4
|
import type { StoryBookArgTypes } from '$lib/storybook-types.js';
|
|
5
|
+
import Icon from '@iconify/svelte';
|
|
5
6
|
|
|
6
7
|
export const storyPasswordInputArgTypes: StoryBookArgTypes = {
|
|
7
8
|
roundness: {
|
|
@@ -38,4 +39,19 @@
|
|
|
38
39
|
<Story name="No toggle" args={{ passwordToggle: false }} />
|
|
39
40
|
|
|
40
41
|
<!-- Show Password by default -->
|
|
41
|
-
<Story name="Show Password" args={{
|
|
42
|
+
<Story name="Show Password" args={{ passwordToggleState: true }} />
|
|
43
|
+
|
|
44
|
+
<Story name="Read only" args={{ readonly: true }} />
|
|
45
|
+
|
|
46
|
+
<!-- Show Password by default -->
|
|
47
|
+
<Story name="Custom toggle icon">
|
|
48
|
+
<PasswordInput value="Hello world!">
|
|
49
|
+
{#snippet customPasswordToggleIcon(toggle)}
|
|
50
|
+
{#if toggle}
|
|
51
|
+
<Icon icon="mingcute:eye-close-line" width="24" height="24" />
|
|
52
|
+
{:else}
|
|
53
|
+
<Icon icon="mingcute:eye-2-line" width="24" height="24" />
|
|
54
|
+
{/if}
|
|
55
|
+
{/snippet}
|
|
56
|
+
</PasswordInput>
|
|
57
|
+
</Story>
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
</script>
|
|
7
7
|
|
|
8
8
|
<script lang="ts">
|
|
9
|
-
import type { ComponentSize } from '$lib/types.js';
|
|
9
|
+
import type { ComponentRoundness, ComponentSize } from '$lib/types.js';
|
|
10
10
|
import type { Snippet } from 'svelte';
|
|
11
11
|
import type {
|
|
12
12
|
ChangeEventHandler,
|
|
@@ -14,28 +14,34 @@
|
|
|
14
14
|
FocusEventHandler,
|
|
15
15
|
FormEventHandler,
|
|
16
16
|
} from 'svelte/elements';
|
|
17
|
-
import type { TextInputFocusEvent
|
|
17
|
+
import type { TextInputFocusEvent } from '../TextInput/TextInput.svelte';
|
|
18
18
|
import Icon from '@iconify/svelte';
|
|
19
|
+
import UtilityButton from '$lib/stories/developer tools/components/UtilityButton/UtilityButton.svelte';
|
|
20
|
+
import InputEnclosure from '$lib/stories/developer tools/components/InputEnclosure/InputEnclosure.svelte';
|
|
19
21
|
|
|
20
22
|
interface PasswordInputProps {
|
|
21
23
|
/** How large should the button be? */
|
|
22
24
|
size?: ComponentSize;
|
|
25
|
+
/** Input ref */
|
|
26
|
+
ref?: HTMLInputElement;
|
|
23
27
|
/** Toggle Password */
|
|
24
28
|
passwordToggle?: boolean;
|
|
25
29
|
/** Default Password Toggle State */
|
|
26
|
-
|
|
30
|
+
passwordToggleState?: boolean;
|
|
27
31
|
/** Toggle Password Icon */
|
|
28
|
-
|
|
32
|
+
customPasswordToggleIcon?: (toggle: boolean) => Snippet;
|
|
29
33
|
/** How round should the border radius be? */
|
|
30
|
-
roundness?:
|
|
34
|
+
roundness?: ComponentRoundness | false;
|
|
31
35
|
/** Add a border around the button. Default True */
|
|
32
36
|
outline?: boolean;
|
|
33
37
|
/** Input value */
|
|
34
38
|
value?: string;
|
|
35
39
|
/** How round should the border radius be? */
|
|
36
40
|
placeholder?: string;
|
|
37
|
-
/**
|
|
41
|
+
/** disabled state */
|
|
38
42
|
disabled?: boolean;
|
|
43
|
+
/** Read only ? */
|
|
44
|
+
readonly?: boolean;
|
|
39
45
|
/** is there any associated Error ? */
|
|
40
46
|
error?: boolean;
|
|
41
47
|
/** Name */
|
|
@@ -83,17 +89,22 @@
|
|
|
83
89
|
oncut,
|
|
84
90
|
before,
|
|
85
91
|
after,
|
|
86
|
-
|
|
92
|
+
customPasswordToggleIcon,
|
|
87
93
|
error = false,
|
|
88
94
|
passwordToggle = true,
|
|
89
|
-
|
|
95
|
+
passwordToggleState = $bindable<boolean>(),
|
|
90
96
|
value = $bindable<string>(),
|
|
91
97
|
placeholder,
|
|
92
98
|
ontoggle,
|
|
99
|
+
ref = $bindable<HTMLInputElement>(),
|
|
100
|
+
readonly = false,
|
|
93
101
|
}: PasswordInputProps = $props();
|
|
94
102
|
|
|
95
103
|
let focused: boolean = $state(false);
|
|
96
|
-
let toggle: boolean = $state(
|
|
104
|
+
let toggle: boolean = $state(passwordToggleState);
|
|
105
|
+
|
|
106
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
107
|
+
let customPasswordToggleIconTyped = customPasswordToggleIcon as any;
|
|
97
108
|
|
|
98
109
|
function onfocusMod(e: TextInputFocusEvent) {
|
|
99
110
|
focused = true;
|
|
@@ -133,76 +144,41 @@
|
|
|
133
144
|
class:toggle
|
|
134
145
|
class={['dodo-ui-PasswordInput', `size--${size}`, `roundness--${roundness}`, className].join(' ')}
|
|
135
146
|
>
|
|
136
|
-
{
|
|
137
|
-
<
|
|
138
|
-
{
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
{/if}
|
|
168
|
-
|
|
169
|
-
{#if after}
|
|
170
|
-
<span class="content--after">
|
|
171
|
-
{@render after()}
|
|
172
|
-
</span>
|
|
173
|
-
{/if}
|
|
147
|
+
<InputEnclosure {outline} {disabled} {error} {focused} {size} {roundness} {before} {after}>
|
|
148
|
+
<input
|
|
149
|
+
type={passwordToggle && toggle ? 'text' : 'password'}
|
|
150
|
+
{name}
|
|
151
|
+
{id}
|
|
152
|
+
{disabled}
|
|
153
|
+
{oninput}
|
|
154
|
+
{onchange}
|
|
155
|
+
onfocus={onfocusMod}
|
|
156
|
+
onblur={onblurMod}
|
|
157
|
+
{onpaste}
|
|
158
|
+
{oncopy}
|
|
159
|
+
{oncut}
|
|
160
|
+
{placeholder}
|
|
161
|
+
bind:value
|
|
162
|
+
bind:this={ref}
|
|
163
|
+
{readonly}
|
|
164
|
+
/>
|
|
165
|
+
|
|
166
|
+
{#if passwordToggle && !disabled}
|
|
167
|
+
<UtilityButton {size} title="Toggle password" class="passwordToggle" onclick={ontoggleMod}>
|
|
168
|
+
{#if customPasswordToggleIcon}
|
|
169
|
+
{@render customPasswordToggleIconTyped(toggle)}
|
|
170
|
+
{:else if toggle}
|
|
171
|
+
<Icon icon="mdi:eye-off" width="24" height="24" />
|
|
172
|
+
{:else}
|
|
173
|
+
<Icon icon="mdi:eye" width="24" height="24" />
|
|
174
|
+
{/if}
|
|
175
|
+
</UtilityButton>
|
|
176
|
+
{/if}
|
|
177
|
+
</InputEnclosure>
|
|
174
178
|
</div>
|
|
175
179
|
|
|
176
180
|
<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
181
|
.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
182
|
input {
|
|
207
183
|
flex: 1;
|
|
208
184
|
border: 0;
|
|
@@ -214,147 +190,26 @@
|
|
|
214
190
|
letter-spacing: 0.3px;
|
|
215
191
|
}
|
|
216
192
|
|
|
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
193
|
&.size {
|
|
255
194
|
&--normal {
|
|
256
|
-
height: var(--dodo-ui-element-height-normal);
|
|
257
195
|
input {
|
|
258
196
|
font-size: 1rem;
|
|
259
197
|
padding: 0 12px;
|
|
260
198
|
}
|
|
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
199
|
}
|
|
278
200
|
|
|
279
201
|
&--small {
|
|
280
|
-
height: var(--dodo-ui-element-height-small);
|
|
281
202
|
input {
|
|
282
203
|
padding: 0 8px;
|
|
283
204
|
font-size: 0.9rem;
|
|
284
205
|
}
|
|
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
206
|
}
|
|
302
207
|
|
|
303
208
|
&--large {
|
|
304
|
-
height: var(--dodo-ui-element-height-large);
|
|
305
209
|
input {
|
|
306
210
|
font-size: 1.1rem;
|
|
307
211
|
padding: 0 14px;
|
|
308
212
|
}
|
|
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
213
|
}
|
|
359
214
|
}
|
|
360
215
|
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
+
import { type SimpleSelectFocusEvent } from '../SimpleSelect.svelte';
|
|
4
|
+
import SimpleSelect from '../SimpleSelect.svelte';
|
|
5
|
+
import {
|
|
6
|
+
storySimpleSelectArgTypes,
|
|
7
|
+
storySimpleSelectOptions,
|
|
8
|
+
} from '../SimpleSelect.stories.svelte';
|
|
9
|
+
|
|
10
|
+
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories
|
|
11
|
+
const { Story } = defineMeta({
|
|
12
|
+
component: SimpleSelect,
|
|
13
|
+
tags: ['autodocs'],
|
|
14
|
+
argTypes: storySimpleSelectArgTypes,
|
|
15
|
+
args: { options: storySimpleSelectOptions },
|
|
16
|
+
});
|
|
17
|
+
</script>
|
|
18
|
+
|
|
19
|
+
<Story
|
|
20
|
+
name="Change"
|
|
21
|
+
args={{
|
|
22
|
+
onchange: (e: Event) => {
|
|
23
|
+
const target = e.target as HTMLSelectElement;
|
|
24
|
+
|
|
25
|
+
console.log('onChange Event', target.value);
|
|
26
|
+
},
|
|
27
|
+
}}
|
|
28
|
+
>
|
|
29
|
+
<SimpleSelect
|
|
30
|
+
onchange={(e: Event) => {
|
|
31
|
+
const target = e.target as HTMLSelectElement;
|
|
32
|
+
|
|
33
|
+
console.log('onchange Event', target.value);
|
|
34
|
+
}}
|
|
35
|
+
options={storySimpleSelectOptions}
|
|
36
|
+
/>
|
|
37
|
+
</Story>
|
|
38
|
+
|
|
39
|
+
<!-- `e: SimpleSelectFocusEvent` -->
|
|
40
|
+
<Story
|
|
41
|
+
name="Focus"
|
|
42
|
+
args={{
|
|
43
|
+
onfocus: (e: SimpleSelectFocusEvent) => {
|
|
44
|
+
const target = e.target as HTMLSelectElement;
|
|
45
|
+
|
|
46
|
+
console.log('onfocus Event', target);
|
|
47
|
+
},
|
|
48
|
+
}}
|
|
49
|
+
>
|
|
50
|
+
<SimpleSelect
|
|
51
|
+
onfocus={(e: SimpleSelectFocusEvent) => {
|
|
52
|
+
const target = e.target as HTMLSelectElement;
|
|
53
|
+
|
|
54
|
+
console.log('onfocus Event', target);
|
|
55
|
+
}}
|
|
56
|
+
options={storySimpleSelectOptions}
|
|
57
|
+
/>
|
|
58
|
+
</Story>
|
|
59
|
+
|
|
60
|
+
<!-- `e: SimpleSelectFocusEvent` -->
|
|
61
|
+
<Story
|
|
62
|
+
name="Blur"
|
|
63
|
+
args={{
|
|
64
|
+
onblur: (e: SimpleSelectFocusEvent) => {
|
|
65
|
+
const target = e.target as HTMLSelectElement;
|
|
66
|
+
|
|
67
|
+
console.log('onblur Event', target);
|
|
68
|
+
},
|
|
69
|
+
}}
|
|
70
|
+
>
|
|
71
|
+
<SimpleSelect
|
|
72
|
+
onblur={(e: SimpleSelectFocusEvent) => {
|
|
73
|
+
const target = e.target as HTMLSelectElement;
|
|
74
|
+
|
|
75
|
+
console.log('onblur Event', target);
|
|
76
|
+
}}
|
|
77
|
+
options={storySimpleSelectOptions}
|
|
78
|
+
/>
|
|
79
|
+
</Story>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<script module>
|
|
2
|
+
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
+
import SimpleSelect from '../SimpleSelect.svelte';
|
|
4
|
+
import {
|
|
5
|
+
storySimpleSelectArgTypes,
|
|
6
|
+
storySimpleSelectOptions,
|
|
7
|
+
} from '../SimpleSelect.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: SimpleSelect,
|
|
12
|
+
tags: ['autodocs'],
|
|
13
|
+
argTypes: storySimpleSelectArgTypes,
|
|
14
|
+
args: { options: storySimpleSelectOptions },
|
|
15
|
+
});
|
|
16
|
+
</script>
|
|
17
|
+
|
|
18
|
+
<Story name="Roundness 1x" />
|
|
19
|
+
|
|
20
|
+
<Story name="Roundness 2x" args={{ roundness: '2x' }} />
|
|
21
|
+
|
|
22
|
+
<Story name="Roundness 3x" args={{ roundness: '3x' }} />
|
|
23
|
+
|
|
24
|
+
<Story name="Roundness False" args={{ roundness: false }} />
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
+
import { type SimpleSelectOption } from './SimpleSelect.svelte';
|
|
4
|
+
import type { StoryBookArgTypes } from '$lib/storybook-types.js';
|
|
5
|
+
import SimpleSelect from './SimpleSelect.svelte';
|
|
6
|
+
|
|
7
|
+
export const storySimpleSelectArgTypes: StoryBookArgTypes = {
|
|
8
|
+
type: {
|
|
9
|
+
control: { type: 'select' },
|
|
10
|
+
options: ['text', 'tel', 'email', 'password', 'url', 'number'],
|
|
11
|
+
},
|
|
12
|
+
roundness: {
|
|
13
|
+
control: { type: 'select' },
|
|
14
|
+
options: [false, '1x', '2x', '3x'],
|
|
15
|
+
},
|
|
16
|
+
size: {
|
|
17
|
+
control: { type: 'select' },
|
|
18
|
+
options: ['normal', 'small', 'large'],
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export const storySimpleSelectOptions: SimpleSelectOption[] = [
|
|
23
|
+
{
|
|
24
|
+
value: 'volvo',
|
|
25
|
+
label: 'Volvo',
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
value: 'saab',
|
|
29
|
+
label: 'Saab',
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
value: 'mercedes',
|
|
33
|
+
label: 'Mercedes',
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
value: 'audi',
|
|
37
|
+
label: 'Audi',
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
value: 'opel',
|
|
41
|
+
label: 'Opel',
|
|
42
|
+
disabled: true,
|
|
43
|
+
},
|
|
44
|
+
];
|
|
45
|
+
|
|
46
|
+
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories
|
|
47
|
+
const { Story } = defineMeta({
|
|
48
|
+
component: SimpleSelect,
|
|
49
|
+
tags: ['autodocs'],
|
|
50
|
+
argTypes: storySimpleSelectArgTypes,
|
|
51
|
+
args: { options: storySimpleSelectOptions },
|
|
52
|
+
});
|
|
53
|
+
</script>
|
|
54
|
+
|
|
55
|
+
<!-- SimpleSelect with default style -->
|
|
56
|
+
<Story name="Default" />
|
|
57
|
+
|
|
58
|
+
<Story name="Placeholder" args={{ value: '', placeholder: 'Type something...' }} />
|
|
59
|
+
|
|
60
|
+
<Story name="No Outline" args={{ outline: false }} />
|
|
61
|
+
|
|
62
|
+
<Story name="Error" args={{ error: true }} />
|
|
63
|
+
|
|
64
|
+
<Story name="Disabled" args={{ disabled: true }} />
|