@flightlesslabs/dodo-ui 0.2.0 → 0.4.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.
Files changed (93) hide show
  1. package/dist/index.d.ts +15 -0
  2. package/dist/index.js +12 -0
  3. package/dist/stories/Home.mdx +1 -1
  4. package/dist/stories/components/Form/Button/Button.stories.svelte +10 -5
  5. package/dist/stories/components/Form/Button/Button.svelte +216 -208
  6. package/dist/stories/components/Form/Button/Button.svelte.d.ts +8 -3
  7. package/dist/stories/components/Form/Button/Events/Events.stories.svelte +40 -0
  8. package/dist/stories/components/Form/Button/Events/Events.stories.svelte.d.ts +18 -0
  9. package/dist/stories/components/Form/Button/utils/scss/mixins.scss +21 -21
  10. package/dist/stories/components/Form/FormControl/FormControl.stories.svelte +27 -0
  11. package/dist/stories/components/Form/FormControl/FormControl.stories.svelte.d.ts +19 -0
  12. package/dist/stories/components/Form/FormControl/FormControl.svelte +34 -0
  13. package/dist/stories/components/Form/FormControl/FormControl.svelte.d.ts +20 -0
  14. package/dist/stories/components/Form/Label/Label.stories.svelte +21 -0
  15. package/dist/stories/components/Form/Label/Label.stories.svelte.d.ts +19 -0
  16. package/dist/stories/components/Form/Label/Label.svelte +19 -0
  17. package/dist/stories/components/Form/Label/Label.svelte.d.ts +18 -0
  18. package/dist/stories/components/Form/Message/Message.stories.svelte +46 -0
  19. package/dist/stories/components/Form/Message/Message.stories.svelte.d.ts +19 -0
  20. package/dist/stories/components/Form/Message/Message.svelte +39 -0
  21. package/dist/stories/components/Form/Message/Message.svelte.d.ts +17 -0
  22. package/dist/stories/components/Form/PasswordInput/Events/Events.stories.svelte +168 -0
  23. package/dist/stories/components/Form/PasswordInput/Events/Events.stories.svelte.d.ts +18 -0
  24. package/dist/stories/components/Form/PasswordInput/PasswordInput.stories.svelte +53 -0
  25. package/dist/stories/components/Form/PasswordInput/PasswordInput.stories.svelte.d.ts +21 -0
  26. package/dist/stories/components/Form/PasswordInput/PasswordInput.svelte +196 -0
  27. package/dist/stories/components/Form/PasswordInput/PasswordInput.svelte.d.ts +63 -0
  28. package/dist/stories/components/Form/PasswordInput/Roundness/Roundness.stories.svelte +20 -0
  29. package/dist/stories/components/Form/{ExampleButton/ExampleButton.stories.svelte.d.ts → PasswordInput/Roundness/Roundness.stories.svelte.d.ts} +3 -4
  30. package/dist/stories/components/Form/PasswordInput/Size/Size.stories.svelte +16 -0
  31. package/dist/stories/components/Form/PasswordInput/Size/Size.stories.svelte.d.ts +26 -0
  32. package/dist/stories/components/Form/PasswordInput/WithIcon/WithIcon.stories.svelte +31 -0
  33. package/dist/stories/components/Form/PasswordInput/WithIcon/WithIcon.stories.svelte.d.ts +26 -0
  34. package/dist/stories/components/Form/TextInput/Events/Events.stories.svelte +148 -0
  35. package/dist/stories/components/Form/TextInput/Events/Events.stories.svelte.d.ts +18 -0
  36. package/dist/stories/components/Form/TextInput/Roundness/Roundness.stories.svelte +21 -0
  37. package/dist/stories/components/Form/TextInput/Roundness/Roundness.stories.svelte.d.ts +26 -0
  38. package/dist/stories/components/Form/TextInput/Size/Size.stories.svelte +17 -0
  39. package/dist/stories/components/Form/TextInput/Size/Size.stories.svelte.d.ts +26 -0
  40. package/dist/stories/components/Form/TextInput/TextInput.stories.svelte +37 -0
  41. package/dist/stories/components/Form/TextInput/TextInput.stories.svelte.d.ts +21 -0
  42. package/dist/stories/components/Form/TextInput/TextInput.svelte +168 -0
  43. package/dist/stories/components/Form/TextInput/TextInput.svelte.d.ts +60 -0
  44. package/dist/stories/components/Form/TextInput/WithIcon/WithIcon.stories.svelte +47 -0
  45. package/dist/stories/components/Form/TextInput/WithIcon/WithIcon.stories.svelte.d.ts +26 -0
  46. package/dist/stories/developer tools/Intro.mdx +7 -0
  47. package/dist/stories/developer tools/components/UtilityButton/Size/Size.stories.svelte +27 -0
  48. package/dist/stories/developer tools/components/UtilityButton/Size/Size.stories.svelte.d.ts +26 -0
  49. package/dist/stories/developer tools/components/UtilityButton/UtilityButton.stories.svelte +29 -0
  50. package/dist/stories/developer tools/components/UtilityButton/UtilityButton.stories.svelte.d.ts +21 -0
  51. package/dist/stories/developer tools/components/UtilityButton/UtilityButton.svelte +79 -0
  52. package/dist/stories/developer tools/components/UtilityButton/UtilityButton.svelte.d.ts +26 -0
  53. package/dist/styles/_components.css +8 -7
  54. package/dist/styles/_minimal-reset.css +3 -0
  55. package/dist/styles/global.css +1 -0
  56. package/package.json +30 -30
  57. package/src/lib/index.ts +26 -0
  58. package/src/lib/stories/components/Form/Button/Button.stories.svelte +10 -5
  59. package/src/lib/stories/components/Form/Button/Button.svelte +40 -24
  60. package/src/lib/stories/components/Form/Button/Events/Events.stories.svelte +42 -0
  61. package/src/lib/stories/components/Form/Button/utils/scss/mixins.scss +21 -21
  62. package/src/lib/stories/components/Form/FormControl/FormControl.stories.svelte +29 -0
  63. package/src/lib/stories/components/Form/FormControl/FormControl.svelte +67 -0
  64. package/src/lib/stories/components/Form/Label/Label.stories.svelte +23 -0
  65. package/src/lib/stories/components/Form/Label/Label.svelte +45 -0
  66. package/src/lib/stories/components/Form/Message/Message.stories.svelte +48 -0
  67. package/src/lib/stories/components/Form/Message/Message.svelte +71 -0
  68. package/src/lib/stories/components/Form/PasswordInput/Events/Events.stories.svelte +174 -0
  69. package/src/lib/stories/components/Form/PasswordInput/PasswordInput.stories.svelte +57 -0
  70. package/src/lib/stories/components/Form/PasswordInput/PasswordInput.svelte +338 -0
  71. package/src/lib/stories/components/Form/PasswordInput/Roundness/Roundness.stories.svelte +20 -0
  72. package/src/lib/stories/components/Form/PasswordInput/Size/Size.stories.svelte +16 -0
  73. package/src/lib/stories/components/Form/PasswordInput/WithIcon/WithIcon.stories.svelte +31 -0
  74. package/src/lib/stories/components/Form/TextInput/Events/Events.stories.svelte +153 -0
  75. package/src/lib/stories/components/Form/TextInput/Roundness/Roundness.stories.svelte +21 -0
  76. package/src/lib/stories/components/Form/TextInput/Size/Size.stories.svelte +17 -0
  77. package/src/lib/stories/components/Form/TextInput/TextInput.stories.svelte +41 -0
  78. package/src/lib/stories/components/Form/TextInput/TextInput.svelte +301 -0
  79. package/src/lib/stories/components/Form/TextInput/WithIcon/WithIcon.stories.svelte +47 -0
  80. package/src/lib/stories/developer tools/Intro.mdx +7 -0
  81. package/src/lib/stories/developer tools/components/UtilityButton/Size/Size.stories.svelte +27 -0
  82. package/src/lib/stories/developer tools/components/UtilityButton/UtilityButton.stories.svelte +33 -0
  83. package/src/lib/stories/developer tools/components/UtilityButton/UtilityButton.svelte +128 -0
  84. package/src/lib/styles/_components.css +8 -7
  85. package/src/lib/styles/_minimal-reset.css +3 -0
  86. package/src/lib/styles/global.css +1 -0
  87. package/dist/stories/components/Form/ExampleButton/ExampleButton.stories.svelte +0 -30
  88. package/dist/stories/components/Form/ExampleButton/ExampleButton.svelte +0 -14
  89. package/dist/stories/components/Form/ExampleButton/ExampleButton.svelte.d.ts +0 -16
  90. package/dist/stories/components/Form/ExampleButton/button.css +0 -30
  91. package/src/lib/stories/components/Form/ExampleButton/ExampleButton.stories.svelte +0 -30
  92. package/src/lib/stories/components/Form/ExampleButton/ExampleButton.svelte +0 -29
  93. package/src/lib/stories/components/Form/ExampleButton/button.css +0 -30
