@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.
Files changed (64) hide show
  1. package/dist/index.d.ts +6 -0
  2. package/dist/index.js +4 -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 +213 -208
  6. package/dist/stories/components/Form/Button/Button.svelte.d.ts +4 -1
  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/PasswordInput/Events/Events.stories.svelte +168 -0
  11. package/dist/stories/components/Form/PasswordInput/Events/Events.stories.svelte.d.ts +18 -0
  12. package/dist/stories/components/Form/PasswordInput/PasswordInput.stories.svelte +37 -0
  13. package/dist/stories/components/Form/PasswordInput/PasswordInput.stories.svelte.d.ts +21 -0
  14. package/dist/stories/components/Form/PasswordInput/PasswordInput.svelte +219 -0
  15. package/dist/stories/components/Form/PasswordInput/PasswordInput.svelte.d.ts +59 -0
  16. package/dist/stories/components/Form/PasswordInput/Roundness/Roundness.stories.svelte +20 -0
  17. package/dist/stories/components/Form/{ExampleButton/ExampleButton.stories.svelte.d.ts → PasswordInput/Roundness/Roundness.stories.svelte.d.ts} +3 -4
  18. package/dist/stories/components/Form/PasswordInput/Size/Size.stories.svelte +16 -0
  19. package/dist/stories/components/Form/PasswordInput/Size/Size.stories.svelte.d.ts +26 -0
  20. package/dist/stories/components/Form/PasswordInput/WithIcon/WithIcon.stories.svelte +31 -0
  21. package/dist/stories/components/Form/PasswordInput/WithIcon/WithIcon.stories.svelte.d.ts +26 -0
  22. package/dist/stories/components/Form/TextInput/Events/Events.stories.svelte +148 -0
  23. package/dist/stories/components/Form/TextInput/Events/Events.stories.svelte.d.ts +18 -0
  24. package/dist/stories/components/Form/TextInput/Roundness/Roundness.stories.svelte +21 -0
  25. package/dist/stories/components/Form/TextInput/Roundness/Roundness.stories.svelte.d.ts +26 -0
  26. package/dist/stories/components/Form/TextInput/Size/Size.stories.svelte +17 -0
  27. package/dist/stories/components/Form/TextInput/Size/Size.stories.svelte.d.ts +26 -0
  28. package/dist/stories/components/Form/TextInput/TextInput.stories.svelte +35 -0
  29. package/dist/stories/components/Form/TextInput/TextInput.stories.svelte.d.ts +21 -0
  30. package/dist/stories/components/Form/TextInput/TextInput.svelte +166 -0
  31. package/dist/stories/components/Form/TextInput/TextInput.svelte.d.ts +56 -0
  32. package/dist/stories/components/Form/TextInput/WithIcon/WithIcon.stories.svelte +47 -0
  33. package/dist/stories/components/Form/TextInput/WithIcon/WithIcon.stories.svelte.d.ts +26 -0
  34. package/dist/styles/_components.css +8 -7
  35. package/dist/styles/_minimal-reset.css +3 -0
  36. package/dist/styles/global.css +1 -0
  37. package/package.json +1 -1
  38. package/src/lib/index.ts +13 -0
  39. package/src/lib/stories/components/Form/Button/Button.stories.svelte +10 -5
  40. package/src/lib/stories/components/Form/Button/Button.svelte +32 -22
  41. package/src/lib/stories/components/Form/Button/Events/Events.stories.svelte +42 -0
  42. package/src/lib/stories/components/Form/Button/utils/scss/mixins.scss +21 -21
  43. package/src/lib/stories/components/Form/PasswordInput/Events/Events.stories.svelte +174 -0
  44. package/src/lib/stories/components/Form/PasswordInput/PasswordInput.stories.svelte +41 -0
  45. package/src/lib/stories/components/Form/PasswordInput/PasswordInput.svelte +361 -0
  46. package/src/lib/stories/components/Form/PasswordInput/Roundness/Roundness.stories.svelte +20 -0
  47. package/src/lib/stories/components/Form/PasswordInput/Size/Size.stories.svelte +16 -0
  48. package/src/lib/stories/components/Form/PasswordInput/WithIcon/WithIcon.stories.svelte +31 -0
  49. package/src/lib/stories/components/Form/TextInput/Events/Events.stories.svelte +153 -0
  50. package/src/lib/stories/components/Form/TextInput/Roundness/Roundness.stories.svelte +21 -0
  51. package/src/lib/stories/components/Form/TextInput/Size/Size.stories.svelte +17 -0
  52. package/src/lib/stories/components/Form/TextInput/TextInput.stories.svelte +39 -0
  53. package/src/lib/stories/components/Form/TextInput/TextInput.svelte +293 -0
  54. package/src/lib/stories/components/Form/TextInput/WithIcon/WithIcon.stories.svelte +47 -0
  55. package/src/lib/styles/_components.css +8 -7
  56. package/src/lib/styles/_minimal-reset.css +3 -0
  57. package/src/lib/styles/global.css +1 -0
  58. package/dist/stories/components/Form/ExampleButton/ExampleButton.stories.svelte +0 -30
  59. package/dist/stories/components/Form/ExampleButton/ExampleButton.svelte +0 -14
  60. package/dist/stories/components/Form/ExampleButton/ExampleButton.svelte.d.ts +0 -16
  61. package/dist/stories/components/Form/ExampleButton/button.css +0 -30
  62. package/src/lib/stories/components/Form/ExampleButton/ExampleButton.stories.svelte +0 -30
  63. package/src/lib/stories/components/Form/ExampleButton/ExampleButton.svelte +0 -29
  64. package/src/lib/stories/components/Form/ExampleButton/button.css +0 -30
