@flightlesslabs/dodo-ui 0.1.5 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/dist/index.d.ts +6 -0
  2. package/dist/index.js +4 -0
  3. package/dist/stories/Home.mdx +57 -7
  4. package/dist/stories/assets/dark-theme-toggle.png +0 -0
  5. package/dist/stories/components/Form/Button/Button.stories.svelte +10 -5
  6. package/dist/stories/components/Form/Button/Button.svelte +213 -211
  7. package/dist/stories/components/Form/Button/Button.svelte.d.ts +4 -1
  8. package/dist/stories/components/Form/Button/Events/Events.stories.svelte +40 -0
  9. package/dist/stories/components/Form/Button/Events/Events.stories.svelte.d.ts +18 -0
  10. package/dist/stories/components/Form/Button/Roundness/Roundness.stories.svelte +14 -11
  11. package/dist/stories/components/Form/Button/utils/scss/mixins.scss +21 -21
  12. package/dist/stories/components/Form/PasswordInput/Events/Events.stories.svelte +168 -0
  13. package/dist/stories/components/Form/PasswordInput/Events/Events.stories.svelte.d.ts +18 -0
  14. package/dist/stories/components/Form/PasswordInput/PasswordInput.stories.svelte +37 -0
  15. package/dist/stories/components/Form/PasswordInput/PasswordInput.stories.svelte.d.ts +21 -0
  16. package/dist/stories/components/Form/PasswordInput/PasswordInput.svelte +219 -0
  17. package/dist/stories/components/Form/PasswordInput/PasswordInput.svelte.d.ts +59 -0
  18. package/dist/stories/components/Form/PasswordInput/Roundness/Roundness.stories.svelte +20 -0
  19. package/dist/stories/components/Form/{ExampleButton/ExampleButton.stories.svelte.d.ts → PasswordInput/Roundness/Roundness.stories.svelte.d.ts} +3 -4
  20. package/dist/stories/components/Form/PasswordInput/Size/Size.stories.svelte +16 -0
  21. package/dist/stories/components/Form/PasswordInput/Size/Size.stories.svelte.d.ts +26 -0
  22. package/dist/stories/components/Form/PasswordInput/WithIcon/WithIcon.stories.svelte +31 -0
  23. package/dist/stories/components/Form/PasswordInput/WithIcon/WithIcon.stories.svelte.d.ts +26 -0
  24. package/dist/stories/components/Form/TextInput/Events/Events.stories.svelte +148 -0
  25. package/dist/stories/components/Form/TextInput/Events/Events.stories.svelte.d.ts +18 -0
  26. package/dist/stories/components/Form/TextInput/Roundness/Roundness.stories.svelte +21 -0
  27. package/dist/stories/components/Form/TextInput/Roundness/Roundness.stories.svelte.d.ts +26 -0
  28. package/dist/stories/components/Form/TextInput/Size/Size.stories.svelte +17 -0
  29. package/dist/stories/components/Form/TextInput/Size/Size.stories.svelte.d.ts +26 -0
  30. package/dist/stories/components/Form/TextInput/TextInput.stories.svelte +35 -0
  31. package/dist/stories/components/Form/TextInput/TextInput.stories.svelte.d.ts +21 -0
  32. package/dist/stories/components/Form/TextInput/TextInput.svelte +166 -0
  33. package/dist/stories/components/Form/TextInput/TextInput.svelte.d.ts +56 -0
  34. package/dist/stories/components/Form/TextInput/WithIcon/WithIcon.stories.svelte +47 -0
  35. package/dist/stories/components/Form/TextInput/WithIcon/WithIcon.stories.svelte.d.ts +26 -0
  36. package/dist/stories/philosophy/Colors/Colors.mdx +43 -0
  37. package/dist/stories/philosophy/Colors/Colors.stories.svelte +20 -0
  38. package/dist/stories/philosophy/Colors/Colors.stories.svelte.d.ts +19 -0
  39. package/dist/stories/philosophy/Colors/Colors.svelte +33 -0
  40. package/dist/stories/philosophy/Colors/Colors.svelte.d.ts +6 -0
  41. package/dist/stories/philosophy/Colors/Opacity.stories.svelte +9 -0
  42. package/dist/stories/philosophy/Colors/Opacity.stories.svelte.d.ts +19 -0
  43. package/dist/stories/philosophy/Colors/Opacity.svelte +20 -0
  44. package/dist/stories/philosophy/Colors/Opacity.svelte.d.ts +18 -0
  45. package/dist/stories/philosophy/Colors/Swatches/Palette.svelte +15 -0
  46. package/dist/stories/philosophy/Colors/Swatches/Palette.svelte.d.ts +6 -0
  47. package/dist/stories/philosophy/Colors/Swatches/Swatch.svelte +18 -0
  48. package/dist/stories/philosophy/Colors/Swatches/Swatch.svelte.d.ts +8 -0
  49. package/dist/stories/philosophy/Colors/Swatches/Swatches.svelte +39 -0
  50. package/dist/stories/philosophy/Colors/Swatches/Swatches.svelte.d.ts +8 -0
  51. package/dist/stories/philosophy/Colors/utils/color.d.ts +4 -0
  52. package/dist/stories/philosophy/Colors/utils/color.js +38 -0
  53. package/dist/stories/philosophy/Themes.mdx +23 -0
  54. package/dist/styles/_colors.css +2 -2
  55. package/dist/styles/_components.css +7 -6
  56. package/dist/styles/_minimal-reset.css +3 -0
  57. package/dist/styles/global.css +1 -0
  58. package/dist/types.d.ts +1 -1
  59. package/package.json +3 -2
  60. package/src/lib/index.ts +13 -0
  61. package/src/lib/stories/components/Form/Button/Button.stories.svelte +10 -5
  62. package/src/lib/stories/components/Form/Button/Button.svelte +36 -30
  63. package/src/lib/stories/components/Form/Button/Events/Events.stories.svelte +42 -0
  64. package/src/lib/stories/components/Form/Button/Roundness/Roundness.stories.svelte +14 -11
  65. package/src/lib/stories/components/Form/Button/utils/scss/mixins.scss +21 -21
  66. package/src/lib/stories/components/Form/PasswordInput/Events/Events.stories.svelte +174 -0
  67. package/src/lib/stories/components/Form/PasswordInput/PasswordInput.stories.svelte +41 -0
  68. package/src/lib/stories/components/Form/PasswordInput/PasswordInput.svelte +361 -0
  69. package/src/lib/stories/components/Form/PasswordInput/Roundness/Roundness.stories.svelte +20 -0
  70. package/src/lib/stories/components/Form/PasswordInput/Size/Size.stories.svelte +16 -0
  71. package/src/lib/stories/components/Form/PasswordInput/WithIcon/WithIcon.stories.svelte +31 -0
  72. package/src/lib/stories/components/Form/TextInput/Events/Events.stories.svelte +153 -0
  73. package/src/lib/stories/components/Form/TextInput/Roundness/Roundness.stories.svelte +21 -0
  74. package/src/lib/stories/components/Form/TextInput/Size/Size.stories.svelte +17 -0
  75. package/src/lib/stories/components/Form/TextInput/TextInput.stories.svelte +39 -0
  76. package/src/lib/stories/components/Form/TextInput/TextInput.svelte +293 -0
  77. package/src/lib/stories/components/Form/TextInput/WithIcon/WithIcon.stories.svelte +47 -0
  78. package/src/lib/styles/_colors.css +2 -2
  79. package/src/lib/styles/_components.css +7 -6
  80. package/src/lib/styles/_minimal-reset.css +3 -0
  81. package/src/lib/styles/global.css +1 -0
  82. package/src/lib/types.ts +1 -1
  83. package/dist/stories/Getting Started.mdx +0 -13
  84. package/dist/stories/components/Form/ExampleButton/ExampleButton.stories.svelte +0 -30
  85. package/dist/stories/components/Form/ExampleButton/ExampleButton.svelte +0 -14
  86. package/dist/stories/components/Form/ExampleButton/ExampleButton.svelte.d.ts +0 -16
  87. package/dist/stories/components/Form/ExampleButton/button.css +0 -30
  88. package/src/lib/stories/components/Form/ExampleButton/ExampleButton.stories.svelte +0 -30
  89. package/src/lib/stories/components/Form/ExampleButton/ExampleButton.svelte +0 -29
  90. package/src/lib/stories/components/Form/ExampleButton/button.css +0 -30