@@ -0,0 +1,26 @@
1
+ export default Roundness;
2
+ type Roundness = SvelteComponent<{
3
+ [x: string]: never;
4
+ }, {
5
+ [evt: string]: CustomEvent<any>;
6
+ }, {}> & {
7
+ $$bindings?: string | undefined;
8
+ };
9
+ declare const Roundness: $$__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
+ }
@@ -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,26 @@
1
+ export default Size;
2
+ type Size = SvelteComponent<{
3
+ [x: string]: never;
4
+ }, {
5
+ [evt: string]: CustomEvent<any>;
6
+ }, {}> & {
7
+ $$bindings?: string | undefined;
8
+ };
9
+ declare const Size: $$__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
+ }
@@ -0,0 +1,37 @@
1
+ <script module lang="ts">import { defineMeta } from '@storybook/addon-svelte-csf';
2
+ import TextInput from './TextInput.svelte';
3
+ export const storyTextInputArgTypes = {
4
+ type: {
5
+ control: { type: 'select' },
6
+ options: ['text', 'tel', 'email', 'password', 'url', 'number'],
7
+ },
8
+ roundness: {
9
+ control: { type: 'select' },
10
+ options: [false, '1x', '2x', '3x'],
11
+ },
12
+ size: {
13
+ control: { type: 'select' },
14
+ options: ['normal', 'small', 'large'],
15
+ },
16
+ };
17
+ // More on how to set up stories at: https://storybook.js.org/docs/writing-stories
18
+ const { Story } = defineMeta({
19
+ component: TextInput,
20
+ tags: ['autodocs'],
21
+ argTypes: storyTextInputArgTypes,
22
+ args: { value: 'Hello world!' },
23
+ });
24
+ </script>
25
+
26
+ <!-- TextInput with default style -->
27
+ <Story name="Default" />
28
+
29
+ <Story name="Placeholder" args={{ value: '', placeholder: 'Type something...' }} />
30
+
31
+ <Story name="No Outline" args={{ outline: false }} />
32
+
33
+ <Story name="Error" args={{ error: true }} />
34
+
35
+ <Story name="Disabled" args={{ disabled: true }} />
36
+
37
+ <Story name="Read only" args={{ readonly: true }} />
@@ -0,0 +1,21 @@
1
+ import TextInput from './TextInput.svelte';
2
+ import type { StoryBookArgTypes } from '../../../../storybook-types.js';
3
+ export declare const storyTextInputArgTypes: StoryBookArgTypes;
4
+ 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> {
5
+ new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
6
+ $$bindings?: Bindings;
7
+ } & Exports;
8
+ (internal: unknown, props: {
9
+ $$events?: Events;
10
+ $$slots?: Slots;
11
+ }): Exports & {
12
+ $set?: any;
13
+ $on?: any;
14
+ };
15
+ z_$$bindings?: Bindings;
16
+ }
17
+ declare const TextInput: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
18
+ [evt: string]: CustomEvent<any>;
19
+ }, {}, {}, string>;
20
+ type TextInput = InstanceType<typeof TextInput>;
21
+ export default TextInput;
@@ -0,0 +1,168 @@
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, ref = $bindable(), readonly = false, } = $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
+ {readonly}
47
+ bind:value
48
+ bind:this={ref}
49
+ />
50
+ {#if after}
51
+ <span class="content--after">
52
+ {@render after()}
53
+ </span>
54
+ {/if}
55
+ </div>
56
+
57
+ <style>:global(:root) {
58
+ --dodo-ui-TextInput-border-color: var(--dodo-color-default-500);
59
+ --dodo-ui-TextInput-focus-border-color: var(--dodo-color-primary-500);
60
+ --dodo-ui-TextInput-error-border-color: var(--dodo-color-danger-500);
61
+ --dodo-ui-TextInput-disabled-color: var(--dodo-color-default-400);
62
+ --dodo-ui-TextInput-disabled-bg: var(--dodo-color-default-200);
63
+ }
64
+
65
+ :global(.dodo-theme--dark) {
66
+ --dodo-ui-TextInput-border-color: var(--dodo-color-default-600);
67
+ --dodo-ui-TextInput-focus-border-color: var(--dodo-color-primary-600);
68
+ --dodo-ui-TextInput-error-border-color: var(--dodo-color-danger-600);
69
+ --dodo-ui-TextInput-disabled-bg: var(--dodo-color-default-100);
70
+ --dodo-ui-TextInput-disabled-color: var(--dodo-color-default-500);
71
+ }
72
+
73
+ .dodo-ui-TextInput {
74
+ display: flex;
75
+ overflow: hidden;
76
+ color: var(--dodo-color-default-800);
77
+ transition: all 150ms;
78
+ border: 0;
79
+ }
80
+ .dodo-ui-TextInput input {
81
+ flex: 1;
82
+ border: 0;
83
+ outline: 0;
84
+ height: 100%;
85
+ background-color: transparent;
86
+ font-family: inherit;
87
+ color: inherit;
88
+ letter-spacing: 0.3px;
89
+ }
90
+ .dodo-ui-TextInput.outline {
91
+ border-style: solid;
92
+ border-width: var(--dodo-ui-element-border-width);
93
+ border-color: var(--dodo-ui-TextInput-border-color);
94
+ }
95
+ .dodo-ui-TextInput.focused {
96
+ border-color: var(--dodo-ui-TextInput-focus-border-color);
97
+ }
98
+ .dodo-ui-TextInput.error {
99
+ border-color: var(--dodo-ui-TextInput-error-border-color);
100
+ }
101
+ .dodo-ui-TextInput.disabled {
102
+ cursor: initial;
103
+ background-color: var(--dodo-ui-TextInput-disabled-bg);
104
+ color: var(--dodo-ui-TextInput-disabled-color);
105
+ border-color: var(--dodo-ui-TextInput-disabled-bg);
106
+ }
107
+ .dodo-ui-TextInput .content--after:empty, .dodo-ui-TextInput .content--before:empty {
108
+ display: none;
109
+ }
110
+ .dodo-ui-TextInput .content--after, .dodo-ui-TextInput .content--before {
111
+ display: inline-flex;
112
+ height: 100%;
113
+ align-items: center;
114
+ }
115
+ .dodo-ui-TextInput.size--normal {
116
+ height: var(--dodo-ui-element-height-normal);
117
+ }
118
+ .dodo-ui-TextInput.size--normal input {
119
+ font-size: 1rem;
120
+ padding: 0 12px;
121
+ }
122
+ .dodo-ui-TextInput.size--normal .content--before {
123
+ margin-left: 12px;
124
+ margin-right: -4px;
125
+ }
126
+ .dodo-ui-TextInput.size--normal .content--after {
127
+ margin-right: 12px;
128
+ margin-left: -4px;
129
+ }
130
+ .dodo-ui-TextInput.size--small {
131
+ height: var(--dodo-ui-element-height-small);
132
+ }
133
+ .dodo-ui-TextInput.size--small input {
134
+ padding: 0 8px;
135
+ font-size: 0.9rem;
136
+ }
137
+ .dodo-ui-TextInput.size--small .content--before {
138
+ margin-left: 8px;
139
+ margin-right: -2px;
140
+ }
141
+ .dodo-ui-TextInput.size--small .content--after {
142
+ margin-right: 8px;
143
+ margin-left: -2px;
144
+ }
145
+ .dodo-ui-TextInput.size--large {
146
+ height: var(--dodo-ui-element-height-large);
147
+ }
148
+ .dodo-ui-TextInput.size--large input {
149
+ font-size: 1.1rem;
150
+ padding: 0 14px;
151
+ }
152
+ .dodo-ui-TextInput.size--large .content--before {
153
+ margin-left: 14px;
154
+ margin-right: -4px;
155
+ }
156
+ .dodo-ui-TextInput.size--large .content--after {
157
+ margin-right: 14px;
158
+ margin-left: -4px;
159
+ }
160
+ .dodo-ui-TextInput.roundness--1x {
161
+ border-radius: var(--dodo-ui-element-roundness-1x);
162
+ }
163
+ .dodo-ui-TextInput.roundness--2x {
164
+ border-radius: var(--dodo-ui-element-roundness-2x);
165
+ }
166
+ .dodo-ui-TextInput.roundness--3x {
167
+ border-radius: var(--dodo-ui-element-roundness-3x);
168
+ }</style>
@@ -0,0 +1,60 @@
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
+ /** Input ref */
16
+ ref?: HTMLInputElement;
17
+ /** How large should the button be? */
18
+ size?: ComponentSize;
19
+ /** How round should the border radius be? */
20
+ roundness?: TextInputRoundness;
21
+ /** Add a border around the button. Default True */
22
+ outline?: boolean;
23
+ /** Input value */
24
+ value?: string;
25
+ /** How round should the border radius be? */
26
+ placeholder?: string;
27
+ /** disabled state */
28
+ disabled?: boolean;
29
+ /** Read only ? */
30
+ readonly?: boolean;
31
+ /** is there any associated Error ? */
32
+ error?: boolean;
33
+ /** Name */
34
+ name?: string;
35
+ /** Id */
36
+ id?: string;
37
+ /** Icon before button content */
38
+ before?: Snippet;
39
+ /** Icon after button content */
40
+ after?: Snippet;
41
+ /** Custom css class*/
42
+ class?: string;
43
+ /** oninput event handler */
44
+ oninput?: FormEventHandler<HTMLInputElement>;
45
+ /** onchange event handler */
46
+ onchange?: ChangeEventHandler<HTMLInputElement>;
47
+ /** onblur event handler */
48
+ onblur?: FocusEventHandler<HTMLInputElement>;
49
+ /** onfocus event handler */
50
+ onfocus?: FocusEventHandler<HTMLInputElement>;
51
+ /** onpaste event handler */
52
+ onpaste?: ClipboardEventHandler<HTMLInputElement>;
53
+ /** oncopy event handler */
54
+ oncopy?: ClipboardEventHandler<HTMLInputElement>;
55
+ /** oncut event handler */
56
+ oncut?: ClipboardEventHandler<HTMLInputElement>;
57
+ }
58
+ declare const TextInput: import("svelte").Component<TextInputProps, {}, "ref" | "value">;
59
+ type TextInput = ReturnType<typeof TextInput>;
60
+ 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
+ }
@@ -0,0 +1,7 @@
1
+ # Developer Tools
2
+
3
+ A set of components and tools used internally in dodo-ui.
4
+
5
+ ## Explore More
6
+
7
+ - [Utility Button](?path=/docs/developer-tools-components-utilitybutton--docs)
@@ -0,0 +1,27 @@
1
+ <script module>
2
+ import { defineMeta } from '@storybook/addon-svelte-csf';
3
+ import { fn } from '@storybook/test';
4
+ import UtilityButton from '../UtilityButton.svelte';
5
+ import { storyUtilityButtonArgTypes } from '../UtilityButton.stories.svelte';
6
+ import Icon from '@iconify/svelte';
7
+
8
+ // More on how to set up stories at: https://storybook.js.org/docs/writing-stories
9
+ const { Story } = defineMeta({
10
+ component: UtilityButton,
11
+ tags: ['autodocs'],
12
+ argTypes: storyUtilityButtonArgTypes,
13
+ args: {
14
+ onclick: fn(),
15
+ },
16
+ });
17
+ </script>
18
+
19
+ <Story name="Normal" args={{ disabled: false }}>
20
+ <UtilityButton><Icon icon="mdi:eye" width="24" height="24" /></UtilityButton>
21
+ </Story>
22
+ <Story name="Small" args={{ size: 'small' }}>
23
+ <UtilityButton size="small"><Icon icon="mdi:eye" width="22" height="22" /></UtilityButton>
24
+ </Story>
25
+ <Story name="Large" args={{ size: 'large' }}>
26
+ <UtilityButton size="large"><Icon icon="mdi:eye" width="28" height="28" /></UtilityButton>
27
+ </Story>
@@ -0,0 +1,26 @@
1
+ export default Size;
2
+ type Size = SvelteComponent<{
3
+ [x: string]: never;
4
+ }, {
5
+ [evt: string]: CustomEvent<any>;
6
+ }, {}> & {
7
+ $$bindings?: string | undefined;
8
+ };
9
+ declare const Size: $$__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
+ }
@@ -0,0 +1,29 @@
1
+ <script module lang="ts">import { defineMeta } from '@storybook/addon-svelte-csf';
2
+ import UtilityButton from './UtilityButton.svelte';
3
+ import Icon from '@iconify/svelte';
4
+ import { fn } from '@storybook/test';
5
+ export const storyUtilityButtonArgTypes = {
6
+ size: {
7
+ control: { type: 'select' },
8
+ options: ['normal', 'small', 'large'],
9
+ },
10
+ };
11
+ // More on how to set up stories at: https://storybook.js.org/docs/writing-stories
12
+ const { Story } = defineMeta({
13
+ component: UtilityButton,
14
+ tags: ['autodocs'],
15
+ argTypes: storyUtilityButtonArgTypes,
16
+ args: {
17
+ onclick: fn(),
18
+ },
19
+ });
20
+ </script>
21
+
22
+ <!-- Button with default style -->
23
+ <Story name="Default">
24
+ <UtilityButton><Icon icon="mdi:eye" width="24" height="24" /></UtilityButton>
25
+ </Story>
26
+
27
+ <Story name="Disabled" args={{ disabled: true }}>
28
+ <UtilityButton disabled><Icon icon="mdi:eye" width="24" height="24" /></UtilityButton>
29
+ </Story>
@@ -0,0 +1,21 @@
1
+ import UtilityButton from './UtilityButton.svelte';
2
+ import type { StoryBookArgTypes } from '../../../../storybook-types.js';
3
+ export declare const storyUtilityButtonArgTypes: StoryBookArgTypes;
4
+ 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> {
5
+ new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
6
+ $$bindings?: Bindings;
7
+ } & Exports;
8
+ (internal: unknown, props: {
9
+ $$events?: Events;
10
+ $$slots?: Slots;
11
+ }): Exports & {
12
+ $set?: any;
13
+ $on?: any;
14
+ };
15
+ z_$$bindings?: Bindings;
16
+ }
17
+ declare const UtilityButton: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
18
+ [evt: string]: CustomEvent<any>;
19
+ }, {}, {}, string>;
20
+ type UtilityButton = InstanceType<typeof UtilityButton>;
21
+ export default UtilityButton;
@@ -0,0 +1,79 @@
1
+ <script lang="ts">let { children, size = 'normal', name, id, title, class: className = '', disabled = false, onclick, ref = $bindable(), } = $props();
2
+ export {};
3
+ </script>
4
+
5
+ <button
6
+ class={['dodo-ui-UtilityButton', `size--${size}`, className].join(' ')}
7
+ {name}
8
+ {id}
9
+ {title}
10
+ {disabled}
11
+ {onclick}
12
+ bind:this={ref}
13
+ >
14
+ {#if children}
15
+ {@render children()}
16
+ {/if}
17
+ </button>
18
+
19
+ <style>:global(:root) {
20
+ --dodo-ui-UtilityButton-hover: var(--dodo-color-primary-600);
21
+ --dodo-ui-UtilityButton-active: var(--dodo-color-primary-600);
22
+ --dodo-ui-UtilityButton-disabled-color: var(--dodo-color-default-400);
23
+ }
24
+
25
+ :global(.dodo-theme--dark) {
26
+ --dodo-ui-UtilityButton-hover: var(--dodo-color-primary-600);
27
+ --dodo-ui-UtilityButton-active: var(--dodo-color-primary-600);
28
+ --dodo-ui-UtilityButton-disabled-color: var(--dodo-color-default-500);
29
+ }
30
+
31
+ .dodo-ui-UtilityButton {
32
+ cursor: pointer;
33
+ outline: none;
34
+ transition: all 150ms;
35
+ text-decoration: none;
36
+ margin: 0;
37
+ display: inline-flex;
38
+ justify-content: center;
39
+ align-items: center;
40
+ font-family: inherit;
41
+ background-color: transparent;
42
+ border: 0;
43
+ outline: 0;
44
+ padding: 0;
45
+ color: var(--dodo-color-default-700);
46
+ border-radius: 50%;
47
+ font-family: inherit;
48
+ }
49
+ .dodo-ui-UtilityButton:hover {
50
+ color: var(--dodo-ui-UtilityButton-hover);
51
+ }
52
+ .dodo-ui-UtilityButton:active {
53
+ color: var(--dodo-ui-UtilityButton-active);
54
+ }
55
+ .dodo-ui-UtilityButton.size--normal {
56
+ height: var(--dodo-ui-element-height-normal);
57
+ width: var(--dodo-ui-element-height-normal);
58
+ font-size: 1rem;
59
+ }
60
+ .dodo-ui-UtilityButton.size--small {
61
+ height: var(--dodo-ui-element-height-small);
62
+ width: var(--dodo-ui-element-height-small);
63
+ font-size: 0.9rem;
64
+ }
65
+ .dodo-ui-UtilityButton.size--large {
66
+ height: var(--dodo-ui-element-height-large);
67
+ width: var(--dodo-ui-element-height-large);
68
+ font-size: 1.1rem;
69
+ }
70
+ .dodo-ui-UtilityButton[disabled] {
71
+ cursor: initial;
72
+ color: var(--dodo-ui-UtilityButton-disabled-color);
73
+ }
74
+ .dodo-ui-UtilityButton[disabled]:hover {
75
+ color: var(--dodo-ui-UtilityButton-disabled-color);
76
+ }
77
+ .dodo-ui-UtilityButton[disabled]:active {
78
+ color: var(--dodo-ui-UtilityButton-disabled-color);
79
+ }</style>
@@ -0,0 +1,26 @@
1
+ import type { ComponentSize } from '../../../../types.js';
2
+ import type { Snippet } from 'svelte';
3
+ import type { MouseEventHandler } from 'svelte/elements';
4
+ interface UtilityButtonProps {
5
+ /** Button contents goes here*/
6
+ children?: Snippet;
7
+ /** Button ref */
8
+ ref?: HTMLButtonElement;
9
+ /** How large should the button be? */
10
+ size?: ComponentSize;
11
+ /** Button disabled state */
12
+ disabled?: boolean;
13
+ /** Name */
14
+ name?: string;
15
+ /** Id */
16
+ id?: string;
17
+ /** Title (for tooltip) */
18
+ title?: string;
19
+ /** Custom css class*/
20
+ class?: string;
21
+ /** The onclick event handler */
22
+ onclick?: MouseEventHandler<HTMLButtonElement>;
23
+ }
24
+ declare const UtilityButton: import("svelte").Component<UtilityButtonProps, {}, "ref">;
25
+ type UtilityButton = ReturnType<typeof UtilityButton>;
26
+ export default UtilityButton;
@@ -1,10 +1,11 @@
1
1
  :root {
2
- --dodo-ui-element-height-normal: 2.5rem;
3
- --dodo-ui-element-height-small: 2.125rem;
4
- --dodo-ui-element-height-large: 3rem;
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-base: 0.438rem;
7
- --dodo-ui-element-roundness-1: var(--dodo-ui-element-roundness-base);
8
- --dodo-ui-element-roundness-2: calc(var(--dodo-ui-element-roundness-base) * 2);
9
- --dodo-ui-element-roundness-3: calc(var(--dodo-ui-element-roundness-base) * 4);
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
  }