@@ -3,15 +3,15 @@
3
3
  /// across different interaction states (default, hover, active).
4
4
  /// @param {String} $color-name - The theme color name (e.g., "primary", "safe", etc.)
5
5
  @mixin generate-dodo-ui-button-colors($color-name) {
6
- --dodo-ui-button-outline-#{$color-name}: var(--dodo-color-#{$color-name}-400);
6
+ --dodo-ui-Button-outline-#{$color-name}: var(--dodo-color-#{$color-name}-400);
7
7
 
8
- --dodo-ui-button-text-#{$color-name}-bg: var(--dodo-color-#{$color-name}-100);
9
- --dodo-ui-button-text-#{$color-name}-hover-bg: var(--dodo-color-#{$color-name}-200);
10
- --dodo-ui-button-text-#{$color-name}-active-bg: var(--dodo-color-#{$color-name}-300);
8
+ --dodo-ui-Button-text-#{$color-name}-bg: var(--dodo-color-#{$color-name}-100);
9
+ --dodo-ui-Button-text-#{$color-name}-hover-bg: var(--dodo-color-#{$color-name}-200);
10
+ --dodo-ui-Button-text-#{$color-name}-active-bg: var(--dodo-color-#{$color-name}-300);
11
11
 
12
- --dodo-ui-button-solid-#{$color-name}-bg: var(--dodo-color-#{$color-name}-500);
13
- --dodo-ui-button-solid-#{$color-name}-hover-bg: var(--dodo-color-#{$color-name}-600);
14
- --dodo-ui-button-solid-#{$color-name}-active-bg: var(--dodo-color-#{$color-name}-700);
12
+ --dodo-ui-Button-solid-#{$color-name}-bg: var(--dodo-color-#{$color-name}-500);
13
+ --dodo-ui-Button-solid-#{$color-name}-hover-bg: var(--dodo-color-#{$color-name}-600);
14
+ --dodo-ui-Button-solid-#{$color-name}-active-bg: var(--dodo-color-#{$color-name}-700);
15
15
  }
16
16
 
17
17
  /// Mixin: generate-dodo-ui-button-colors
@@ -19,15 +19,15 @@
19
19
  /// across different interaction states (default, hover, active).
20
20
  /// @param {String} $color-name - The theme color name (e.g., "primary", "safe", etc.)