@@ -0,0 +1,293 @@
1
+ <script lang="ts" module>
2
+ export type TextInputRoundness = ComponentRoundness | false;
3
+ export type TextInputType = 'text' | 'tel' | 'email' | 'password' | 'url' | 'number';
4
+
5
+ export type TextInputFocusEvent = FocusEvent & {
6
+ currentTarget: EventTarget & HTMLInputElement;
7
+ };
8
+
9
+ export type TextInputClipboardEvent = ClipboardEvent & {
10
+ currentTarget: EventTarget & HTMLInputElement;
11
+ };
12
+ </script>
13
+
14
+ <script lang="ts">
15
+ import type { ComponentRoundness, ComponentSize } from '$lib/types.js';
16
+ import type { Snippet } from 'svelte';
17
+ import type {
18
+ ChangeEventHandler,
19
+ ClipboardEventHandler,
20
+ FocusEventHandler,
21
+ FormEventHandler,
22
+ } from 'svelte/elements';
23
+
24
+ interface TextInputProps {
25
+ /** Input type? */
26
+ type?: TextInputType;
27
+ /** How large should the button be? */
28
+ size?: ComponentSize;
29
+ /** How round should the border radius be? */
30
+ roundness?: TextInputRoundness;
31
+ /** Add a border around the button. Default True */
32
+ outline?: boolean;
33
+ /** Input value */
34
+ value?: string;
35
+ /** How round should the border radius be? */
36
+ placeholder?: string;
37
+ /** Button disabled state */
38
+ disabled?: boolean;
39
+ /** is there any associated Error ? */
40
+ error?: boolean;
41
+ /** Name */
42
+ name?: string;
43
+ /** Id */
44
+ id?: string;
45
+ /** Icon before button content */
46
+ before?: Snippet;
47
+ /** Icon after button content */
48
+ after?: Snippet;
49
+ /** Custom css class*/
50
+ class?: string;
51
+ /** oninput event handler */
52
+ oninput?: FormEventHandler<HTMLInputElement>;
53
+ /** onchange event handler */
54
+ onchange?: ChangeEventHandler<HTMLInputElement>;
55
+ /** onblur event handler */
56
+ onblur?: FocusEventHandler<HTMLInputElement>;
57
+ /** onfocus event handler */
58
+ onfocus?: FocusEventHandler<HTMLInputElement>;
59
+ /** onpaste event handler */
60
+ onpaste?: ClipboardEventHandler<HTMLInputElement>;
61
+ /** oncopy event handler */
62
+ oncopy?: ClipboardEventHandler<HTMLInputElement>;
63
+ /** oncut event handler */
64
+ oncut?: ClipboardEventHandler<HTMLInputElement>;
65
+ }
66
+
67
+ let {
68
+ type = 'text',
69
+ size = 'normal',
70
+ roundness = '1x',
71
+ outline = true,
72
+ name,
73
+ id,
74
+ class: className = '',
75
+ disabled = false,
76
+ oninput,
77
+ onchange,
78
+ onblur,
79
+ onfocus,
80
+ onpaste,
81
+ oncopy,
82
+ oncut,
83
+ before,
84
+ after,
85
+ error = false,
86
+ value = $bindable<string>(),
87
+ placeholder,
88
+ }: TextInputProps = $props();
89
+
90
+ let focused: boolean = $state(false);
91
+
92
+ function onfocusMod(e: TextInputFocusEvent) {
93
+ focused = true;
94
+
95
+ if (onfocus) {
96
+ onfocus(e);
97
+ }
98
+ }
99
+
100
+ function onblurMod(e: TextInputFocusEvent) {
101
+ focused = false;
102
+
103
+ if (onblur) {
104
+ onblur(e);
105
+ }
106
+ }
107
+ </script>
108
+
109
+ <div
110
+ class:outline
111
+ class:disabled
112
+ class:error
113
+ class:focused
114
+ class={['dodo-ui-TextInput', `size--${size}`, `roundness--${roundness}`, className].join(' ')}
115
+ >
116
+ {#if before}
117
+ <span class="content--before">
118
+ {@render before()}
119
+ </span>
120
+ {/if}
121
+ <input
122
+ {type}
123
+ {name}
124
+ {id}
125
+ {disabled}
126
+ {oninput}
127
+ {onchange}
128
+ onfocus={onfocusMod}
129
+ onblur={onblurMod}
130
+ {onpaste}
131
+ {oncopy}
132
+ {oncut}
133
+ {placeholder}
134
+ bind:value
135
+ />
136
+ {#if after}
137
+ <span class="content--after">
138
+ {@render after()}
139
+ </span>
140
+ {/if}
141
+ </div>
142
+
143
+ <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
+ .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
+ input {
170
+ flex: 1;
171
+ border: 0;
172
+ outline: 0;
173
+ height: 100%;
174
+ background-color: transparent;
175
+ font-family: inherit;
176
+ color: inherit;
177
+ letter-spacing: 0.3px;
178
+ }
179
+
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
+ &.size {
218
+ &--normal {
219
+ height: var(--dodo-ui-element-height-normal);
220
+ input {
221
+ font-size: 1rem;
222
+ padding: 0 12px;
223
+ }
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
+ }
237
+
238
+ &--small {
239
+ height: var(--dodo-ui-element-height-small);
240
+ input {
241
+ padding: 0 8px;
242
+ font-size: 0.9rem;
243
+ }
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
+ }
257
+
258
+ &--large {
259
+ height: var(--dodo-ui-element-height-large);
260
+ input {
261
+ font-size: 1.1rem;
262
+ padding: 0 14px;
263
+ }
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
+ }
291
+ }
292
+ }
293
+ </style>
@@ -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>
@@ -1,9 +1,9 @@
1
1
  :root {
2
- /* Base colors */
2
+ /* Neutral colors */
3
3
  --dodo-color-black: var(--dodo-color-base-black);
4
4
  --dodo-color-white: var(--dodo-color-base-white);
5
5
 
6
- /* Base colors constants */
6
+ /* Constants colors */
7
7
  --dodo-color-constant-black: var(--dodo-color-base-black);
8
8
  --dodo-color-constant-white: var(--dodo-color-base-white);
9
9
 
@@ -1,10 +1,11 @@
1
1
  :root {
2
- --dodo-ui-element-height-normal: 40px;
3
2
  --dodo-ui-element-height-small: 34px;
4
- --dodo-ui-element-height-large: 48px;
3
+ --dodo-ui-element-height-normal: 40px;
4
+ --dodo-ui-element-height-large: 50px;
5
+
6
+ --dodo-ui-element-roundness-1x: 7px;
7
+ --dodo-ui-element-roundness-2x: 13px;
8
+ --dodo-ui-element-roundness-3x: 31px;
5
9
 
6
- --dodo-ui-element-roundness-base: 7px;
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);
10
+ --dodo-ui-element-border-width: 1px;
10
11
  }
@@ -0,0 +1,3 @@
1
+ * {
2
+ box-sizing: border-box;
3
+ }
@@ -1,3 +1,4 @@
1
+ @import '_minimal-reset.css';
1
2
  @import '_colors-base.css';
2
3
  @import '_colors.css';
3
4
  @import '_breakpoint.css';
package/src/lib/types.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /** Component Size */
2
2
  export type ComponentSize = 'normal' | 'small' | 'large';
3
3
 
4
- export type ComponentRoundness = 1 | 2 | 3;
4
+ export type ComponentRoundness = '1x' | '2x' | '3x';
5
5
  export type ComponentRoundnessFull = 'full';
@@ -1,13 +0,0 @@
1
- import { Source } from '@storybook/blocks';
2
-
3
- # Getting Started
4
-
5
- ## Install
6
-
7
- <Source dark language='bash' code={`
8
- // pnpm
9
- pnpm add @flightlesslabs/dodo-ui
10
-
11
- // npm
12
- npm i @flightlesslabs/dodo-ui
13
- `} />
@@ -1,30 +0,0 @@
1
- <script module>
2
- import { defineMeta } from '@storybook/addon-svelte-csf';
3
- import ExampleButton from './ExampleButton.svelte';
4
- import { fn } from '@storybook/test';
5
-
6
- // More on how to set up stories at: https://storybook.js.org/docs/writing-stories
7
- const { Story } = defineMeta({
8
- component: ExampleButton,
9
- tags: ['autodocs'],
10
- argTypes: {
11
- backgroundColor: { control: 'color' },
12
- size: {
13
- control: { type: 'select' },
14
- options: ['small', 'medium', 'large'],
15
- },
16
- },
17
- args: {
18
- onClick: fn(),
19
- },
20
- });
21
- </script>
22
-
23
- <!-- More on writing stories with args: https://storybook.js.org/docs/writing-stories/args -->
24
- <Story name="Primary" args={{ primary: true, label: 'Button' }} />
25
-
26
- <Story name="Secondary" args={{ label: 'Button' }} />
27
-
28
- <Story name="Large" args={{ size: 'large', label: 'Button' }} />
29
-
30
- <Story name="Small" args={{ size: 'small', label: 'Button' }} />
@@ -1,14 +0,0 @@
1
- <script lang="ts">import './button.css';
2
- const { primary = false, backgroundColor, size = 'medium', label, onClick } = $props();
3
- </script>
4
-
5
- <button
6
- type="button"
7
- class={['storybook-button', `storybook-button--${size}`].join(' ')}
8
- class:storybook-button--primary={primary}
9
- class:storybook-button--secondary={!primary}
10
- style:background-color={backgroundColor}
11
- onclick={onClick}
12
- >
13
- {label}
14
- </button>
@@ -1,16 +0,0 @@
1
- import './button.css';
2
- interface Props {
3
- /** Is this the principal call to action on the page? */
4
- primary?: boolean;
5
- /** What background color to use */
6
- backgroundColor?: string;
7
- /** How large should the button be? */
8
- size?: 'small' | 'medium' | 'large';
9
- /** Button contents */
10
- label: string;
11
- /** The onclick event handler */
12
- onClick?: () => void;
13
- }
14
- declare const ExampleButton: import("svelte").Component<Props, {}, "">;
15
- type ExampleButton = ReturnType<typeof ExampleButton>;
16
- export default ExampleButton;
@@ -1,30 +0,0 @@
1
- .storybook-button {
2
- display: inline-block;
3
- cursor: pointer;
4
- border: 0;
5
- border-radius: 3em;
6
- font-weight: 700;
7
- line-height: 1;
8
- font-family: 'Nunito Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
9
- }
10
- .storybook-button--primary {
11
- background-color: #555ab9;
12
- color: white;
13
- }
14
- .storybook-button--secondary {
15
- box-shadow: rgba(0, 0, 0, 0.15) 0px 0px 0px 1px inset;
16
- background-color: transparent;
17
- color: #333;
18
- }
19
- .storybook-button--small {
20
- padding: 10px 16px;
21
- font-size: 12px;
22
- }
23
- .storybook-button--medium {
24
- padding: 11px 20px;
25
- font-size: 14px;
26
- }
27
- .storybook-button--large {
28
- padding: 12px 24px;
29
- font-size: 16px;
30
- }
@@ -1,30 +0,0 @@
1
- <script module>
2
- import { defineMeta } from '@storybook/addon-svelte-csf';
3
- import ExampleButton from './ExampleButton.svelte';
4
- import { fn } from '@storybook/test';
5
-
6
- // More on how to set up stories at: https://storybook.js.org/docs/writing-stories
7
- const { Story } = defineMeta({
8
- component: ExampleButton,
9
- tags: ['autodocs'],
10
- argTypes: {
11
- backgroundColor: { control: 'color' },
12
- size: {
13
- control: { type: 'select' },
14
- options: ['small', 'medium', 'large'],
15
- },
16
- },
17
- args: {
18
- onClick: fn(),
19
- },
20
- });
21
- </script>
22
-
23
- <!-- More on writing stories with args: https://storybook.js.org/docs/writing-stories/args -->
24
- <Story name="Primary" args={{ primary: true, label: 'Button' }} />
25
-
26
- <Story name="Secondary" args={{ label: 'Button' }} />
27
-
28
- <Story name="Large" args={{ size: 'large', label: 'Button' }} />
29
-
30
- <Story name="Small" args={{ size: 'small', label: 'Button' }} />
@@ -1,29 +0,0 @@
1
- <script lang="ts">
2
- import './button.css';
3
-
4
- interface Props {
5
- /** Is this the principal call to action on the page? */
6
- primary?: boolean;
7
- /** What background color to use */
8
- backgroundColor?: string;
9
- /** How large should the button be? */
10
- size?: 'small' | 'medium' | 'large';
11
- /** Button contents */
12
- label: string;
13
- /** The onclick event handler */
14
- onClick?: () => void;
15
- }
16
-
17
- const { primary = false, backgroundColor, size = 'medium', label, onClick }: Props = $props();
18
- </script>
19
-
20
- <button
21
- type="button"
22
- class={['storybook-button', `storybook-button--${size}`].join(' ')}
23
- class:storybook-button--primary={primary}
24
- class:storybook-button--secondary={!primary}
25
- style:background-color={backgroundColor}
26
- onclick={onClick}
27
- >
28
- {label}
29
- </button>
@@ -1,30 +0,0 @@
1
- .storybook-button {
2
- display: inline-block;
3
- cursor: pointer;
4
- border: 0;
5
- border-radius: 3em;
6
- font-weight: 700;
7
- line-height: 1;
8
- font-family: 'Nunito Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
9
- }
10
- .storybook-button--primary {
11
- background-color: #555ab9;
12
- color: white;
13
- }
14
- .storybook-button--secondary {
15
- box-shadow: rgba(0, 0, 0, 0.15) 0px 0px 0px 1px inset;
16
- background-color: transparent;
17
- color: #333;
18
- }
19
- .storybook-button--small {
20
- padding: 10px 16px;
21
- font-size: 12px;
22
- }
23
- .storybook-button--medium {
24
- padding: 11px 20px;
25
- font-size: 14px;
26
- }
27
- .storybook-button--large {
28
- padding: 12px 24px;
29
- font-size: 16px;
30
- }