@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.
Files changed (85) hide show
  1. package/dist/index.d.ts +15 -1
  2. package/dist/index.js +12 -0
  3. package/dist/stories/components/Form/Button/Button.svelte +4 -1
  4. package/dist/stories/components/Form/Button/Button.svelte.d.ts +4 -2
  5. package/dist/stories/components/Form/FormControl/FormControl.stories.svelte +27 -0
  6. package/dist/stories/components/Form/FormControl/FormControl.stories.svelte.d.ts +19 -0
  7. package/dist/stories/components/Form/FormControl/FormControl.svelte +34 -0
  8. package/dist/stories/components/Form/FormControl/FormControl.svelte.d.ts +20 -0
  9. package/dist/stories/components/Form/Label/Label.stories.svelte +21 -0
  10. package/dist/stories/components/Form/Label/Label.stories.svelte.d.ts +19 -0
  11. package/dist/stories/components/Form/Label/Label.svelte +19 -0
  12. package/dist/stories/components/Form/Label/Label.svelte.d.ts +18 -0
  13. package/dist/stories/components/Form/Message/Color/Color.stories.svelte +36 -0
  14. package/dist/stories/components/Form/Message/Color/Color.stories.svelte.d.ts +26 -0
  15. package/dist/stories/components/Form/Message/Message.stories.svelte +31 -0
  16. package/dist/stories/components/Form/Message/Message.stories.svelte.d.ts +21 -0
  17. package/dist/stories/components/Form/Message/Message.svelte +50 -0
  18. package/dist/stories/components/Form/Message/Message.svelte.d.ts +20 -0
  19. package/dist/stories/components/Form/Message/Size/Size.stories.svelte +24 -0
  20. package/dist/stories/components/Form/Message/Size/Size.stories.svelte.d.ts +26 -0
  21. package/dist/stories/components/Form/PasswordInput/PasswordInput.stories.svelte +17 -1
  22. package/dist/stories/components/Form/PasswordInput/PasswordInput.svelte +37 -158
  23. package/dist/stories/components/Form/PasswordInput/PasswordInput.svelte.d.ts +10 -7
  24. package/dist/stories/components/Form/SimpleSelect/Events/Events.stories.svelte +74 -0
  25. package/dist/stories/components/Form/SimpleSelect/Events/Events.stories.svelte.d.ts +18 -0
  26. package/dist/stories/components/Form/SimpleSelect/Roundness/Roundness.stories.svelte +24 -0
  27. package/dist/stories/components/Form/SimpleSelect/Roundness/Roundness.stories.svelte.d.ts +26 -0
  28. package/dist/stories/components/Form/SimpleSelect/SimpleSelect.stories.svelte +59 -0
  29. package/dist/stories/components/Form/SimpleSelect/SimpleSelect.stories.svelte.d.ts +23 -0
  30. package/dist/stories/components/Form/SimpleSelect/SimpleSelect.svelte +69 -0
  31. package/dist/stories/components/Form/SimpleSelect/SimpleSelect.svelte.d.ts +50 -0
  32. package/dist/stories/components/Form/SimpleSelect/Size/Size.stories.svelte +20 -0
  33. package/dist/stories/components/Form/SimpleSelect/Size/Size.stories.svelte.d.ts +26 -0
  34. package/dist/stories/components/Form/SimpleSelect/WithIcon/WithIcon.stories.svelte +36 -0
  35. package/dist/stories/components/Form/SimpleSelect/WithIcon/WithIcon.stories.svelte.d.ts +26 -0
  36. package/dist/stories/components/Form/TextInput/TextInput.stories.svelte +2 -0
  37. package/dist/stories/components/Form/TextInput/TextInput.svelte +22 -118
  38. package/dist/stories/components/Form/TextInput/TextInput.svelte.d.ts +7 -4
  39. package/dist/stories/developer tools/Intro.mdx +7 -0
  40. package/dist/stories/developer tools/components/InputEnclosure/InputEnclosure.stories.svelte +34 -0
  41. package/dist/stories/developer tools/components/InputEnclosure/InputEnclosure.stories.svelte.d.ts +21 -0
  42. package/dist/stories/developer tools/components/InputEnclosure/InputEnclosure.svelte +120 -0
  43. package/dist/stories/developer tools/components/InputEnclosure/InputEnclosure.svelte.d.ts +29 -0
  44. package/dist/stories/developer tools/components/InputEnclosure/Roundness/Roundness.stories.svelte +20 -0
  45. package/dist/stories/developer tools/components/InputEnclosure/Roundness/Roundness.stories.svelte.d.ts +26 -0
  46. package/dist/stories/developer tools/components/InputEnclosure/Size/Size.stories.svelte +16 -0
  47. package/dist/stories/developer tools/components/InputEnclosure/Size/Size.stories.svelte.d.ts +26 -0
  48. package/dist/stories/developer tools/components/InputEnclosure/WithIcon/WithIcon.stories.svelte +47 -0
  49. package/dist/stories/developer tools/components/InputEnclosure/WithIcon/WithIcon.stories.svelte.d.ts +26 -0
  50. package/dist/stories/developer tools/components/UtilityButton/Size/Size.stories.svelte +27 -0
  51. package/dist/stories/developer tools/components/UtilityButton/Size/Size.stories.svelte.d.ts +26 -0
  52. package/dist/stories/developer tools/components/UtilityButton/UtilityButton.stories.svelte +29 -0
  53. package/dist/stories/developer tools/components/UtilityButton/UtilityButton.stories.svelte.d.ts +21 -0
  54. package/dist/stories/developer tools/components/UtilityButton/UtilityButton.svelte +79 -0
  55. package/dist/stories/developer tools/components/UtilityButton/UtilityButton.svelte.d.ts +26 -0
  56. package/package.json +30 -30
  57. package/src/lib/index.ts +23 -1
  58. package/src/lib/stories/components/Form/Button/Button.svelte +8 -2
  59. package/src/lib/stories/components/Form/FormControl/FormControl.stories.svelte +29 -0
  60. package/src/lib/stories/components/Form/FormControl/FormControl.svelte +67 -0
  61. package/src/lib/stories/components/Form/Label/Label.stories.svelte +23 -0
  62. package/src/lib/stories/components/Form/Label/Label.svelte +45 -0
  63. package/src/lib/stories/components/Form/Message/Color/Color.stories.svelte +36 -0
  64. package/src/lib/stories/components/Form/Message/Message.stories.svelte +35 -0
  65. package/src/lib/stories/components/Form/Message/Message.svelte +92 -0
  66. package/src/lib/stories/components/Form/Message/Size/Size.stories.svelte +24 -0
  67. package/src/lib/stories/components/Form/PasswordInput/PasswordInput.stories.svelte +17 -1
  68. package/src/lib/stories/components/Form/PasswordInput/PasswordInput.svelte +51 -196
  69. package/src/lib/stories/components/Form/SimpleSelect/Events/Events.stories.svelte +79 -0
  70. package/src/lib/stories/components/Form/SimpleSelect/Roundness/Roundness.stories.svelte +24 -0
  71. package/src/lib/stories/components/Form/SimpleSelect/SimpleSelect.stories.svelte +64 -0
  72. package/src/lib/stories/components/Form/SimpleSelect/SimpleSelect.svelte +159 -0
  73. package/src/lib/stories/components/Form/SimpleSelect/Size/Size.stories.svelte +20 -0
  74. package/src/lib/stories/components/Form/SimpleSelect/WithIcon/WithIcon.stories.svelte +36 -0
  75. package/src/lib/stories/components/Form/TextInput/TextInput.stories.svelte +2 -0
  76. package/src/lib/stories/components/Form/TextInput/TextInput.svelte +29 -142
  77. package/src/lib/stories/developer tools/Intro.mdx +7 -0
  78. package/src/lib/stories/developer tools/components/InputEnclosure/InputEnclosure.stories.svelte +38 -0
  79. package/src/lib/stories/developer tools/components/InputEnclosure/InputEnclosure.svelte +198 -0
  80. package/src/lib/stories/developer tools/components/InputEnclosure/Roundness/Roundness.stories.svelte +20 -0
  81. package/src/lib/stories/developer tools/components/InputEnclosure/Size/Size.stories.svelte +16 -0
  82. package/src/lib/stories/developer tools/components/InputEnclosure/WithIcon/WithIcon.stories.svelte +47 -0
  83. package/src/lib/stories/developer tools/components/UtilityButton/Size/Size.stories.svelte +27 -0
  84. package/src/lib/stories/developer tools/components/UtilityButton/UtilityButton.stories.svelte +33 -0
  85. package/src/lib/stories/developer tools/components/UtilityButton/UtilityButton.svelte +128 -0