21
21
  @mixin generate-dodo-ui-button-colors-dark($color-name) {
22
- --dodo-ui-button-outline-#{$color-name}: var(--dodo-color-#{$color-name}-300);
22
+ --dodo-ui-Button-outline-#{$color-name}: var(--dodo-color-#{$color-name}-300);
23
23
 
24
- --dodo-ui-button-text-#{$color-name}-bg: var(--dodo-color-#{$color-name}-50);
25
- --dodo-ui-button-text-#{$color-name}-hover-bg: var(--dodo-color-#{$color-name}-100);
26
- --dodo-ui-button-text-#{$color-name}-active-bg: var(--dodo-color-#{$color-name}-200);
24
+ --dodo-ui-Button-text-#{$color-name}-bg: var(--dodo-color-#{$color-name}-50);
25
+ --dodo-ui-Button-text-#{$color-name}-hover-bg: var(--dodo-color-#{$color-name}-100);
26
+ --dodo-ui-Button-text-#{$color-name}-active-bg: var(--dodo-color-#{$color-name}-200);
27
27
 
28
- --dodo-ui-button-solid-#{$color-name}-bg: var(--dodo-color-#{$color-name}-300);
29
- --dodo-ui-button-solid-#{$color-name}-hover-bg: var(--dodo-color-#{$color-name}-200);
30
- --dodo-ui-button-solid-#{$color-name}-active-bg: var(--dodo-color-#{$color-name}-100);
28
+ --dodo-ui-Button-solid-#{$color-name}-bg: var(--dodo-color-#{$color-name}-300);
29
+ --dodo-ui-Button-solid-#{$color-name}-hover-bg: var(--dodo-color-#{$color-name}-200);
30
+ --dodo-ui-Button-solid-#{$color-name}-active-bg: var(--dodo-color-#{$color-name}-100);
31
31
  }
32
32
 
33
33
  /// Mixin: generate-dodo-ui-button-color
