@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,159 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
export type SimpleSelectFocusEvent = FocusEvent & {
|
|
3
|
+
currentTarget: EventTarget & HTMLSelectElement;
|
|
4
|
+
};
|
|
5
|
+
|
|
6
|
+
export type SimpleSelectOption = {
|
|
7
|
+
value: string;
|
|
8
|
+
label: string;
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
};
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<script lang="ts">
|
|
14
|
+
import InputEnclosure from '$lib/stories/developer tools/components/InputEnclosure/InputEnclosure.svelte';
|
|
15
|
+
|
|
16
|
+
import type { ComponentRoundness, ComponentSize } from '$lib/types.js';
|
|
17
|
+
import type { Snippet } from 'svelte';
|
|
18
|
+
import type { ChangeEventHandler, FocusEventHandler } from 'svelte/elements';
|
|
19
|
+
|
|
20
|
+
interface SimpleSelectProps {
|
|
21
|
+
/** Select ref */
|
|
22
|
+
ref?: HTMLSelectElement;
|
|
23
|
+
/** How large should the button be? */
|
|
24
|
+
size?: ComponentSize;
|
|
25
|
+
/** How round should the border radius be? */
|
|
26
|
+
roundness?: ComponentRoundness | false;
|
|
27
|
+
/** How round should the border radius be? */
|
|
28
|
+
options: SimpleSelectOption[];
|
|
29
|
+
/** Add a border around the button. Default True */
|
|
30
|
+
outline?: boolean;
|
|
31
|
+
/** Select value */
|
|
32
|
+
value?: string;
|
|
33
|
+
/** How round should the border radius be? */
|
|
34
|
+
placeholder?: string;
|
|
35
|
+
/** disabled state */
|
|
36
|
+
disabled?: boolean;
|
|
37
|
+
/** is there any associated Error ? */
|
|
38
|
+
error?: boolean;
|
|
39
|
+
/** Name */
|
|
40
|
+
name?: string;
|
|
41
|
+
/** Id */
|
|
42
|
+
id?: string;
|
|
43
|
+
/** Icon before button content */
|
|
44
|
+
before?: Snippet;
|
|
45
|
+
/** Icon after button content */
|
|
46
|
+
after?: Snippet;
|
|
47
|
+
/** Custom css class*/
|
|
48
|
+
class?: string;
|
|
49
|
+
/** onchange event handler */
|
|
50
|
+
onchange?: ChangeEventHandler<HTMLSelectElement>;
|
|
51
|
+
/** onblur event handler */
|
|
52
|
+
onblur?: FocusEventHandler<HTMLSelectElement>;
|
|
53
|
+
/** onfocus event handler */
|
|
54
|
+
onfocus?: FocusEventHandler<HTMLSelectElement>;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
let {
|
|
58
|
+
size = 'normal',
|
|
59
|
+
roundness = '1x',
|
|
60
|
+
outline = true,
|
|
61
|
+
name,
|
|
62
|
+
id,
|
|
63
|
+
class: className = '',
|
|
64
|
+
disabled = false,
|
|
65
|
+
onchange,
|
|
66
|
+
onblur,
|
|
67
|
+
onfocus,
|
|
68
|
+
before,
|
|
69
|
+
after,
|
|
70
|
+
error = false,
|
|
71
|
+
value,
|
|
72
|
+
placeholder,
|
|
73
|
+
ref = $bindable<HTMLSelectElement>(),
|
|
74
|
+
options,
|
|
75
|
+
}: SimpleSelectProps = $props();
|
|
76
|
+
|
|
77
|
+
let focused: boolean = $state(false);
|
|
78
|
+
|
|
79
|
+
function onfocusMod(e: SimpleSelectFocusEvent) {
|
|
80
|
+
focused = true;
|
|
81
|
+
|
|
82
|
+
if (onfocus) {
|
|
83
|
+
onfocus(e);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function onblurMod(e: SimpleSelectFocusEvent) {
|
|
88
|
+
focused = false;
|
|
89
|
+
|
|
90
|
+
if (onblur) {
|
|
91
|
+
onblur(e);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
</script>
|
|
95
|
+
|
|
96
|
+
<div
|
|
97
|
+
class:outline
|
|
98
|
+
class:disabled
|
|
99
|
+
class:error
|
|
100
|
+
class:focused
|
|
101
|
+
class={['dodo-ui-SimpleSelect', `size--${size}`, `roundness--${roundness}`, className].join(' ')}
|
|
102
|
+
>
|
|
103
|
+
<InputEnclosure {outline} {disabled} {error} {focused} {size} {roundness} {before} {after}>
|
|
104
|
+
<select
|
|
105
|
+
{name}
|
|
106
|
+
{id}
|
|
107
|
+
{disabled}
|
|
108
|
+
{onchange}
|
|
109
|
+
onfocus={onfocusMod}
|
|
110
|
+
onblur={onblurMod}
|
|
111
|
+
{placeholder}
|
|
112
|
+
bind:this={ref}
|
|
113
|
+
>
|
|
114
|
+
{#each options as option (option.value)}
|
|
115
|
+
<option value={option.value} disabled={option.disabled} selected={value === option.value}>
|
|
116
|
+
{option.label}
|
|
117
|
+
</option>
|
|
118
|
+
{/each}
|
|
119
|
+
</select>
|
|
120
|
+
</InputEnclosure>
|
|
121
|
+
</div>
|
|
122
|
+
|
|
123
|
+
<style lang="scss">
|
|
124
|
+
.dodo-ui-SimpleSelect {
|
|
125
|
+
select {
|
|
126
|
+
flex: 1;
|
|
127
|
+
border: 0;
|
|
128
|
+
outline: 0;
|
|
129
|
+
height: 100%;
|
|
130
|
+
background-color: transparent;
|
|
131
|
+
font-family: inherit;
|
|
132
|
+
color: inherit;
|
|
133
|
+
letter-spacing: 0.3px;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
&.size {
|
|
137
|
+
&--normal {
|
|
138
|
+
select {
|
|
139
|
+
font-size: 1rem;
|
|
140
|
+
padding: 0 12px;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
&--small {
|
|
145
|
+
select {
|
|
146
|
+
padding: 0 8px;
|
|
147
|
+
font-size: 0.9rem;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
&--large {
|
|
152
|
+
select {
|
|
153
|
+
font-size: 1.1rem;
|
|
154
|
+
padding: 0 14px;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
</style>
|
|
@@ -0,0 +1,20 @@
|
|
|
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="Normal" />
|
|
19
|
+
<Story name="Small" args={{ size: 'small' }} />
|
|
20
|
+
<Story name="Large" args={{ size: 'large' }} />
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
<script module>
|
|
2
|
+
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
+
import Icon from '@iconify/svelte';
|
|
4
|
+
|
|
5
|
+
import SimpleSelect from '../SimpleSelect.svelte';
|
|
6
|
+
import {
|
|
7
|
+
storySimpleSelectArgTypes,
|
|
8
|
+
storySimpleSelectOptions,
|
|
9
|
+
} from '../SimpleSelect.stories.svelte';
|
|
10
|
+
|
|
11
|
+
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories
|
|
12
|
+
const { Story } = defineMeta({
|
|
13
|
+
component: SimpleSelect,
|
|
14
|
+
tags: ['autodocs'],
|
|
15
|
+
argTypes: storySimpleSelectArgTypes,
|
|
16
|
+
args: { options: storySimpleSelectOptions },
|
|
17
|
+
});
|
|
18
|
+
</script>
|
|
19
|
+
|
|
20
|
+
<!-- SimpleSelect icon in front. -->
|
|
21
|
+
<Story name="Icon Before">
|
|
22
|
+
<SimpleSelect options={storySimpleSelectOptions}>
|
|
23
|
+
{#snippet before()}
|
|
24
|
+
<Icon icon="material-symbols:content-copy" />
|
|
25
|
+
{/snippet}
|
|
26
|
+
</SimpleSelect>
|
|
27
|
+
</Story>
|
|
28
|
+
|
|
29
|
+
<!-- SimpleSelect icon in front. -->
|
|
30
|
+
<Story name="Icon After">
|
|
31
|
+
<SimpleSelect options={storySimpleSelectOptions}>
|
|
32
|
+
{#snippet after()}
|
|
33
|
+
<Icon icon="material-symbols:download-2" />
|
|
34
|
+
{/snippet}
|
|
35
|
+
</SimpleSelect>
|
|
36
|
+
</Story>
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
<script lang="ts" module>
|
|
2
|
-
export type TextInputRoundness = ComponentRoundness | false;
|
|
3
2
|
export type TextInputType = 'text' | 'tel' | 'email' | 'password' | 'url' | 'number';
|
|
4
3
|
|
|
5
4
|
export type TextInputFocusEvent = FocusEvent & {
|
|
@@ -12,6 +11,8 @@
|
|
|
12
11
|
</script>
|
|
13
12
|
|
|
14
13
|
<script lang="ts">
|
|
14
|
+
import InputEnclosure from '$lib/stories/developer tools/components/InputEnclosure/InputEnclosure.svelte';
|
|
15
|
+
|
|
15
16
|
import type { ComponentRoundness, ComponentSize } from '$lib/types.js';
|
|
16
17
|
import type { Snippet } from 'svelte';
|
|
17
18
|
import type {
|
|
@@ -24,18 +25,22 @@
|
|
|
24
25
|
interface TextInputProps {
|
|
25
26
|
/** Input type? */
|
|
26
27
|
type?: TextInputType;
|
|
28
|
+
/** Input ref */
|
|
29
|
+
ref?: HTMLInputElement;
|
|
27
30
|
/** How large should the button be? */
|
|
28
31
|
size?: ComponentSize;
|
|
29
32
|
/** How round should the border radius be? */
|
|
30
|
-
roundness?:
|
|
33
|
+
roundness?: ComponentRoundness | false;
|
|
31
34
|
/** Add a border around the button. Default True */
|
|
32
35
|
outline?: boolean;
|
|
33
36
|
/** Input value */
|
|
34
37
|
value?: string;
|
|
35
38
|
/** How round should the border radius be? */
|
|
36
39
|
placeholder?: string;
|
|
37
|
-
/**
|
|
40
|
+
/** disabled state */
|
|
38
41
|
disabled?: boolean;
|
|
42
|
+
/** Read only ? */
|
|
43
|
+
readonly?: boolean;
|
|
39
44
|
/** is there any associated Error ? */
|
|
40
45
|
error?: boolean;
|
|
41
46
|
/** Name */
|
|
@@ -85,6 +90,8 @@
|
|
|
85
90
|
error = false,
|
|
86
91
|
value = $bindable<string>(),
|
|
87
92
|
placeholder,
|
|
93
|
+
ref = $bindable<HTMLInputElement>(),
|
|
94
|
+
readonly = false,
|
|
88
95
|
}: TextInputProps = $props();
|
|
89
96
|
|
|
90
97
|
let focused: boolean = $state(false);
|
|
@@ -113,59 +120,29 @@
|
|
|
113
120
|
class:focused
|
|
114
121
|
class={['dodo-ui-TextInput', `size--${size}`, `roundness--${roundness}`, className].join(' ')}
|
|
115
122
|
>
|
|
116
|
-
{
|
|
117
|
-
<
|
|
118
|
-
{
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
/>
|
|
136
|
-
{#if after}
|
|
137
|
-
<span class="content--after">
|
|
138
|
-
{@render after()}
|
|
139
|
-
</span>
|
|
140
|
-
{/if}
|
|
123
|
+
<InputEnclosure {outline} {disabled} {error} {focused} {size} {roundness} {before} {after}>
|
|
124
|
+
<input
|
|
125
|
+
{type}
|
|
126
|
+
{name}
|
|
127
|
+
{id}
|
|
128
|
+
{disabled}
|
|
129
|
+
{oninput}
|
|
130
|
+
{onchange}
|
|
131
|
+
onfocus={onfocusMod}
|
|
132
|
+
onblur={onblurMod}
|
|
133
|
+
{onpaste}
|
|
134
|
+
{oncopy}
|
|
135
|
+
{oncut}
|
|
136
|
+
{placeholder}
|
|
137
|
+
{readonly}
|
|
138
|
+
bind:value
|
|
139
|
+
bind:this={ref}
|
|
140
|
+
/>
|
|
141
|
+
</InputEnclosure>
|
|
141
142
|
</div>
|
|
142
143
|
|
|
143
144
|
<style lang="scss">
|
|
144
|
-
:global(:root) {
|
|
145
|
-
--dodo-ui-TextInput-border-color: var(--dodo-color-default-500);
|
|
146
|
-
--dodo-ui-TextInput-focus-border-color: var(--dodo-color-primary-500);
|
|
147
|
-
--dodo-ui-TextInput-error-border-color: var(--dodo-color-danger-500);
|
|
148
|
-
|
|
149
|
-
--dodo-ui-TextInput-disabled-color: var(--dodo-color-default-400);
|
|
150
|
-
--dodo-ui-TextInput-disabled-bg: var(--dodo-color-default-200);
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
:global(.dodo-theme--dark) {
|
|
154
|
-
--dodo-ui-TextInput-border-color: var(--dodo-color-default-600);
|
|
155
|
-
--dodo-ui-TextInput-focus-border-color: var(--dodo-color-primary-600);
|
|
156
|
-
--dodo-ui-TextInput-error-border-color: var(--dodo-color-danger-600);
|
|
157
|
-
|
|
158
|
-
--dodo-ui-TextInput-disabled-bg: var(--dodo-color-default-100);
|
|
159
|
-
--dodo-ui-TextInput-disabled-color: var(--dodo-color-default-500);
|
|
160
|
-
}
|
|
161
|
-
|
|
162
145
|
.dodo-ui-TextInput {
|
|
163
|
-
display: flex;
|
|
164
|
-
overflow: hidden;
|
|
165
|
-
color: var(--dodo-color-default-800);
|
|
166
|
-
transition: all 150ms;
|
|
167
|
-
border: 0;
|
|
168
|
-
|
|
169
146
|
input {
|
|
170
147
|
flex: 1;
|
|
171
148
|
border: 0;
|
|
@@ -177,116 +154,26 @@
|
|
|
177
154
|
letter-spacing: 0.3px;
|
|
178
155
|
}
|
|
179
156
|
|
|
180
|
-
&.outline {
|
|
181
|
-
border-style: solid;
|
|
182
|
-
border-width: var(--dodo-ui-element-border-width);
|
|
183
|
-
border-color: var(--dodo-ui-TextInput-border-color);
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
&.focused {
|
|
187
|
-
border-color: var(--dodo-ui-TextInput-focus-border-color);
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
&.error {
|
|
191
|
-
border-color: var(--dodo-ui-TextInput-error-border-color);
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
&.disabled {
|
|
195
|
-
cursor: initial;
|
|
196
|
-
background-color: var(--dodo-ui-TextInput-disabled-bg);
|
|
197
|
-
color: var(--dodo-ui-TextInput-disabled-color);
|
|
198
|
-
border-color: var(--dodo-ui-TextInput-disabled-bg);
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
.content {
|
|
202
|
-
&--after,
|
|
203
|
-
&--before {
|
|
204
|
-
&:empty {
|
|
205
|
-
display: none;
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
&--after,
|
|
210
|
-
&--before {
|
|
211
|
-
display: inline-flex;
|
|
212
|
-
height: 100%;
|
|
213
|
-
align-items: center;
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
|
|
217
157
|
&.size {
|
|
218
158
|
&--normal {
|
|
219
|
-
height: var(--dodo-ui-element-height-normal);
|
|
220
159
|
input {
|
|
221
160
|
font-size: 1rem;
|
|
222
161
|
padding: 0 12px;
|
|
223
162
|
}
|
|
224
|
-
|
|
225
|
-
.content {
|
|
226
|
-
&--before {
|
|
227
|
-
margin-left: 12px;
|
|
228
|
-
margin-right: -4px;
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
&--after {
|
|
232
|
-
margin-right: 12px;
|
|
233
|
-
margin-left: -4px;
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
163
|
}
|
|
237
164
|
|
|
238
165
|
&--small {
|
|
239
|
-
height: var(--dodo-ui-element-height-small);
|
|
240
166
|
input {
|
|
241
167
|
padding: 0 8px;
|
|
242
168
|
font-size: 0.9rem;
|
|
243
169
|
}
|
|
244
|
-
|
|
245
|
-
.content {
|
|
246
|
-
&--before {
|
|
247
|
-
margin-left: 8px;
|
|
248
|
-
margin-right: -2px;
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
&--after {
|
|
252
|
-
margin-right: 8px;
|
|
253
|
-
margin-left: -2px;
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
170
|
}
|
|
257
171
|
|
|
258
172
|
&--large {
|
|
259
|
-
height: var(--dodo-ui-element-height-large);
|
|
260
173
|
input {
|
|
261
174
|
font-size: 1.1rem;
|
|
262
175
|
padding: 0 14px;
|
|
263
176
|
}
|
|
264
|
-
|
|
265
|
-
.content {
|
|
266
|
-
&--before {
|
|
267
|
-
margin-left: 14px;
|
|
268
|
-
margin-right: -4px;
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
&--after {
|
|
272
|
-
margin-right: 14px;
|
|
273
|
-
margin-left: -4px;
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
&.roundness {
|
|
280
|
-
&--1x {
|
|
281
|
-
border-radius: var(--dodo-ui-element-roundness-1x);
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
&--2x {
|
|
285
|
-
border-radius: var(--dodo-ui-element-roundness-2x);
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
&--3x {
|
|
289
|
-
border-radius: var(--dodo-ui-element-roundness-3x);
|
|
290
177
|
}
|
|
291
178
|
}
|
|
292
179
|
}
|
package/src/lib/stories/developer tools/components/InputEnclosure/InputEnclosure.stories.svelte
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
+
import InputEnclosure from './InputEnclosure.svelte';
|
|
4
|
+
import type { StoryBookArgTypes } from '$lib/storybook-types.js';
|
|
5
|
+
|
|
6
|
+
export const storyInputEnclosureArgTypes: 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: InputEnclosure,
|
|
20
|
+
tags: ['autodocs'],
|
|
21
|
+
argTypes: storyInputEnclosureArgTypes,
|
|
22
|
+
});
|
|
23
|
+
</script>
|
|
24
|
+
|
|
25
|
+
<!-- An ensloure for Form Inputs [TextInput](?path=/docs/components-form-textinput--docs) -->
|
|
26
|
+
<Story name="Default" />
|
|
27
|
+
|
|
28
|
+
<Story name="Focused" args={{ focused: true }} />
|
|
29
|
+
|
|
30
|
+
<Story name="Error" args={{ error: true }} />
|
|
31
|
+
|
|
32
|
+
<Story name="Disabled" args={{ disabled: true }} />
|
|
33
|
+
|
|
34
|
+
<Story name="Input example">
|
|
35
|
+
<InputEnclosure>
|
|
36
|
+
<input type="text" style="flex: 1; border: 0;" placeholder="Enter name" />
|
|
37
|
+
</InputEnclosure>
|
|
38
|
+
</Story>
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { ComponentRoundness, ComponentSize } from '$lib/types.js';
|
|
3
|
+
import type { Snippet } from 'svelte';
|
|
4
|
+
|
|
5
|
+
interface InputEnclosureProps {
|
|
6
|
+
/** InputEnclosure contents goes here */
|
|
7
|
+
children?: Snippet;
|
|
8
|
+
/** InputEnclosure ref */
|
|
9
|
+
ref?: HTMLDivElement;
|
|
10
|
+
/** How large should the button be? */
|
|
11
|
+
size?: ComponentSize;
|
|
12
|
+
/** How round should the border radius be? */
|
|
13
|
+
roundness?: ComponentRoundness | false;
|
|
14
|
+
/** Add a border around the button. Default True */
|
|
15
|
+
outline?: boolean;
|
|
16
|
+
/** disabled state */
|
|
17
|
+
disabled?: boolean;
|
|
18
|
+
/** is there any associated Error ? */
|
|
19
|
+
error?: boolean;
|
|
20
|
+
/** is focused */
|
|
21
|
+
focused?: boolean;
|
|
22
|
+
/** Icon before button content */
|
|
23
|
+
before?: Snippet;
|
|
24
|
+
/** Icon after button content */
|
|
25
|
+
after?: Snippet;
|
|
26
|
+
/** Custom css class*/
|
|
27
|
+
class?: string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
let {
|
|
31
|
+
size = 'normal',
|
|
32
|
+
roundness = '1x',
|
|
33
|
+
outline = true,
|
|
34
|
+
class: className = '',
|
|
35
|
+
disabled = false,
|
|
36
|
+
before,
|
|
37
|
+
after,
|
|
38
|
+
error = false,
|
|
39
|
+
focused = false,
|
|
40
|
+
children,
|
|
41
|
+
ref = $bindable<HTMLDivElement>(),
|
|
42
|
+
}: InputEnclosureProps = $props();
|
|
43
|
+
</script>
|
|
44
|
+
|
|
45
|
+
<div
|
|
46
|
+
class:outline
|
|
47
|
+
class:disabled
|
|
48
|
+
class:error
|
|
49
|
+
class:focused
|
|
50
|
+
class={['dodo-ui-InputEnclosure', `size--${size}`, `roundness--${roundness}`, className].join(
|
|
51
|
+
' ',
|
|
52
|
+
)}
|
|
53
|
+
bind:this={ref}
|
|
54
|
+
>
|
|
55
|
+
{#if before}
|
|
56
|
+
<span class="content--before">
|
|
57
|
+
{@render before()}
|
|
58
|
+
</span>
|
|
59
|
+
{/if}
|
|
60
|
+
|
|
61
|
+
{#if children}
|
|
62
|
+
{@render children()}
|
|
63
|
+
{/if}
|
|
64
|
+
{#if after}
|
|
65
|
+
<span class="content--after">
|
|
66
|
+
{@render after()}
|
|
67
|
+
</span>
|
|
68
|
+
{/if}
|
|
69
|
+
</div>
|
|
70
|
+
|
|
71
|
+
<style lang="scss">
|
|
72
|
+
:global(:root) {
|
|
73
|
+
--dodo-ui-InputEnclosure-border-color: var(--dodo-color-default-500);
|
|
74
|
+
--dodo-ui-InputEnclosure-focus-border-color: var(--dodo-color-primary-500);
|
|
75
|
+
--dodo-ui-InputEnclosure-error-border-color: var(--dodo-color-danger-500);
|
|
76
|
+
|
|
77
|
+
--dodo-ui-InputEnclosure-disabled-color: var(--dodo-color-default-400);
|
|
78
|
+
--dodo-ui-InputEnclosure-disabled-bg: var(--dodo-color-default-200);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
:global(.dodo-theme--dark) {
|
|
82
|
+
--dodo-ui-InputEnclosure-border-color: var(--dodo-color-default-600);
|
|
83
|
+
--dodo-ui-InputEnclosure-focus-border-color: var(--dodo-color-primary-600);
|
|
84
|
+
--dodo-ui-InputEnclosure-error-border-color: var(--dodo-color-danger-600);
|
|
85
|
+
|
|
86
|
+
--dodo-ui-InputEnclosure-disabled-bg: var(--dodo-color-default-100);
|
|
87
|
+
--dodo-ui-InputEnclosure-disabled-color: var(--dodo-color-default-500);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.dodo-ui-InputEnclosure {
|
|
91
|
+
display: flex;
|
|
92
|
+
overflow: hidden;
|
|
93
|
+
color: var(--dodo-color-default-800);
|
|
94
|
+
transition: all 150ms;
|
|
95
|
+
border: 0;
|
|
96
|
+
|
|
97
|
+
&.outline {
|
|
98
|
+
border-style: solid;
|
|
99
|
+
border-width: var(--dodo-ui-element-border-width);
|
|
100
|
+
border-color: var(--dodo-ui-InputEnclosure-border-color);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
&.focused {
|
|
104
|
+
border-color: var(--dodo-ui-InputEnclosure-focus-border-color);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
&.error {
|
|
108
|
+
border-color: var(--dodo-ui-InputEnclosure-error-border-color);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
&.disabled {
|
|
112
|
+
cursor: initial;
|
|
113
|
+
background-color: var(--dodo-ui-InputEnclosure-disabled-bg);
|
|
114
|
+
color: var(--dodo-ui-InputEnclosure-disabled-color);
|
|
115
|
+
border-color: var(--dodo-ui-InputEnclosure-disabled-bg);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
.content {
|
|
119
|
+
&--after,
|
|
120
|
+
&--before {
|
|
121
|
+
&:empty {
|
|
122
|
+
display: none;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
&--after,
|
|
127
|
+
&--before {
|
|
128
|
+
display: inline-flex;
|
|
129
|
+
height: 100%;
|
|
130
|
+
align-items: center;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
&.size {
|
|
135
|
+
&--normal {
|
|
136
|
+
height: var(--dodo-ui-element-height-normal);
|
|
137
|
+
|
|
138
|
+
.content {
|
|
139
|
+
&--before {
|
|
140
|
+
margin-left: 12px;
|
|
141
|
+
margin-right: -4px;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
&--after {
|
|
145
|
+
margin-right: 12px;
|
|
146
|
+
margin-left: -4px;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
&--small {
|
|
152
|
+
height: var(--dodo-ui-element-height-small);
|
|
153
|
+
|
|
154
|
+
.content {
|
|
155
|
+
&--before {
|
|
156
|
+
margin-left: 8px;
|
|
157
|
+
margin-right: -2px;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
&--after {
|
|
161
|
+
margin-right: 8px;
|
|
162
|
+
margin-left: -2px;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
&--large {
|
|
168
|
+
height: var(--dodo-ui-element-height-large);
|
|
169
|
+
|
|
170
|
+
.content {
|
|
171
|
+
&--before {
|
|
172
|
+
margin-left: 14px;
|
|
173
|
+
margin-right: -4px;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
&--after {
|
|
177
|
+
margin-right: 14px;
|
|
178
|
+
margin-left: -4px;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
&.roundness {
|
|
185
|
+
&--1x {
|
|
186
|
+
border-radius: var(--dodo-ui-element-roundness-1x);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
&--2x {
|
|
190
|
+
border-radius: var(--dodo-ui-element-roundness-2x);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
&--3x {
|
|
194
|
+
border-radius: var(--dodo-ui-element-roundness-3x);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
</style>
|