@@ -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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flightlesslabs/dodo-ui",
3
- "version": "0.3.0",
3
+ "version": "0.5.0",
4
4
  "scripts": {
5
5
  "build": "vite build && pnpm run prepack",
6
6
  "preview": "vite preview",
@@ -48,42 +48,42 @@
48
48
  "svelte": "^5.0.0"
49
49
  },
50
50
  "devDependencies": {
51
- "@chromatic-com/storybook": "^3",
52
- "@eslint/compat": "^1.2.5",
53
- "@eslint/js": "^9.18.0",
54
- "@storybook/addon-essentials": "^8.6.7",
55
- "@storybook/addon-svelte-csf": "^5.0.0-next.0",
56
- "@storybook/blocks": "^8.6.7",
57
- "@storybook/experimental-addon-test": "^8.6.7",
51
+ "@chromatic-com/storybook": "^3.2.6",
52
+ "@eslint/compat": "^1.2.8",
53
+ "@eslint/js": "^9.24.0",
54
+ "@storybook/addon-essentials": "^8.6.12",
55
+ "@storybook/addon-svelte-csf": "5.0.0-next.28",
56
+ "@storybook/blocks": "^8.6.12",
57
+ "@storybook/experimental-addon-test": "^8.6.12",
58
58
  "@storybook/manager-api": "^8.6.12",
59
- "@storybook/svelte": "^8.6.7",
60
- "@storybook/sveltekit": "^8.6.7",
61
- "@storybook/test": "^8.6.7",
59
+ "@storybook/svelte": "^8.6.12",
60
+ "@storybook/sveltekit": "^8.6.12",
61
+ "@storybook/test": "^8.6.12",
62
62
  "@storybook/theming": "^8.6.12",
63
- "@sveltejs/adapter-auto": "^4.0.0",
64
- "@sveltejs/kit": "^2.16.0",
65
- "@sveltejs/package": "^2.0.0",
66
- "@sveltejs/vite-plugin-svelte": "^5.0.0",
67
- "@vitest/browser": "^3.0.9",
68
- "@vitest/coverage-v8": "^3.0.9",
69
- "eslint": "^9.18.0",
70
- "eslint-config-prettier": "^10.0.1",
71
- "eslint-plugin-svelte": "^3.0.0",
63
+ "@sveltejs/adapter-static": "^3.0.8",
64
+ "@sveltejs/kit": "^2.20.5",
65
+ "@sveltejs/package": "^2.3.10",
66
+ "@sveltejs/vite-plugin-svelte": "^5.0.3",
67
+ "@vitest/browser": "^3.1.1",
68
+ "@vitest/coverage-v8": "^3.1.1",
69
+ "eslint": "^9.24.0",
70
+ "eslint-config-prettier": "^10.1.1",
71
+ "eslint-plugin-svelte": "^3.5.1",
72
72
  "globals": "^16.0.0",
73
73
  "playwright": "^1.51.1",
74
- "prettier": "^3.4.2",
74
+ "prettier": "^3.5.3",
75
75
  "prettier-plugin-svelte": "^3.3.3",
76
- "publint": "^0.3.2",
77
- "sass": "^1.86.0",
78
- "storybook": "^8.6.7",
76
+ "publint": "^0.3.11",
77
+ "sass": "^1.86.3",
78
+ "storybook": "^8.6.12",
79
79
  "storybook-dark-mode": "^4.0.2",
80
- "svelte": "^5.0.0",
81
- "svelte-check": "^4.0.0",
80
+ "svelte": "^5.25.10",
81
+ "svelte-check": "^4.1.5",
82
82
  "svelte-preprocess": "^6.0.3",
83
- "typescript": "^5.0.0",
84
- "typescript-eslint": "^8.20.0",
85
- "vite": "^6.0.0",
86
- "vitest": "^3.0.9"
83
+ "typescript": "^5.8.3",
84
+ "typescript-eslint": "^8.29.1",
85
+ "vite": "^6.2.5",
86
+ "vitest": "^3.1.1"
87
87
  },