@@ -38,31 +38,31 @@
38
38
  &.variant {
39
39
  &--text {
40
40
  color: var(--dodo-color-#{$theme}-800);
41
- background-color: var(--dodo-ui-button-text-#{$theme}-bg);
41
+ background-color: var(--dodo-ui-Button-text-#{$theme}-bg);
42
42
 
43
43
  &:hover {
44
- background-color: var(--dodo-ui-button-text-#{$theme}-hover-bg);
44
+ background-color: var(--dodo-ui-Button-text-#{$theme}-hover-bg);
45
45
  }
46
46
 
47
47
  &:active {
48
- background-color: var(--dodo-ui-button-text-#{$theme}-active-bg);
48
+ background-color: var(--dodo-ui-Button-text-#{$theme}-active-bg);
49
49
  }
50
50
 
51
51
  &.outline {
52
- border-color: var(--dodo-ui-button-outline-#{$theme});
52
+ border-color: var(--dodo-ui-Button-outline-#{$theme});
53
53
  }
54
54
  }
55
55
 
56
56
  &--solid {
57
57
  color: var(--dodo-color-constant-white);
58
- background-color: var(--dodo-ui-button-solid-#{$theme}-bg);
58
+ background-color: var(--dodo-ui-Button-solid-#{$theme}-bg);
59
59
 
60
60
  &:hover {
61
- background-color: var(--dodo-ui-button-solid-#{$theme}-hover-bg);
61
+ background-color: var(--dodo-ui-Button-solid-#{$theme}-hover-bg);
62
62
  }
63
63
 
64
64
  &:active {
65
- background-color: var(--dodo-ui-button-solid-#{$theme}-active-bg);
65
+ background-color: var(--dodo-ui-Button-solid-#{$theme}-active-bg);
66
66
  }
67
67
  }
68
68
  }
@@ -0,0 +1,174 @@
1
+ <script module lang="ts">
2
+ import { defineMeta } from '@storybook/addon-svelte-csf';
3
+ import { storyPasswordInputArgTypes } from '../PasswordInput.stories.svelte';
4
+ import PasswordInput, { type PasswordInputToggleEvent } from '../PasswordInput.svelte';
5
+ import type {
6
+ TextInputFocusEvent,
7
+ TextInputClipboardEvent,
8
+ } from '../../TextInput/TextInput.svelte';
9
+
10
+ // More on how to set up stories at: https://storybook.js.org/docs/writing-stories
11
+ const { Story } = defineMeta({
12
+ component: PasswordInput,
13
+ tags: ['autodocs'],
14
+ argTypes: storyPasswordInputArgTypes,
15
+ });
16
+ </script>
17
+
18
+ <Story
19
+ name="Input"
20
+ args={{
21
+ oninput: (e: Event) => {
22
+ const target = e.target as HTMLInputElement;
23
+
24
+ console.log('Input Event', target.value);
25
+ },
26
+ }}
27
+ >
28
+ <PasswordInput
29
+ oninput={(e: Event) => {
30
+ const target = e.target as HTMLInputElement;
31
+
32
+ console.log('Input Event', target.value);
33
+ }}
34
+ />
35
+ </Story>
36
+
37
+ <Story
38
+ name="Change"
39
+ args={{
40
+ onchange: (e: Event) => {
41
+ const target = e.target as HTMLInputElement;
42
+
43
+ console.log('onChange Event', target.value);
44
+ },
45
+ }}
46
+ >
47
+ <PasswordInput
48
+ onchange={(e: Event) => {
49
+ const target = e.target as HTMLInputElement;
50
+
51
+ console.log('onchange Event', target.value);
52
+ }}
53
+ />
54
+ </Story>
55
+
56
+ <!-- `e: PasswordInputToggleEvent` -->
57
+ <Story
58
+ name="Toggle"
59
+ args={{
60
+ ontoggle: (e: PasswordInputToggleEvent) => {
61
+ const target = e.event.target as HTMLButtonElement;
62
+
63
+ console.log('ontoggle Event', e, target);
64
+ },
65
+ }}
66
+ >
67
+ <PasswordInput
68
+ ontoggle={(e: PasswordInputToggleEvent) => {
69
+ const target = e.event.target as HTMLButtonElement;
70
+
71
+ console.log('ontoggle Event', e, target);
72
+ }}
73
+ />
74
+ </Story>
75
+
76
+ <!-- `e: TextInputFocusEvent` -->
77
+ <Story
78
+ name="Focus"
79
+ args={{
80
+ onfocus: (e: TextInputFocusEvent) => {
81
+ const target = e.target as HTMLInputElement;
82
+
83
+ console.log('onfocus Event', target);
84
+ },
85
+ }}
86
+ >
87
+ <PasswordInput
88
+ onfocus={(e: TextInputFocusEvent) => {
89
+ const target = e.target as HTMLInputElement;
90
+
91
+ console.log('onfocus Event', target);
92
+ }}
93
+ />
94
+ </Story>
95
+
96
+ <!-- `e: TextInputFocusEvent` -->
97
+ <Story
98
+ name="Blur"
99
+ args={{
100
+ onblur: (e: TextInputFocusEvent) => {
101
+ const target = e.target as HTMLInputElement;
102
+
103
+ console.log('onblur Event', target);
104
+ },
105
+ }}
106
+ >
107
+ <PasswordInput
108
+ onblur={(e: TextInputFocusEvent) => {
109
+ const target = e.target as HTMLInputElement;
110
+
111
+ console.log('onblur Event', target);
112
+ }}
113
+ />
114
+ </Story>
115
+
116
+ <!-- `e: TextInputClipboardEvent` -->
117
+ <Story
118
+ name="Copy"
119
+ args={{
120
+ oncopy: (e: TextInputClipboardEvent) => {
121
+ const target = e.target as HTMLInputElement;
122
+
123
+ console.log('oncopy Event', target);
124
+ },
125
+ }}
126
+ >
127
+ <PasswordInput
128
+ oncopy={(e: TextInputClipboardEvent) => {
129
+ const target = e.target as HTMLInputElement;
130
+
131
+ console.log('oncopy Event', target);
132
+ }}
133
+ />
134
+ </Story>
135
+
136
+ <!-- `e: TextInputClipboardEvent` -->
137
+ <Story
138
+ name="Cut"
139
+ args={{
140
+ oncut: (e: TextInputClipboardEvent) => {
141
+ const target = e.target as HTMLInputElement;
142
+
143
+ console.log('oncut Event', target);
144
+ },
145
+ }}
146
+ >
147
+ <PasswordInput
148
+ oncut={(e: TextInputClipboardEvent) => {
149
+ const target = e.target as HTMLInputElement;
150
+
151
+ console.log('oncut Event', target);
152
+ }}
153
+ />
154
+ </Story>
155
+
156
+ <!-- `e: TextInputClipboardEvent` -->
157
+ <Story
158
+ name="Paste"
159
+ args={{
160
+ onpaste: (e: TextInputClipboardEvent) => {
161
+ const target = e.target as HTMLInputElement;
162
+
163
+ console.log('onpaste Event', target);
164
+ },
165
+ }}
166
+ >
167
+ <PasswordInput
168
+ onpaste={(e: TextInputClipboardEvent) => {
169
+ const target = e.target as HTMLInputElement;
170
+
171
+ console.log('onpaste Event', target);
172
+ }}
173
+ />
174
+ </Story>
@@ -0,0 +1,41 @@
1
+ <script module lang="ts">
2
+ import { defineMeta } from '@storybook/addon-svelte-csf';
3
+ import PasswordInput from './PasswordInput.svelte';
4
+ import type { StoryBookArgTypes } from '$lib/storybook-types.js';
5
+
6
+ export const storyPasswordInputArgTypes: StoryBookArgTypes = {
7
+ roundness: {
8
+ control: { type: 'select' },
9
+ options: [false, '1x', '2x', '3x'],
10
+ },
11
+ size: {
12
+ control: { type: 'select' },
13
+ options: ['normal', 'small', 'large'],
14
+ },
15
+ };
16
+
17
+ // More on how to set up stories at: https://storybook.js.org/docs/writing-stories
18
+ const { Story } = defineMeta({
19
+ component: PasswordInput,
20
+ tags: ['autodocs'],
21
+ argTypes: storyPasswordInputArgTypes,
22
+ args: { value: 'Hello world!' },
23
+ });
24
+ </script>
25
+
26
+ <!-- PasswordInput 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
+ <!-- Disable password toggle -->
38
+ <Story name="No toggle" args={{ passwordToggle: false }} />
39
+
40
+ <!-- Show Password by default -->
41
+ <Story name="Show Password" args={{ defaultPasswordToggleState: true }} />
@@ -0,0 +1,361 @@
1
+ <script lang="ts" module>
2
+ export type PasswordInputToggleEvent = {
3
+ event: Event;
4
+ toggle: boolean;
5
+ };
6
+ </script>
7
+
8
+ <script lang="ts">
9
+ import type { ComponentSize } from '$lib/types.js';
10
+ import type { Snippet } from 'svelte';
11
+ import type {
12
+ ChangeEventHandler,
13
+ ClipboardEventHandler,
14
+ FocusEventHandler,
15
+ FormEventHandler,
16
+ } from 'svelte/elements';
17
+ import type { TextInputFocusEvent, TextInputRoundness } from '../TextInput/TextInput.svelte';
18
+ import Icon from '@iconify/svelte';
19
+
20
+ interface PasswordInputProps {
21
+ /** How large should the button be? */
22
+ size?: ComponentSize;
23
+ /** Toggle Password */
24
+ passwordToggle?: boolean;
25
+ /** Default Password Toggle State */
26
+ defaultPasswordToggleState?: boolean;
27
+ /** Toggle Password Icon */
28
+ passwordToggleIcon?: Snippet;
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
+ /** ontoggle event handler */
66
+ ontoggle?: (e: PasswordInputToggleEvent) => void;
67
+ }
68
+
69
+ let {
70
+ size = 'normal',
71
+ roundness = '1x',
72
+ outline = true,
73
+ name,
74
+ id,
75
+ class: className = '',
76
+ disabled = false,
77
+ oninput,
78
+ onchange,
79
+ onblur,
80
+ onfocus,
81
+ onpaste,
82
+ oncopy,
83
+ oncut,
84
+ before,
85
+ after,
86
+ passwordToggleIcon,
87
+ error = false,
88
+ passwordToggle = true,
89
+ defaultPasswordToggleState = false,
90
+ value = $bindable<string>(),
91
+ placeholder,
92
+ ontoggle,
93
+ }: PasswordInputProps = $props();
94
+
95
+ let focused: boolean = $state(false);
96
+ let toggle: boolean = $state(defaultPasswordToggleState);
97
+
98
+ function onfocusMod(e: TextInputFocusEvent) {
99
+ focused = true;
100
+
101
+ if (onfocus) {
102
+ onfocus(e);
103
+ }
104
+ }
105
+
106
+ function onblurMod(e: TextInputFocusEvent) {
107
+ focused = false;
108
+
109
+ if (onblur) {
110
+ onblur(e);
111
+ }
112
+ }
113
+
114
+ function ontoggleMod(e: Event) {
115
+ toggle = !toggle;
116
+
117
+ const customEvent: PasswordInputToggleEvent = {
118
+ event: e,
119
+ toggle,
120
+ };
121
+
122
+ if (ontoggle) {
123
+ ontoggle(customEvent);
124
+ }
125
+ }
126
+ </script>
127
+
128
+ <div
129
+ class:outline
130
+ class:disabled
131
+ class:error
132
+ class:focused
133
+ class:toggle
134
+ class={['dodo-ui-PasswordInput', `size--${size}`, `roundness--${roundness}`, className].join(' ')}
135
+ >
136
+ {#if before}
137
+ <span class="content--before">
138
+ {@render before()}
139
+ </span>
140
+ {/if}
141
+ <input
142
+ type={passwordToggle && toggle ? 'text' : 'password'}
143
+ {name}
144
+ {id}
145
+ {disabled}
146
+ {oninput}
147
+ {onchange}
148
+ onfocus={onfocusMod}
149
+ onblur={onblurMod}
150
+ {onpaste}
151
+ {oncopy}
152
+ {oncut}
153
+ {placeholder}
154
+ bind:value
155
+ />
156
+
157
+ {#if passwordToggle && !disabled}
158
+ <button class="passwordToggle" title="Toggle password" onclick={ontoggleMod} class:toggle>
159
+ {#if passwordToggleIcon}
160
+ {@render passwordToggleIcon()}
161
+ {:else if toggle}
162
+ <Icon icon="mdi:eye-off" width="24" height="24" />
163
+ {:else}
164
+ <Icon icon="mdi:eye" width="24" height="24" />
165
+ {/if}
166
+ </button>
167
+ {/if}
168
+
169
+ {#if after}
170
+ <span class="content--after">
171
+ {@render after()}
172
+ </span>
173
+ {/if}
174
+ </div>
175
+
176
+ <style lang="scss">
177
+ :global(:root) {
178
+ --dodo-ui-PasswordInput-border-color: var(--dodo-color-default-500);
179
+ --dodo-ui-PasswordInput-focus-border-color: var(--dodo-color-primary-500);
180
+ --dodo-ui-PasswordInput-error-border-color: var(--dodo-color-danger-500);
181
+
182
+ --dodo-ui-PasswordInput-disabled-color: var(--dodo-color-default-400);
183
+ --dodo-ui-PasswordInput-disabled-bg: var(--dodo-color-default-200);
184
+
185
+ --dodo-ui-PasswordInput-ToggleButton-hover: var(--dodo-color-primary-700);
186
+ }
187
+
188
+ :global(.dodo-theme--dark) {
189
+ --dodo-ui-PasswordInput-border-color: var(--dodo-color-default-600);
190
+ --dodo-ui-PasswordInput-focus-border-color: var(--dodo-color-primary-600);
191
+ --dodo-ui-PasswordInput-error-border-color: var(--dodo-color-danger-600);
192
+
193
+ --dodo-ui-PasswordInput-disabled-bg: var(--dodo-color-default-100);
194
+ --dodo-ui-PasswordInput-disabled-color: var(--dodo-color-default-500);
195
+
196
+ --dodo-ui-PasswordInput-ToggleButton-hover: var(--dodo-color-primary-600);
197
+ }
198
+
199
+ .dodo-ui-PasswordInput {
200
+ display: flex;
201
+ overflow: hidden;
202
+ color: var(--dodo-color-default-800);
203
+ transition: all 150ms;
204
+ border: 0;
205
+
206
+ input {
207
+ flex: 1;
208
+ border: 0;
209
+ outline: 0;
210
+ height: 100%;
211
+ background-color: transparent;
212
+ font-family: inherit;
213
+ color: inherit;
214
+ letter-spacing: 0.3px;
215
+ }
216
+
217
+ &.outline {
218
+ border-style: solid;
219
+ border-width: var(--dodo-ui-element-border-width);
220
+ border-color: var(--dodo-ui-PasswordInput-border-color);
221
+ }
222
+
223
+ &.focused {
224
+ border-color: var(--dodo-ui-PasswordInput-focus-border-color);
225
+ }
226
+
227
+ &.error {
228
+ border-color: var(--dodo-ui-PasswordInput-error-border-color);
229
+ }
230
+
231
+ &.disabled {
232
+ cursor: initial;
233
+ background-color: var(--dodo-ui-PasswordInput-disabled-bg);
234
+ color: var(--dodo-ui-PasswordInput-disabled-color);
235
+ border-color: var(--dodo-ui-PasswordInput-disabled-bg);
236
+ }
237
+
238
+ .content {
239
+ &--after,
240
+ &--before {
241
+ &:empty {
242
+ display: none;
243
+ }
244
+ }
245
+
246
+ &--after,
247
+ &--before {
248
+ display: inline-flex;
249
+ height: 100%;
250
+ align-items: center;
251
+ }
252
+ }
253
+
254
+ &.size {
255
+ &--normal {
256
+ height: var(--dodo-ui-element-height-normal);
257
+ input {
258
+ font-size: 1rem;
259
+ padding: 0 12px;
260
+ }
261
+
262
+ .content {
263
+ &--before {
264
+ margin-left: 12px;
265
+ margin-right: -4px;
266
+ }
267
+
268
+ &--after {
269
+ margin-right: 12px;
270
+ margin-left: -4px;
271
+ }
272
+ }
273
+
274
+ .passwordToggle {
275
+ width: var(--dodo-ui-element-height-normal);
276
+ }
277
+ }
278
+
279
+ &--small {
280
+ height: var(--dodo-ui-element-height-small);
281
+ input {
282
+ padding: 0 8px;
283
+ font-size: 0.9rem;
284
+ }
285
+
286
+ .content {
287
+ &--before {
288
+ margin-left: 8px;
289
+ margin-right: -2px;
290
+ }
291
+
292
+ &--after {
293
+ margin-right: 8px;
294
+ margin-left: -2px;
295
+ }
296
+ }
297
+
298
+ .passwordToggle {
299
+ width: var(--dodo-ui-element-height-small);
300
+ }
301
+ }
302
+
303
+ &--large {
304
+ height: var(--dodo-ui-element-height-large);
305
+ input {
306
+ font-size: 1.1rem;
307
+ padding: 0 14px;
308
+ }
309
+
310
+ .content {
311
+ &--before {
312
+ margin-left: 14px;
313
+ margin-right: -4px;
314
+ }
315
+
316
+ &--after {
317
+ margin-right: 14px;
318
+ margin-left: -4px;
319
+ }
320
+ }
321
+
322
+ .passwordToggle {
323
+ width: var(--dodo-ui-element-height-large);
324
+ }
325
+ }
326
+ }
327
+
328
+ &.roundness {
329
+ &--1x {
330
+ border-radius: var(--dodo-ui-element-roundness-1x);
331
+ }
332
+
333
+ &--2x {
334
+ border-radius: var(--dodo-ui-element-roundness-2x);
335
+ }
336
+
337
+ &--3x {
338
+ border-radius: var(--dodo-ui-element-roundness-3x);
339
+ }
340
+ }
341
+
342
+ .passwordToggle {
343
+ background-color: transparent;
344
+ outline: 0;
345
+ border: 0;
346
+ display: inline-flex;
347
+ justify-content: center;
348
+ align-items: center;
349
+ height: 100%;
350
+ cursor: pointer;
351
+ padding: 0;
352
+ margin-right: 4px;
353
+ color: var(--dodo-color-default-700);
354
+ transition: all 150ms;
355
+
356
+ &:hover {
357
+ color: var(--dodo-ui-PasswordInput-ToggleButton-hover);
358
+ }
359
+ }
360
+ }
361
+ </style>
@@ -0,0 +1,20 @@
1
+ <script module>
2
+ import { defineMeta } from '@storybook/addon-svelte-csf';
3
+ import PasswordInput from '../PasswordInput.svelte';
4
+ import { storyPasswordInputArgTypes } from '../PasswordInput.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: PasswordInput,
9
+ tags: ['autodocs'],
10
+ argTypes: storyPasswordInputArgTypes,
11
+ });
12
+ </script>
13
+
14
+ <Story name="Roundness 1x" />
15
+
16
+ <Story name="Roundness 2x" args={{ roundness: '2x' }} />
17
+
18
+ <Story name="Roundness 3x" args={{ roundness: '3x' }} />
19
+
20
+ <Story name="Roundness False" args={{ roundness: false }} />
@@ -0,0 +1,16 @@
1
+ <script module>
2
+ import { defineMeta } from '@storybook/addon-svelte-csf';
3
+ import PasswordInput from '../PasswordInput.svelte';
4
+ import { storyPasswordInputArgTypes } from '../PasswordInput.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: PasswordInput,
9
+ tags: ['autodocs'],
10
+ argTypes: storyPasswordInputArgTypes,
11
+ });
12
+ </script>
13
+
14
+ <Story name="Normal" />
15
+ <Story name="Small" args={{ size: 'small' }} />
16
+ <Story name="Large" args={{ size: 'large' }} />