@finsweet/webflow-apps-utils 1.0.8 → 1.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/types/customCode.d.ts +1 -1
- package/dist/ui/components/Loader.svelte +0 -2
- package/dist/ui/components/LoadingScreen.svelte +6 -2
- package/dist/ui/components/LoadingScreen.svelte.d.ts +1 -0
- package/dist/ui/components/breakpoints/BreakpointItem.svelte +2 -2
- package/dist/ui/components/button/Button.stories.svelte +0 -8
- package/dist/ui/components/button/Button.svelte +68 -76
- package/dist/ui/components/button/index.d.ts +1 -1
- package/dist/ui/components/button/index.js +1 -0
- package/dist/ui/components/color-picker/ColorPicker.stories.svelte +42 -0
- package/dist/ui/components/color-picker/ColorPicker.stories.svelte.d.ts +19 -0
- package/dist/ui/components/color-picker/ColorPicker.svelte +155 -0
- package/dist/ui/components/color-picker/ColorPicker.svelte.d.ts +8 -0
- package/dist/ui/components/color-picker/ColorSelect.stories.svelte +61 -0
- package/dist/ui/components/color-picker/ColorSelect.stories.svelte.d.ts +27 -0
- package/dist/ui/components/color-picker/ColorSelect.svelte +940 -0
- package/dist/ui/components/color-picker/ColorSelect.svelte.d.ts +7 -0
- package/dist/ui/components/color-picker/index.d.ts +1 -0
- package/dist/ui/components/color-picker/index.js +1 -0
- package/dist/ui/components/controlled-buttons/ControlledButtons.svelte +17 -7
- package/dist/ui/components/copy-text/CopyText.svelte +48 -39
- package/dist/ui/components/divider/Divider.stories.svelte +0 -4
- package/dist/ui/components/input/index.d.ts +1 -1
- package/dist/ui/components/input/index.js +1 -0
- package/dist/ui/components/layout/Layout.svelte +0 -5
- package/dist/ui/components/layout/examples/ExampleLayout.svelte +9 -8
- package/dist/ui/components/modal/Example.svelte +0 -7
- package/dist/ui/components/modal/Modal.stories.svelte +0 -2
- package/dist/ui/components/modal/Modal.svelte +1 -1
- package/dist/ui/components/notification/Notification.stories.svelte +0 -8
- package/dist/ui/components/notification/Notification.svelte +2 -2
- package/dist/ui/components/section/Section.stories.svelte +0 -1
- package/dist/ui/components/text/README.md +0 -2
- package/dist/ui/components/text/Text.stories.svelte +0 -6
- package/dist/ui/components/text/Text.svelte +0 -19
- package/dist/ui/components/tooltip/Tooltip.svelte +9 -5
- package/dist/ui/icons/FinsweetLogoOutlineIcon.svelte +17 -0
- package/dist/ui/icons/FinsweetLogoOutlineIcon.svelte.d.ts +26 -0
- package/dist/ui/icons/TriangleDownIconToggle.svelte +0 -1
- package/dist/ui/icons/index.d.ts +2 -1
- package/dist/ui/icons/index.js +2 -1
- package/dist/ui/index.css +1 -1
- package/dist/ui/providers/GlobalProviderDemo.svelte +0 -2
- package/dist/ui/router/Router.stories.js +7 -7
- package/dist/ui/router/examples/RouterExample.svelte +0 -9
- package/dist/ui/router/examples/pages/AboutPage.svelte +0 -4
- package/dist/ui/router/providers/Link.svelte +0 -2
- package/dist/ui/router/providers/Route.svelte +0 -3
- package/dist/ui/stores/form.d.ts +136 -3
- package/dist/ui/stores/form.js +310 -2
- package/package.json +1 -1
|
@@ -16,7 +16,6 @@
|
|
|
16
16
|
|
|
17
17
|
<div class="wrapper" style={`margin: ${margin};`}>
|
|
18
18
|
<svg class="loader-svg" width={size} height={size} viewBox={`0 0 ${size} ${size}`}>
|
|
19
|
-
<!-- Background track circle with opacity -->
|
|
20
19
|
<circle
|
|
21
20
|
cx={center}
|
|
22
21
|
cy={center}
|
|
@@ -27,7 +26,6 @@
|
|
|
27
26
|
opacity="0.2"
|
|
28
27
|
/>
|
|
29
28
|
|
|
30
|
-
<!-- Animated quarter arc -->
|
|
31
29
|
<circle
|
|
32
30
|
cx={center}
|
|
33
31
|
cy={center}
|
|
@@ -10,10 +10,14 @@
|
|
|
10
10
|
export let raw = false;
|
|
11
11
|
export let backgroundColor = 'rgba(30, 30, 30, 0.96)';
|
|
12
12
|
export let spinnerSize = 50;
|
|
13
|
+
export let className: string = '';
|
|
13
14
|
</script>
|
|
14
15
|
|
|
15
16
|
{#if active}
|
|
16
|
-
<div
|
|
17
|
+
<div
|
|
18
|
+
class="main-loader {className}"
|
|
19
|
+
style="position:{position}; background-color: {backgroundColor};"
|
|
20
|
+
>
|
|
17
21
|
<div class="loading-info {error ? 'error' : ''}">
|
|
18
22
|
{#if error}
|
|
19
23
|
<WarningTriangleOutlineIcon />
|
|
@@ -32,7 +36,7 @@
|
|
|
32
36
|
{/if}
|
|
33
37
|
|
|
34
38
|
<style>
|
|
35
|
-
.
|
|
39
|
+
.main-loader {
|
|
36
40
|
top: 0;
|
|
37
41
|
bottom: 0;
|
|
38
42
|
left: 0;
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
<Switch {disabled} bind:checked={enabled} onchange={handleSwitchChange} />
|
|
32
32
|
</div>
|
|
33
33
|
|
|
34
|
-
<div class="content" style="display: {enabled ? 'flex' : 'none'}">
|
|
34
|
+
<div class="breakpoint-content" style="display: {enabled ? 'flex' : 'none'}">
|
|
35
35
|
<slot />
|
|
36
36
|
</div>
|
|
37
37
|
</div>
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
gap: var(--Spacing-8, 8px);
|
|
47
47
|
align-self: stretch;
|
|
48
48
|
}
|
|
49
|
-
.content {
|
|
49
|
+
.breakpoint-content {
|
|
50
50
|
display: flex;
|
|
51
51
|
flex-direction: column;
|
|
52
52
|
align-items: flex-start;
|
|
@@ -56,7 +56,6 @@
|
|
|
56
56
|
});
|
|
57
57
|
</script>
|
|
58
58
|
|
|
59
|
-
<!-- Basic Variants -->
|
|
60
59
|
<Story
|
|
61
60
|
name="Primary"
|
|
62
61
|
args={{
|
|
@@ -89,7 +88,6 @@
|
|
|
89
88
|
}}
|
|
90
89
|
/>
|
|
91
90
|
|
|
92
|
-
<!-- States -->
|
|
93
91
|
<Story
|
|
94
92
|
name="Loading"
|
|
95
93
|
args={{
|
|
@@ -107,7 +105,6 @@
|
|
|
107
105
|
}}
|
|
108
106
|
/>
|
|
109
107
|
|
|
110
|
-
<!-- Full Width -->
|
|
111
108
|
<Story
|
|
112
109
|
name="Full Width"
|
|
113
110
|
args={{
|
|
@@ -116,7 +113,6 @@
|
|
|
116
113
|
}}
|
|
117
114
|
/>
|
|
118
115
|
|
|
119
|
-
<!-- With Icons using Component Props -->
|
|
120
116
|
<Story
|
|
121
117
|
name="With Icon Left"
|
|
122
118
|
args={{
|
|
@@ -141,7 +137,6 @@
|
|
|
141
137
|
}}
|
|
142
138
|
/>
|
|
143
139
|
|
|
144
|
-
<!-- Common Use Cases -->
|
|
145
140
|
<Story
|
|
146
141
|
name="Play Button"
|
|
147
142
|
args={{
|
|
@@ -188,7 +183,6 @@
|
|
|
188
183
|
}}
|
|
189
184
|
/>
|
|
190
185
|
|
|
191
|
-
<!-- Loading States with Icons -->
|
|
192
186
|
<Story
|
|
193
187
|
name="Loading with Icon"
|
|
194
188
|
args={{
|
|
@@ -200,7 +194,6 @@
|
|
|
200
194
|
}}
|
|
201
195
|
/>
|
|
202
196
|
|
|
203
|
-
<!-- Invalid State (Disabled with Tooltip) -->
|
|
204
197
|
<Story
|
|
205
198
|
name="Invalid State"
|
|
206
199
|
args={{
|
|
@@ -216,7 +209,6 @@
|
|
|
216
209
|
}}
|
|
217
210
|
/>
|
|
218
211
|
|
|
219
|
-
<!-- Tooltip Examples -->
|
|
220
212
|
<Story
|
|
221
213
|
name="Basic Tooltip"
|
|
222
214
|
args={{
|
|
@@ -163,45 +163,41 @@
|
|
|
163
163
|
>
|
|
164
164
|
{#if children}
|
|
165
165
|
{@render children()}
|
|
166
|
+
{:else if loading}
|
|
167
|
+
<div class="button__content">
|
|
168
|
+
<Loader size={parseInt(computedIconSize)} color="currentColor" />
|
|
169
|
+
{#if currentText}
|
|
170
|
+
<span class="button__text">{currentText}</span>
|
|
171
|
+
{/if}
|
|
172
|
+
</div>
|
|
166
173
|
{:else}
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
<
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
<div
|
|
195
|
-
class="button__icon button__icon--right"
|
|
196
|
-
style:color={iconColor}
|
|
197
|
-
style:width={computedIconSize}
|
|
198
|
-
style:height={computedIconSize}
|
|
199
|
-
>
|
|
200
|
-
<RightIcon />
|
|
201
|
-
</div>
|
|
202
|
-
{/if}
|
|
203
|
-
</div>
|
|
204
|
-
{/if}
|
|
174
|
+
<div class="button__content">
|
|
175
|
+
{#if hasLeftIcon}
|
|
176
|
+
<div
|
|
177
|
+
class="button__icon button__icon--left"
|
|
178
|
+
style:color={iconColor}
|
|
179
|
+
style:width={computedIconSize}
|
|
180
|
+
style:height={computedIconSize}
|
|
181
|
+
>
|
|
182
|
+
<LeftIcon />
|
|
183
|
+
</div>
|
|
184
|
+
{/if}
|
|
185
|
+
|
|
186
|
+
{#if hasText}
|
|
187
|
+
<span class="button__text">{currentText}</span>
|
|
188
|
+
{/if}
|
|
189
|
+
|
|
190
|
+
{#if hasRightIcon}
|
|
191
|
+
<div
|
|
192
|
+
class="button__icon button__icon--right"
|
|
193
|
+
style:color={iconColor}
|
|
194
|
+
style:width={computedIconSize}
|
|
195
|
+
style:height={computedIconSize}
|
|
196
|
+
>
|
|
197
|
+
<RightIcon />
|
|
198
|
+
</div>
|
|
199
|
+
{/if}
|
|
200
|
+
</div>
|
|
205
201
|
{/if}
|
|
206
202
|
</button>
|
|
207
203
|
{/snippet}
|
|
@@ -220,45 +216,41 @@
|
|
|
220
216
|
>
|
|
221
217
|
{#if children}
|
|
222
218
|
{@render children()}
|
|
219
|
+
{:else if loading}
|
|
220
|
+
<div class="button__content">
|
|
221
|
+
<Loader size={parseInt(computedIconSize)} color="currentColor" />
|
|
222
|
+
{#if currentText}
|
|
223
|
+
<span class="button__text">{currentText}</span>
|
|
224
|
+
{/if}
|
|
225
|
+
</div>
|
|
223
226
|
{:else}
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
<
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
<div
|
|
252
|
-
class="button__icon button__icon--right"
|
|
253
|
-
style:color={iconColor}
|
|
254
|
-
style:width={computedIconSize}
|
|
255
|
-
style:height={computedIconSize}
|
|
256
|
-
>
|
|
257
|
-
<RightIcon />
|
|
258
|
-
</div>
|
|
259
|
-
{/if}
|
|
260
|
-
</div>
|
|
261
|
-
{/if}
|
|
227
|
+
<div class="button__content">
|
|
228
|
+
{#if hasLeftIcon}
|
|
229
|
+
<div
|
|
230
|
+
class="button__icon button__icon--left"
|
|
231
|
+
style:color={iconColor}
|
|
232
|
+
style:width={computedIconSize}
|
|
233
|
+
style:height={computedIconSize}
|
|
234
|
+
>
|
|
235
|
+
<LeftIcon />
|
|
236
|
+
</div>
|
|
237
|
+
{/if}
|
|
238
|
+
|
|
239
|
+
{#if hasText}
|
|
240
|
+
<span class="button__text">{currentText}</span>
|
|
241
|
+
{/if}
|
|
242
|
+
|
|
243
|
+
{#if hasRightIcon}
|
|
244
|
+
<div
|
|
245
|
+
class="button__icon button__icon--right"
|
|
246
|
+
style:color={iconColor}
|
|
247
|
+
style:width={computedIconSize}
|
|
248
|
+
style:height={computedIconSize}
|
|
249
|
+
>
|
|
250
|
+
<RightIcon />
|
|
251
|
+
</div>
|
|
252
|
+
{/if}
|
|
253
|
+
</div>
|
|
262
254
|
{/if}
|
|
263
255
|
</button>
|
|
264
256
|
{/if}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { default as Button } from './Button.svelte';
|
|
2
|
-
export
|
|
2
|
+
export * from './types.js';
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
+
import { fn } from 'storybook/test';
|
|
4
|
+
|
|
5
|
+
import ColorPicker from './ColorPicker.svelte';
|
|
6
|
+
|
|
7
|
+
let controlledColor = $state('#00ff00');
|
|
8
|
+
const handleChange = (color: string) => (controlledColor = color);
|
|
9
|
+
|
|
10
|
+
const { Story } = defineMeta({
|
|
11
|
+
title: 'UI/ColorPicker',
|
|
12
|
+
component: ColorPicker,
|
|
13
|
+
tags: ['autodocs'],
|
|
14
|
+
argTypes: {
|
|
15
|
+
color: {
|
|
16
|
+
control: { type: 'color' },
|
|
17
|
+
description: 'Selected color (hex string or writable store)'
|
|
18
|
+
},
|
|
19
|
+
onchange: { action: 'colorChanged' }
|
|
20
|
+
},
|
|
21
|
+
parameters: {
|
|
22
|
+
layout: 'centered',
|
|
23
|
+
viewport: {
|
|
24
|
+
defaultViewport: 'responsive'
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
args: {
|
|
28
|
+
color: '#ff0000',
|
|
29
|
+
onchange: fn()
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
</script>
|
|
33
|
+
|
|
34
|
+
<Story name="Default" args={{}} />
|
|
35
|
+
|
|
36
|
+
<Story name="With Initial Color" args={{ color: '#00ff00' }} />
|
|
37
|
+
|
|
38
|
+
<Story name="Store Controlled" args={{ color: controlledColor, onchange: handleChange }} />
|
|
39
|
+
|
|
40
|
+
<Story name="Edge: Invalid Color" args={{ color: '#xyzxyz' }} />
|
|
41
|
+
|
|
42
|
+
<Story name="Edge: No Color" args={{ color: undefined }} />
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import ColorPicker from './ColorPicker.svelte';
|
|
2
|
+
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> {
|
|
3
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
4
|
+
$$bindings?: Bindings;
|
|
5
|
+
} & Exports;
|
|
6
|
+
(internal: unknown, props: {
|
|
7
|
+
$$events?: Events;
|
|
8
|
+
$$slots?: Slots;
|
|
9
|
+
}): Exports & {
|
|
10
|
+
$set?: any;
|
|
11
|
+
$on?: any;
|
|
12
|
+
};
|
|
13
|
+
z_$$bindings?: Bindings;
|
|
14
|
+
}
|
|
15
|
+
declare const ColorPicker: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
|
|
16
|
+
[evt: string]: CustomEvent<any>;
|
|
17
|
+
}, {}, {}, string>;
|
|
18
|
+
type ColorPicker = InstanceType<typeof ColorPicker>;
|
|
19
|
+
export default ColorPicker;
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import Tooltip from '../tooltip/Tooltip.svelte';
|
|
3
|
+
import ColorSelect from './ColorSelect.svelte';
|
|
4
|
+
|
|
5
|
+
let {
|
|
6
|
+
color = $bindable('#fff'),
|
|
7
|
+
onchange,
|
|
8
|
+
width = '80px'
|
|
9
|
+
} = $props<{
|
|
10
|
+
color?: string;
|
|
11
|
+
onchange?: (color: string) => void;
|
|
12
|
+
width?: string;
|
|
13
|
+
}>();
|
|
14
|
+
|
|
15
|
+
function normalizeHex(value: string): string {
|
|
16
|
+
let v = value.trim();
|
|
17
|
+
|
|
18
|
+
if (!v.startsWith('#')) v = `#${v}`;
|
|
19
|
+
|
|
20
|
+
return v.toUpperCase();
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function isValidColor(value: string): boolean {
|
|
24
|
+
const hexRegex = /^#?([A-Fa-f0-9]{3}|[A-Fa-f0-9]{6}|[A-Fa-f0-9]{8})$/;
|
|
25
|
+
return hexRegex.test(value.startsWith('#') ? value.slice(1) : value);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function handleInputPaste(event: ClipboardEvent) {
|
|
29
|
+
event.preventDefault();
|
|
30
|
+
|
|
31
|
+
const pastedText = event.clipboardData?.getData('text') || '';
|
|
32
|
+
let cleanText = pastedText.replace(/[^0-9A-Fa-f#]/g, '');
|
|
33
|
+
if (!cleanText.startsWith('#')) cleanText = '#' + cleanText;
|
|
34
|
+
|
|
35
|
+
cleanText = cleanText.substring(0, 9);
|
|
36
|
+
|
|
37
|
+
if (isValidColor(cleanText)) {
|
|
38
|
+
const normalizedValue = normalizeHex(cleanText);
|
|
39
|
+
color = normalizedValue;
|
|
40
|
+
onchange?.(normalizedValue);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function handleInputChange(event: Event) {
|
|
45
|
+
const target = event.target as HTMLInputElement;
|
|
46
|
+
const value = target.value.trim();
|
|
47
|
+
|
|
48
|
+
if (isValidColor(value)) {
|
|
49
|
+
const normalizedValue = normalizeHex(value);
|
|
50
|
+
|
|
51
|
+
color = normalizedValue;
|
|
52
|
+
|
|
53
|
+
onchange?.(normalizedValue);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function handleInputKeydown(event: KeyboardEvent) {
|
|
58
|
+
if (event.key === 'Enter') {
|
|
59
|
+
(event.target as HTMLInputElement).blur();
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function handleColorChange(newColor: string) {
|
|
64
|
+
const normalizedValue = normalizeHex(newColor);
|
|
65
|
+
|
|
66
|
+
color = normalizedValue;
|
|
67
|
+
onchange?.(normalizedValue);
|
|
68
|
+
}
|
|
69
|
+
</script>
|
|
70
|
+
|
|
71
|
+
<div class="color-picker">
|
|
72
|
+
<Tooltip
|
|
73
|
+
listener="click"
|
|
74
|
+
listenerout="click"
|
|
75
|
+
showArrow={false}
|
|
76
|
+
padding="0"
|
|
77
|
+
stopPropagation={true}
|
|
78
|
+
width="241px"
|
|
79
|
+
placement="bottom"
|
|
80
|
+
fallbackPlacements={['top-end', 'top', 'bottom-end', 'bottom', 'top-start', 'bottom-start']}
|
|
81
|
+
>
|
|
82
|
+
{#snippet target()}
|
|
83
|
+
<div class="color-picker__swatch" data-testid="color-swatch">
|
|
84
|
+
<div class="color-swatch" style="background-color: {color || '#000000'}"></div>
|
|
85
|
+
</div>
|
|
86
|
+
{/snippet}
|
|
87
|
+
{#snippet tooltipContent()}
|
|
88
|
+
<ColorSelect {color} onchange={handleColorChange} />
|
|
89
|
+
{/snippet}
|
|
90
|
+
</Tooltip>
|
|
91
|
+
|
|
92
|
+
<input
|
|
93
|
+
type="text"
|
|
94
|
+
class="color-picker__input"
|
|
95
|
+
bind:value={color}
|
|
96
|
+
oninput={handleInputChange}
|
|
97
|
+
onkeydown={handleInputKeydown}
|
|
98
|
+
onpaste={handleInputPaste}
|
|
99
|
+
placeholder="#ffffff"
|
|
100
|
+
aria-label="Color hex value"
|
|
101
|
+
style="width: {width}"
|
|
102
|
+
/>
|
|
103
|
+
</div>
|
|
104
|
+
|
|
105
|
+
<style>
|
|
106
|
+
.color-picker {
|
|
107
|
+
display: flex;
|
|
108
|
+
align-items: center;
|
|
109
|
+
gap: 4px;
|
|
110
|
+
height: 24px;
|
|
111
|
+
border: 1px solid var(--border1);
|
|
112
|
+
border-radius: 4px;
|
|
113
|
+
overflow: hidden;
|
|
114
|
+
background: var(--background1);
|
|
115
|
+
box-shadow:
|
|
116
|
+
0px 16px 16px -16px rgba(0, 0, 0, 0.13) inset,
|
|
117
|
+
0px 12px 12px -12px rgba(0, 0, 0, 0.13) inset,
|
|
118
|
+
0px 8px 8px -8px rgba(0, 0, 0, 0.17) inset,
|
|
119
|
+
0px 4px 4px -4px rgba(0, 0, 0, 0.17) inset,
|
|
120
|
+
0px 3px 3px -3px rgba(0, 0, 0, 0.17) inset,
|
|
121
|
+
0px 1px 1px -1px rgba(0, 0, 0, 0.13) inset;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
.color-picker__swatch {
|
|
125
|
+
position: relative;
|
|
126
|
+
width: 24px;
|
|
127
|
+
height: 24px;
|
|
128
|
+
overflow: hidden;
|
|
129
|
+
cursor: pointer;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
.color-swatch {
|
|
133
|
+
width: 100%;
|
|
134
|
+
height: 100%;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
.color-picker__input {
|
|
138
|
+
width: 80px;
|
|
139
|
+
padding: 4px 8px 4px 0px;
|
|
140
|
+
border-radius: 4px;
|
|
141
|
+
font-family: monospace;
|
|
142
|
+
font-size: 12px;
|
|
143
|
+
border: none;
|
|
144
|
+
background: transparent;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
.color-picker:has(.color-picker__input:focus) {
|
|
148
|
+
outline: none;
|
|
149
|
+
border-color: var(--blueBorder);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
.color-picker:global(:has(.tooltip[aria-hidden='false'])) {
|
|
153
|
+
border-color: var(--blueBorder);
|
|
154
|
+
}
|
|
155
|
+
</style>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
type $$ComponentProps = {
|
|
2
|
+
color?: string;
|
|
3
|
+
onchange?: (color: string) => void;
|
|
4
|
+
width?: string;
|
|
5
|
+
};
|
|
6
|
+
declare const ColorPicker: import("svelte").Component<$$ComponentProps, {}, "color">;
|
|
7
|
+
type ColorPicker = ReturnType<typeof ColorPicker>;
|
|
8
|
+
export default ColorPicker;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
<script module>
|
|
2
|
+
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
+
import { fn } from 'storybook/test';
|
|
4
|
+
|
|
5
|
+
import ColorSelect from './ColorSelect.svelte';
|
|
6
|
+
|
|
7
|
+
const { Story } = defineMeta({
|
|
8
|
+
title: 'UI/ColorSelect',
|
|
9
|
+
component: ColorSelect,
|
|
10
|
+
tags: ['autodocs'],
|
|
11
|
+
argTypes: {
|
|
12
|
+
color: {
|
|
13
|
+
control: { type: 'color' },
|
|
14
|
+
description: 'Initial color value (hex)'
|
|
15
|
+
},
|
|
16
|
+
onchange: { action: 'colorChanged' }
|
|
17
|
+
},
|
|
18
|
+
args: {
|
|
19
|
+
color: '#ff0000',
|
|
20
|
+
onchange: fn()
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
</script>
|
|
24
|
+
|
|
25
|
+
<Story name="Default" args={{}} />
|
|
26
|
+
|
|
27
|
+
<Story name="With Initial Color" args={{ color: '#00ff00' }} />
|
|
28
|
+
|
|
29
|
+
<Story
|
|
30
|
+
name="Alpha Channel"
|
|
31
|
+
args={{ color: '#0000ff' }}
|
|
32
|
+
story={{
|
|
33
|
+
parameters: {
|
|
34
|
+
docs: { description: { story: 'Shows alpha slider and allows changing opacity.' } }
|
|
35
|
+
}
|
|
36
|
+
}}
|
|
37
|
+
/>
|
|
38
|
+
|
|
39
|
+
<Story
|
|
40
|
+
name="HSB/RGB Toggle"
|
|
41
|
+
args={{ color: '#ff00ff' }}
|
|
42
|
+
story={{
|
|
43
|
+
parameters: {
|
|
44
|
+
docs: { description: { story: 'Toggle between HSB and RGB modes using the mode switch.' } }
|
|
45
|
+
}
|
|
46
|
+
}}
|
|
47
|
+
/>
|
|
48
|
+
|
|
49
|
+
<Story
|
|
50
|
+
name="With EyeDropper"
|
|
51
|
+
args={{ color: '#123456' }}
|
|
52
|
+
story={{
|
|
53
|
+
parameters: {
|
|
54
|
+
docs: {
|
|
55
|
+
description: {
|
|
56
|
+
story: 'Use the EyeDropper button to pick a color from the screen (if supported).'
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}}
|
|
61
|
+
/>
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export default ColorSelect;
|
|
2
|
+
type ColorSelect = SvelteComponent<{
|
|
3
|
+
[x: string]: never;
|
|
4
|
+
}, {
|
|
5
|
+
[evt: string]: CustomEvent<any>;
|
|
6
|
+
}, {}> & {
|
|
7
|
+
$$bindings?: string | undefined;
|
|
8
|
+
};
|
|
9
|
+
declare const ColorSelect: $$__sveltets_2_IsomorphicComponent<{
|
|
10
|
+
[x: string]: never;
|
|
11
|
+
}, {
|
|
12
|
+
[evt: string]: CustomEvent<any>;
|
|
13
|
+
}, {}, {}, string>;
|
|
14
|
+
import ColorSelect from './ColorSelect.svelte';
|
|
15
|
+
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> {
|
|
16
|
+
new (options: import("svelte").ComponentConstructorOptions<Props>): import("svelte").SvelteComponent<Props, Events, Slots> & {
|
|
17
|
+
$$bindings?: Bindings;
|
|
18
|
+
} & Exports;
|
|
19
|
+
(internal: unknown, props: {
|
|
20
|
+
$$events?: Events;
|
|
21
|
+
$$slots?: Slots;
|
|
22
|
+
}): Exports & {
|
|
23
|
+
$set?: any;
|
|
24
|
+
$on?: any;
|
|
25
|
+
};
|
|
26
|
+
z_$$bindings?: Bindings;
|
|
27
|
+
}
|