88
88
  "keywords": [
89
89
  "svelte"
package/src/lib/index.ts CHANGED
@@ -2,6 +2,12 @@ import '$lib/styles/global.css';
2
2
 
3
3
  export type { ComponentSize, ComponentRoundness, ComponentRoundnessFull } from './types.js';
4
4
 
5
+ /** developer tools: components: UtilityButton */
6
+ export { default as UtilityButton } from '$lib/stories/developer tools/components/UtilityButton/UtilityButton.svelte';
7
+
8
+ /** developer tools: components: InputEnclosure */
9
+ export { default as InputEnclosure } from '$lib/stories/developer tools/components/InputEnclosure/InputEnclosure.svelte';
10
+
5
11
  /** Form: Button */
6
12
  export { default as Button } from '$lib/stories/components/Form/Button/Button.svelte';
7
13
  export type {
@@ -14,7 +20,6 @@ export type {
14
20
  /** Form: TextInput */
15
21
  export { default as TextInput } from '$lib/stories/components/Form/TextInput/TextInput.svelte';
16
22
  export type {
17
- TextInputRoundness,
18
23
  TextInputType,
19
24
  TextInputFocusEvent,
20
25
  TextInputClipboardEvent,
@@ -23,3 +28,20 @@ export type {
23
28
  /** Form: PasswordInput */
24
29
  export { default as PasswordInput } from '$lib/stories/components/Form/PasswordInput/PasswordInput.svelte';
25
30
  export type { PasswordInputToggleEvent } from '$lib/stories/components/Form/PasswordInput/PasswordInput.svelte';
31
+
32
+ /** Form: Label */
33
+ export { default as Label } from '$lib/stories/components/Form/Label/Label.svelte';
34
+
35
+ /** Form: FormControl */
36
+ export { default as FormControl } from '$lib/stories/components/Form/FormControl/FormControl.svelte';
37
+
38
+ /** Form: Message */
39
+ export { default as Message } from '$lib/stories/components/Form/Message/Message.svelte';
40
+ export type { MessageColor } from '$lib/stories/components/Form/Message/Message.svelte';
41
+
42
+ /** Form: SimpleSelect */
43
+ export { default as SimpleSelect } from '$lib/stories/components/Form/SimpleSelect/SimpleSelect.svelte';
44
+ export type {
45
+ SimpleSelectFocusEvent,
46
+ SimpleSelectOption,
47
+ } from '$lib/stories/components/Form/SimpleSelect/SimpleSelect.svelte';
@@ -18,8 +18,10 @@
18
18
  import type { MouseEventHandler } from 'svelte/elements';
19
19
 
20
20
  interface ButtonProps {
21
- /** Button contents goes here*/
21
+ /** Button contents goes here */
22
22
  children?: Snippet;
23
+ /** Button ref */
24
+ ref?: HTMLButtonElement | HTMLAnchorElement;
23
25
  /** Regular button or submit button? */
24
26
  type?: 'button' | 'submit';
25
27
  /** How large should the button be? */
@@ -75,7 +77,7 @@
75
77
  _unsafeChildrenStringForTesting?: string;
76
78
  }
77
79
 
78
- const {
80
+ let {
79
81
  children,
80
82
  type = 'button',
81
83
  size = 'normal',
@@ -103,6 +105,7 @@
103
105
  anchorMediaType,
104
106
  referrerpolicy,
105
107
  _unsafeChildrenStringForTesting,
108
+ ref = $bindable<HTMLButtonElement | HTMLAnchorElement>(),
106
109
  }: ButtonProps = $props();
107
110
  </script>
108
111
 
@@ -151,6 +154,7 @@
151
154
  `roundness--${roundness}`,
152
155
  className,
153
156
  ].join(' ')}
157
+ bind:this={ref}
154
158
  >
155
159
  {@render buttonContent()}
156
160
  </a>
@@ -173,6 +177,7 @@
173
177
  {title}
174
178
  {disabled}
175
179
  {onclick}
180
+ bind:this={ref}
176
181
  >
177
182
  {@render buttonContent()}
178
183
  </button>
@@ -222,6 +227,7 @@
222
227
  outline: 0;
223
228
  color: inherit;
224
229
  letter-spacing: 0.3px;
230
+ font-family: inherit;
225
231
 
226
232
  &.size {
227
233
  &--normal {
@@ -0,0 +1,29 @@
1
+ <script module lang="ts">
2
+ import { defineMeta } from '@storybook/addon-svelte-csf';
3
+ import FormControl from './FormControl.svelte';
4
+ import TextInput from '../TextInput/TextInput.svelte';
5
+
6
+ // More on how to set up stories at: https://storybook.js.org/docs/writing-stories
7
+ const { Story } = defineMeta({
8
+ component: FormControl,
9
+ tags: ['autodocs'],
10
+ });
11
+ </script>
12
+
13
+ <Story name="Default" args={{ label: 'Hello there' }} />
14
+
15
+ <Story name="Example TextInput" args={{ label: 'Whats your first name?' }}>
16
+ <FormControl label="Whats your first name?" for="first-name-01">
17
+ <TextInput placeholder="First name" id="first-name-01" />
18
+ </FormControl>
19
+ </Story>
20
+
21
+ <Story name="ErrorMessage" args={{ label: 'Whats your first name?' }}>
22
+ <FormControl
23
+ label="Whats your first name?"
24
+ for="first-name-02"
25
+ errorMessage="This is an error message"
26
+ >
27
+ <TextInput value="John Smith" id="first-name-02" error />
28
+ </FormControl>
29
+ </Story>
@@ -0,0 +1,67 @@
1
+ <script lang="ts">
2
+ import type { Snippet } from 'svelte';
3
+ import Label from '../Label/Label.svelte';
4
+ import Message from '../Message/Message.svelte';
5
+
6
+ interface FormControlProps {
7
+ /** FormControl contents goes here */
8
+ children?: Snippet;
9
+ /** Label for FormControl */
10
+ label?: string;
11
+ /** is there any associated Error Message ? */
12
+ errorMessage?: string;
13
+ /** Label ref */
14
+ ref?: HTMLDivElement;
15
+ /** id of the form element the label should be bound to */
16
+ for?: string;
17
+ /** Specifies which form the label belongs to */
18
+ form?: string;
19
+ /** Custom css class*/
20
+ class?: string;
21
+ }
22
+
23
+ let {
24
+ children,
25
+ label,
26
+ class: className = '',
27
+ for: htmlFor,
28
+ form,
29
+ ref = $bindable<HTMLDivElement>(),
30
+ errorMessage,
31
+ }: FormControlProps = $props();
32
+ </script>
33
+
34
+ <div class={['dodo-ui-FormControl', className].join(' ')} bind:this={ref}>
35
+ {#if label}
36
+ <div class="LabelSection">
37
+ <Label for={htmlFor} {form}>{label}</Label>
38
+ </div>
39
+ {/if}
40
+ <div class="content">
41
+ {#if children}
42
+ {@render children()}
43
+ {/if}
44
+ </div>
45
+ {#if errorMessage}
46
+ <div class="errorMessage">
47
+ <Message color="danger">{errorMessage}</Message>
48
+ </div>
49
+ {/if}
50
+ </div>
51
+
52
+ <style lang="scss">
53
+ :global(:root) {
54
+ --dodo-ui-FormControl-LabelSection-gap: 8px;
55
+ --dodo-ui-FormControl-errorMessage-gap: 10px;
56
+ }
57
+
58
+ .dodo-ui-FormControl {
59
+ .LabelSection {
60
+ margin-bottom: var(--dodo-ui-FormControl-LabelSection-gap);
61
+ }
62
+
63
+ .errorMessage {
64
+ margin-top: var(--dodo-ui-FormControl-errorMessage-gap);
65
+ }
66
+ }
67
+ </style>
@@ -0,0 +1,23 @@
1
+ <script module lang="ts">
2
+ import { defineMeta } from '@storybook/addon-svelte-csf';
3
+ import Label from './Label.svelte';
4
+
5
+ // More on how to set up stories at: https://storybook.js.org/docs/writing-stories
6
+ const { Story } = defineMeta({
7
+ component: Label,
8
+ tags: ['autodocs'],
9
+ });
10
+ </script>
11
+
12
+ <!-- ⚠️ Test Label: Do not use! -->
13
+ <Story
14
+ name="Test Label"
15
+ args={{
16
+ _unsafeChildrenStringForTesting: 'This is a form label',
17
+ }}
18
+ />
19
+
20
+ <!-- Label with default style -->
21
+ <Story name="Default">
22
+ <Label>This is a form label</Label>
23
+ </Story>
@@ -0,0 +1,45 @@
1
+ <script lang="ts">
2
+ import type { Snippet } from 'svelte';
3
+
4
+ interface LabelProps {
5
+ /** Label contents goes here */
6
+ children?: Snippet;
7
+ /** Label ref */
8
+ ref?: HTMLLabelElement;
9
+ /** id of the form element the label should be bound to */
10
+ for?: string;
11
+ /** Specifies which form the label belongs to */
12
+ form?: string;
13
+ /** Custom css class*/
14
+ class?: string;
15
+ /** Test: ⚠️ Unsafe Children String. Do Not use*/
16
+ _unsafeChildrenStringForTesting?: string;
17
+ }
18
+
19
+ let {
20
+ children,
21
+ class: className = '',
22
+ for: htmlFor,
23
+ form,
24
+ _unsafeChildrenStringForTesting,
25
+ ref = $bindable<HTMLLabelElement>(),
26
+ }: LabelProps = $props();
27
+ </script>
28
+
29
+ <label class={['dodo-ui-Label', className].join(' ')} for={htmlFor} {form} bind:this={ref}>
30
+ {#if children}
31
+ {@render children()}
32
+ {:else if _unsafeChildrenStringForTesting}
33
+ {_unsafeChildrenStringForTesting}
34
+ {/if}
35
+ </label>
36
+
37
+ <style lang="scss">
38
+ .dodo-ui-Label {
39
+ font-size: 0.95rem;
40
+ color: var(--dodo-color-default-700);
41
+ display: flex;
42
+ align-items: center;
43
+ font-family: inherit;
44
+ }
45
+ </style>
@@ -0,0 +1,36 @@
1
+ <script module>
2
+ import { defineMeta } from '@storybook/addon-svelte-csf';
3
+ import Message from '../Message.svelte';
4
+ import { storyMessageArgTypes } from '../Message.stories.svelte';
5
+
6
+ // More on how to set up stories at: https://storybook.js.org/docs/writing-stories
7
+ const { Story } = defineMeta({
8
+ component: Message,
9
+ tags: ['autodocs'],
10
+ argTypes: storyMessageArgTypes,
11
+ });
12
+ </script>
13
+
14
+ <Story name="Default">
15
+ <Message>Lorem ipsum dolor sit amet, consectetur adipiscing elit</Message>
16
+ </Story>
17
+
18
+ <Story name="Primary" args={{ color: 'primary' }}>
19
+ <Message color="primary">Lorem ipsum dolor sit amet, consectetur adipiscing elit</Message>
20
+ </Story>
21
+
22
+ <Story name="Safe" args={{ color: 'safe' }}>
23
+ <Message color="safe">Lorem ipsum dolor sit amet, consectetur adipiscing elit</Message>
24
+ </Story>
25
+
26
+ <Story name="Warning" args={{ color: 'warning' }}>
27
+ <Message color="warning">Lorem ipsum dolor sit amet, consectetur adipiscing elit</Message>
28
+ </Story>
29
+
30
+ <Story name="Danger" args={{ color: 'danger' }}>
31
+ <Message color="danger">Lorem ipsum dolor sit amet, consectetur adipiscing elit</Message>
32
+ </Story>
33
+
34
+ <Story name="Info" args={{ color: 'info' }}>
35
+ <Message color="info">Lorem ipsum dolor sit amet, consectetur adipiscing elit</Message>
36
+ </Story>
@@ -0,0 +1,35 @@
1
+ <script module lang="ts">
2
+ import { defineMeta } from '@storybook/addon-svelte-csf';
3
+ import Message from './Message.svelte';
4
+ import type { StoryBookArgTypes } from '$lib/storybook-types.js';
5
+
6
+ export const storyMessageArgTypes: StoryBookArgTypes = {
7
+ color: {
8
+ control: { type: 'select' },
9
+ options: ['default', 'primary', 'safe', 'warning', 'danger', 'info'],
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: Message,
20
+ tags: ['autodocs'],
21
+ argTypes: storyMessageArgTypes,
22
+ });
23
+ </script>
24
+
25
+ <!-- ⚠️ Test Message: Do not use! -->
26
+ <Story
27
+ name="Test Message"
28
+ args={{
29
+ _unsafeChildrenStringForTesting: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit',
30
+ }}
31
+ />
32
+
33
+ <Story name="Default">
34
+ <Message>Lorem ipsum dolor sit amet, consectetur adipiscing elit</Message>
35
+ </Story>