@flightlesslabs/dodo-ui 0.2.0 → 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 +1 -1
- package/dist/stories/components/Form/Button/Button.stories.svelte +10 -5
- package/dist/stories/components/Form/Button/Button.svelte +213 -208
- 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/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/styles/_components.css +8 -7
- package/dist/styles/_minimal-reset.css +3 -0
- package/dist/styles/global.css +1 -0
- package/package.json +1 -1
- 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 +32 -22
- package/src/lib/stories/components/Form/Button/Events/Events.stories.svelte +42 -0
- 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/_components.css +8 -7
- package/src/lib/styles/_minimal-reset.css +3 -0
- package/src/lib/styles/global.css +1 -0
- 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,166 @@
|
|
|
1
|
+
<script lang="ts" module>export {};
|
|
2
|
+
</script>
|
|
3
|
+
|
|
4
|
+
<script lang="ts">let { type = 'text', size = 'normal', roundness = '1x', outline = true, name, id, class: className = '', disabled = false, oninput, onchange, onblur, onfocus, onpaste, oncopy, oncut, before, after, error = false, value = $bindable(), placeholder, } = $props();
|
|
5
|
+
let focused = $state(false);
|
|
6
|
+
function onfocusMod(e) {
|
|
7
|
+
focused = true;
|
|
8
|
+
if (onfocus) {
|
|
9
|
+
onfocus(e);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
function onblurMod(e) {
|
|
13
|
+
focused = false;
|
|
14
|
+
if (onblur) {
|
|
15
|
+
onblur(e);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export {};
|
|
19
|
+
</script>
|
|
20
|
+
|
|
21
|
+
<div
|
|
22
|
+
class:outline
|
|
23
|
+
class:disabled
|
|
24
|
+
class:error
|
|
25
|
+
class:focused
|
|
26
|
+
class={['dodo-ui-TextInput', `size--${size}`, `roundness--${roundness}`, className].join(' ')}
|
|
27
|
+
>
|
|
28
|
+
{#if before}
|
|
29
|
+
<span class="content--before">
|
|
30
|
+
{@render before()}
|
|
31
|
+
</span>
|
|
32
|
+
{/if}
|
|
33
|
+
<input
|
|
34
|
+
{type}
|
|
35
|
+
{name}
|
|
36
|
+
{id}
|
|
37
|
+
{disabled}
|
|
38
|
+
{oninput}
|
|
39
|
+
{onchange}
|
|
40
|
+
onfocus={onfocusMod}
|
|
41
|
+
onblur={onblurMod}
|
|
42
|
+
{onpaste}
|
|
43
|
+
{oncopy}
|
|
44
|
+
{oncut}
|
|
45
|
+
{placeholder}
|
|
46
|
+
bind:value
|
|
47
|
+
/>
|
|
48
|
+
{#if after}
|
|
49
|
+
<span class="content--after">
|
|
50
|
+
{@render after()}
|
|
51
|
+
</span>
|
|
52
|
+
{/if}
|
|
53
|
+
</div>
|
|
54
|
+
|
|
55
|
+
<style>:global(:root) {
|
|
56
|
+
--dodo-ui-TextInput-border-color: var(--dodo-color-default-500);
|
|
57
|
+
--dodo-ui-TextInput-focus-border-color: var(--dodo-color-primary-500);
|
|
58
|
+
--dodo-ui-TextInput-error-border-color: var(--dodo-color-danger-500);
|
|
59
|
+
--dodo-ui-TextInput-disabled-color: var(--dodo-color-default-400);
|
|
60
|
+
--dodo-ui-TextInput-disabled-bg: var(--dodo-color-default-200);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
:global(.dodo-theme--dark) {
|
|
64
|
+
--dodo-ui-TextInput-border-color: var(--dodo-color-default-600);
|
|
65
|
+
--dodo-ui-TextInput-focus-border-color: var(--dodo-color-primary-600);
|
|
66
|
+
--dodo-ui-TextInput-error-border-color: var(--dodo-color-danger-600);
|
|
67
|
+
--dodo-ui-TextInput-disabled-bg: var(--dodo-color-default-100);
|
|
68
|
+
--dodo-ui-TextInput-disabled-color: var(--dodo-color-default-500);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.dodo-ui-TextInput {
|
|
72
|
+
display: flex;
|
|
73
|
+
overflow: hidden;
|
|
74
|
+
color: var(--dodo-color-default-800);
|
|
75
|
+
transition: all 150ms;
|
|
76
|
+
border: 0;
|
|
77
|
+
}
|
|
78
|
+
.dodo-ui-TextInput input {
|
|
79
|
+
flex: 1;
|
|
80
|
+
border: 0;
|
|
81
|
+
outline: 0;
|
|
82
|
+
height: 100%;
|
|
83
|
+
background-color: transparent;
|
|
84
|
+
font-family: inherit;
|
|
85
|
+
color: inherit;
|
|
86
|
+
letter-spacing: 0.3px;
|
|
87
|
+
}
|
|
88
|
+
.dodo-ui-TextInput.outline {
|
|
89
|
+
border-style: solid;
|
|
90
|
+
border-width: var(--dodo-ui-element-border-width);
|
|
91
|
+
border-color: var(--dodo-ui-TextInput-border-color);
|
|
92
|
+
}
|
|
93
|
+
.dodo-ui-TextInput.focused {
|
|
94
|
+
border-color: var(--dodo-ui-TextInput-focus-border-color);
|
|
95
|
+
}
|
|
96
|
+
.dodo-ui-TextInput.error {
|
|
97
|
+
border-color: var(--dodo-ui-TextInput-error-border-color);
|
|
98
|
+
}
|
|
99
|
+
.dodo-ui-TextInput.disabled {
|
|
100
|
+
cursor: initial;
|
|
101
|
+
background-color: var(--dodo-ui-TextInput-disabled-bg);
|
|
102
|
+
color: var(--dodo-ui-TextInput-disabled-color);
|
|
103
|
+
border-color: var(--dodo-ui-TextInput-disabled-bg);
|
|
104
|
+
}
|
|
105
|
+
.dodo-ui-TextInput .content--after:empty, .dodo-ui-TextInput .content--before:empty {
|
|
106
|
+
display: none;
|
|
107
|
+
}
|
|
108
|
+
.dodo-ui-TextInput .content--after, .dodo-ui-TextInput .content--before {
|
|
109
|
+
display: inline-flex;
|
|
110
|
+
height: 100%;
|
|
111
|
+
align-items: center;
|
|
112
|
+
}
|
|
113
|
+
.dodo-ui-TextInput.size--normal {
|
|
114
|
+
height: var(--dodo-ui-element-height-normal);
|
|
115
|
+
}
|
|
116
|
+
.dodo-ui-TextInput.size--normal input {
|
|
117
|
+
font-size: 1rem;
|
|
118
|
+
padding: 0 12px;
|
|
119
|
+
}
|
|
120
|
+
.dodo-ui-TextInput.size--normal .content--before {
|
|
121
|
+
margin-left: 12px;
|
|
122
|
+
margin-right: -4px;
|
|
123
|
+
}
|
|
124
|
+
.dodo-ui-TextInput.size--normal .content--after {
|
|
125
|
+
margin-right: 12px;
|
|
126
|
+
margin-left: -4px;
|
|
127
|
+
}
|
|
128
|
+
.dodo-ui-TextInput.size--small {
|
|
129
|
+
height: var(--dodo-ui-element-height-small);
|
|
130
|
+
}
|
|
131
|
+
.dodo-ui-TextInput.size--small input {
|
|
132
|
+
padding: 0 8px;
|
|
133
|
+
font-size: 0.9rem;
|
|
134
|
+
}
|
|
135
|
+
.dodo-ui-TextInput.size--small .content--before {
|
|
136
|
+
margin-left: 8px;
|
|
137
|
+
margin-right: -2px;
|
|
138
|
+
}
|
|
139
|
+
.dodo-ui-TextInput.size--small .content--after {
|
|
140
|
+
margin-right: 8px;
|
|
141
|
+
margin-left: -2px;
|
|
142
|
+
}
|
|
143
|
+
.dodo-ui-TextInput.size--large {
|
|
144
|
+
height: var(--dodo-ui-element-height-large);
|
|
145
|
+
}
|
|
146
|
+
.dodo-ui-TextInput.size--large input {
|
|
147
|
+
font-size: 1.1rem;
|
|
148
|
+
padding: 0 14px;
|
|
149
|
+
}
|
|
150
|
+
.dodo-ui-TextInput.size--large .content--before {
|
|
151
|
+
margin-left: 14px;
|
|
152
|
+
margin-right: -4px;
|
|
153
|
+
}
|
|
154
|
+
.dodo-ui-TextInput.size--large .content--after {
|
|
155
|
+
margin-right: 14px;
|
|
156
|
+
margin-left: -4px;
|
|
157
|
+
}
|
|
158
|
+
.dodo-ui-TextInput.roundness--1x {
|
|
159
|
+
border-radius: var(--dodo-ui-element-roundness-1x);
|
|
160
|
+
}
|
|
161
|
+
.dodo-ui-TextInput.roundness--2x {
|
|
162
|
+
border-radius: var(--dodo-ui-element-roundness-2x);
|
|
163
|
+
}
|
|
164
|
+
.dodo-ui-TextInput.roundness--3x {
|
|
165
|
+
border-radius: var(--dodo-ui-element-roundness-3x);
|
|
166
|
+
}</style>
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
export type TextInputRoundness = ComponentRoundness | false;
|
|
2
|
+
export type TextInputType = 'text' | 'tel' | 'email' | 'password' | 'url' | 'number';
|
|
3
|
+
export type TextInputFocusEvent = FocusEvent & {
|
|
4
|
+
currentTarget: EventTarget & HTMLInputElement;
|
|
5
|
+
};
|
|
6
|
+
export type TextInputClipboardEvent = ClipboardEvent & {
|
|
7
|
+
currentTarget: EventTarget & HTMLInputElement;
|
|
8
|
+
};
|
|
9
|
+
import type { ComponentRoundness, ComponentSize } from '../../../../types.js';
|
|
10
|
+
import type { Snippet } from 'svelte';
|
|
11
|
+
import type { ChangeEventHandler, ClipboardEventHandler, FocusEventHandler, FormEventHandler } from 'svelte/elements';
|
|
12
|
+
interface TextInputProps {
|
|
13
|
+
/** Input type? */
|
|
14
|
+
type?: TextInputType;
|
|
15
|
+
/** How large should the button be? */
|
|
16
|
+
size?: ComponentSize;
|
|
17
|
+
/** How round should the border radius be? */
|
|
18
|
+
roundness?: TextInputRoundness;
|
|
19
|
+
/** Add a border around the button. Default True */
|
|
20
|
+
outline?: boolean;
|
|
21
|
+
/** Input value */
|
|
22
|
+
value?: string;
|
|
23
|
+
/** How round should the border radius be? */
|
|
24
|
+
placeholder?: string;
|
|
25
|
+
/** Button disabled state */
|
|
26
|
+
disabled?: boolean;
|
|
27
|
+
/** is there any associated Error ? */
|
|
28
|
+
error?: boolean;
|
|
29
|
+
/** Name */
|
|
30
|
+
name?: string;
|
|
31
|
+
/** Id */
|
|
32
|
+
id?: string;
|
|
33
|
+
/** Icon before button content */
|
|
34
|
+
before?: Snippet;
|
|
35
|
+
/** Icon after button content */
|
|
36
|
+
after?: Snippet;
|
|
37
|
+
/** Custom css class*/
|
|
38
|
+
class?: string;
|
|
39
|
+
/** oninput event handler */
|
|
40
|
+
oninput?: FormEventHandler<HTMLInputElement>;
|
|
41
|
+
/** onchange event handler */
|
|
42
|
+
onchange?: ChangeEventHandler<HTMLInputElement>;
|
|
43
|
+
/** onblur event handler */
|
|
44
|
+
onblur?: FocusEventHandler<HTMLInputElement>;
|
|
45
|
+
/** onfocus event handler */
|
|
46
|
+
onfocus?: FocusEventHandler<HTMLInputElement>;
|
|
47
|
+
/** onpaste event handler */
|
|
48
|
+
onpaste?: ClipboardEventHandler<HTMLInputElement>;
|
|
49
|
+
/** oncopy event handler */
|
|
50
|
+
oncopy?: ClipboardEventHandler<HTMLInputElement>;
|
|
51
|
+
/** oncut event handler */
|
|
52
|
+
oncut?: ClipboardEventHandler<HTMLInputElement>;
|
|
53
|
+
}
|
|
54
|
+
declare const TextInput: import("svelte").Component<TextInputProps, {}, "value">;
|
|
55
|
+
type TextInput = ReturnType<typeof TextInput>;
|
|
56
|
+
export default TextInput;
|
|
@@ -0,0 +1,47 @@
|
|
|
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
|
+
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: TextInput,
|
|
10
|
+
tags: ['autodocs'],
|
|
11
|
+
argTypes: storyTextInputArgTypes,
|
|
12
|
+
});
|
|
13
|
+
</script>
|
|
14
|
+
|
|
15
|
+
<!-- TextInput icon in front. -->
|
|
16
|
+
<Story name="Icon Before">
|
|
17
|
+
<TextInput>
|
|
18
|
+
{#snippet before()}
|
|
19
|
+
<Icon icon="material-symbols:content-copy" />
|
|
20
|
+
{/snippet}
|
|
21
|
+
</TextInput>
|
|
22
|
+
</Story>
|
|
23
|
+
|
|
24
|
+
<!-- TextInput icon in front. -->
|
|
25
|
+
<Story name="Icon After">
|
|
26
|
+
<TextInput>
|
|
27
|
+
{#snippet after()}
|
|
28
|
+
<Icon icon="material-symbols:download-2" />
|
|
29
|
+
{/snippet}
|
|
30
|
+
</TextInput>
|
|
31
|
+
</Story>
|
|
32
|
+
|
|
33
|
+
<Story name="Small" args={{ size: 'small' }}>
|
|
34
|
+
<TextInput size="small">
|
|
35
|
+
{#snippet before()}
|
|
36
|
+
<Icon icon="material-symbols:content-copy" />
|
|
37
|
+
{/snippet}
|
|
38
|
+
</TextInput>
|
|
39
|
+
</Story>
|
|
40
|
+
|
|
41
|
+
<Story name="Large" args={{ size: 'large' }}>
|
|
42
|
+
<TextInput size="large">
|
|
43
|
+
{#snippet before()}
|
|
44
|
+
<Icon icon="material-symbols:content-copy" />
|
|
45
|
+
{/snippet}
|
|
46
|
+
</TextInput>
|
|
47
|
+
</Story>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export default WithIcon;
|
|
2
|
+
type WithIcon = SvelteComponent<{
|
|
3
|
+
[x: string]: never;
|
|
4
|
+
}, {
|
|
5
|
+
[evt: string]: CustomEvent<any>;
|
|
6
|
+
}, {}> & {
|
|
7
|
+
$$bindings?: string | undefined;
|
|
8
|
+
};
|
|
9
|
+
declare const WithIcon: $$__sveltets_2_IsomorphicComponent<{
|
|
10
|
+
[x: string]: never;
|
|
11
|
+
}, {
|
|
12
|
+
[evt: string]: CustomEvent<any>;
|
|
13
|
+
}, {}, {}, string>;
|
|
14
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
15
|
+
new (options: import("svelte").ComponentConstructorOptions<Props>): import("svelte").SvelteComponent<Props, Events, Slots> & {
|
|
16
|
+
$$bindings?: Bindings;
|
|
17
|
+
} & Exports;
|
|
18
|
+
(internal: unknown, props: {
|
|
19
|
+
$$events?: Events;
|
|
20
|
+
$$slots?: Slots;
|
|
21
|
+
}): Exports & {
|
|
22
|
+
$set?: any;
|
|
23
|
+
$on?: any;
|
|
24
|
+
};
|
|
25
|
+
z_$$bindings?: Bindings;
|
|
26
|
+
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
:root {
|
|
2
|
-
--dodo-ui-element-height-
|
|
3
|
-
--dodo-ui-element-height-
|
|
4
|
-
--dodo-ui-element-height-large:
|
|
2
|
+
--dodo-ui-element-height-small: 34px;
|
|
3
|
+
--dodo-ui-element-height-normal: 40px;
|
|
4
|
+
--dodo-ui-element-height-large: 50px;
|
|
5
5
|
|
|
6
|
-
--dodo-ui-element-roundness-
|
|
7
|
-
--dodo-ui-element-roundness-
|
|
8
|
-
--dodo-ui-element-roundness-
|
|
9
|
-
|
|
6
|
+
--dodo-ui-element-roundness-1x: 7px;
|
|
7
|
+
--dodo-ui-element-roundness-2x: 13px;
|
|
8
|
+
--dodo-ui-element-roundness-3x: 31px;
|
|
9
|
+
|
|
10
|
+
--dodo-ui-element-border-width: 1px;
|
|
10
11
|
}
|
package/dist/styles/global.css
CHANGED
package/package.json
CHANGED
package/src/lib/index.ts
CHANGED
|
@@ -10,3 +10,16 @@ export type {
|
|
|
10
10
|
ButtonLinkTarget,
|
|
11
11
|
ButtonLinkReferrerpolicy,
|
|
12
12
|
} from '$lib/stories/components/Form/Button/Button.svelte';
|
|
13
|
+
|
|
14
|
+
/** Form: TextInput */
|
|
15
|
+
export { default as TextInput } from '$lib/stories/components/Form/TextInput/TextInput.svelte';
|
|
16
|
+
export type {
|
|
17
|
+
TextInputRoundness,
|
|
18
|
+
TextInputType,
|
|
19
|
+
TextInputFocusEvent,
|
|
20
|
+
TextInputClipboardEvent,
|
|
21
|
+
} from '$lib/stories/components/Form/TextInput/TextInput.svelte';
|
|
22
|
+
|
|
23
|
+
/** Form: PasswordInput */
|
|
24
|
+
export { default as PasswordInput } from '$lib/stories/components/Form/PasswordInput/PasswordInput.svelte';
|
|
25
|
+
export type { PasswordInputToggleEvent } from '$lib/stories/components/Form/PasswordInput/PasswordInput.svelte';
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
},
|
|
20
20
|
roundness: {
|
|
21
21
|
control: { type: 'select' },
|
|
22
|
-
options: [false,
|
|
22
|
+
options: [false, '1x', '2x', '3x', 'full'],
|
|
23
23
|
},
|
|
24
24
|
size: {
|
|
25
25
|
control: { type: 'select' },
|
|
@@ -54,20 +54,25 @@
|
|
|
54
54
|
<Button>Click me!</Button>
|
|
55
55
|
</Story>
|
|
56
56
|
|
|
57
|
-
<Story name="Disabled" args={{ disabled: true }}>
|
|
58
|
-
<Button disabled>Click me!</Button>
|
|
59
|
-
</Story>
|
|
60
|
-
|
|
61
57
|
<!-- Button with border around it -->
|
|
62
58
|
<Story name="Outline" args={{ outline: true }}>
|
|
63
59
|
<Button outline>Click me!</Button>
|
|
64
60
|
</Story>
|
|
65
61
|
|
|
62
|
+
<Story name="Disabled" args={{ disabled: true }}>
|
|
63
|
+
<Button disabled>Click me!</Button>
|
|
64
|
+
</Story>
|
|
65
|
+
|
|
66
66
|
<!-- Form submit button -->
|
|
67
67
|
<Story name="Sumbit Button" args={{ type: 'submit' }}>
|
|
68
68
|
<Button type="submit">Submit Form</Button>
|
|
69
69
|
</Story>
|
|
70
70
|
|
|
71
|
+
<!-- Form submit button -->
|
|
72
|
+
<Story name="Full width Button" args={{ fullWidth: true }}>
|
|
73
|
+
<Button fullWidth>Click me!</Button>
|
|
74
|
+
</Story>
|
|
75
|
+
|
|
71
76
|
<!-- Anchor Link styled like a Button -->
|
|
72
77
|
<Story
|
|
73
78
|
name="Link Button"
|
|
@@ -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 */
|
|
@@ -81,6 +84,7 @@
|
|
|
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;
|
|
@@ -242,15 +248,15 @@
|
|
|
242
248
|
|
|
243
249
|
&.roundness {
|
|
244
250
|
&--1x {
|
|
245
|
-
border-radius: var(--dodo-ui-element-roundness-
|
|
251
|
+
border-radius: var(--dodo-ui-element-roundness-1x);
|
|
246
252
|
}
|
|
247
253
|
|
|
248
254
|
&--2x {
|
|
249
|
-
border-radius: var(--dodo-ui-element-roundness-
|
|
255
|
+
border-radius: var(--dodo-ui-element-roundness-2x);
|
|
250
256
|
}
|
|
251
257
|
|
|
252
258
|
&--3x {
|
|
253
|
-
border-radius: var(--dodo-ui-element-roundness-
|
|
259
|
+
border-radius: var(--dodo-ui-element-roundness-3x);
|
|
254
260
|
}
|
|
255
261
|
|
|
256
262
|
&--full {
|
|
@@ -273,17 +279,17 @@
|
|
|
273
279
|
&.variant {
|
|
274
280
|
&--text,
|
|
275
281
|
&--solid {
|
|
276
|
-
background-color: var(--dodo-ui-
|
|
277
|
-
color: var(--dodo-ui-
|
|
282
|
+
background-color: var(--dodo-ui-Button-disabled-bg);
|
|
283
|
+
color: var(--dodo-ui-Button-disabled-color);
|
|
278
284
|
|
|
279
285
|
&:hover {
|
|
280
|
-
background-color: var(--dodo-ui-
|
|
281
|
-
color: var(--dodo-ui-
|
|
286
|
+
background-color: var(--dodo-ui-Button-disabled-bg);
|
|
287
|
+
color: var(--dodo-ui-Button-disabled-color);
|
|
282
288
|
}
|
|
283
289
|
|
|
284
290
|
&:active {
|
|
285
|
-
background-color: var(--dodo-ui-
|
|
286
|
-
color: var(--dodo-ui-
|
|
291
|
+
background-color: var(--dodo-ui-Button-disabled-bg);
|
|
292
|
+
color: var(--dodo-ui-Button-disabled-color);
|
|
287
293
|
}
|
|
288
294
|
|
|
289
295
|
&.outline {
|
|
@@ -316,7 +322,11 @@
|
|
|
316
322
|
}
|
|
317
323
|
}
|
|
318
324
|
|
|
319
|
-
|
|
325
|
+
&.fullWidth {
|
|
326
|
+
width: 100%;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
.content {
|
|
320
330
|
&--after,
|
|
321
331
|
&--before {
|
|
322
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>
|