@x33025/sveltely 0.1.18 → 0.1.21
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/actions/LoaderOverlay.svelte +33 -8
- package/dist/actions/LoaderOverlay.svelte.d.ts +3 -0
- package/dist/actions/loader.d.ts +3 -0
- package/dist/actions/loader.js +20 -7
- package/dist/components/Library/AnimatedNumber/AnimatedNumber.demo.svelte +3 -9
- package/dist/components/Library/ArticleEditor/ArticleEditor.svelte +1 -1
- package/dist/components/Library/ArticleEditor/ArticleEditorHeader.svelte +20 -30
- package/dist/components/Library/ArticleEditor/Blocks/Code.svelte +0 -1
- package/dist/components/Library/ArticleEditor/Blocks/FAQ.svelte +1 -1
- package/dist/components/Library/ArticleEditor/Blocks/Heading.svelte +7 -7
- package/dist/components/Library/ArticleEditor/Blocks/Image.svelte +20 -36
- package/dist/components/Library/ArticleEditor/Blocks/Image.svelte.d.ts +1 -0
- package/dist/components/Library/ArticleEditor/Blocks/List.svelte +2 -2
- package/dist/components/Library/ArticleEditor/Blocks/Paragraph.svelte +1 -1
- package/dist/components/Library/ArticleEditor/Blocks/index.d.ts +0 -1
- package/dist/components/Library/ArticleEditor/Blocks/index.js +0 -1
- package/dist/components/Library/AsyncButton/AsyncButton.demo.svelte +2 -6
- package/dist/components/Library/AsyncButton/AsyncButton.svelte +9 -5
- package/dist/components/Library/AsyncButton/AsyncButton.svelte.d.ts +2 -1
- package/dist/components/Library/Button/Button.demo.svelte +2 -17
- package/dist/components/Library/Button/Button.demo.svelte.d.ts +0 -1
- package/dist/components/Library/Button/Button.svelte +15 -16
- package/dist/components/Library/Button/Button.svelte.d.ts +2 -1
- package/dist/components/Library/Calendar/Calendar.svelte +17 -27
- package/dist/components/Library/Checkbox/Checkbox.demo.svelte +7 -4
- package/dist/components/Library/Checkbox/Checkbox.svelte +24 -61
- package/dist/components/Library/Checkbox/Checkbox.svelte.d.ts +2 -4
- package/dist/components/Library/ChipInput/ChipInput.demo.svelte +2 -2
- package/dist/components/Library/ChipInput/ChipInput.svelte +7 -11
- package/dist/components/Library/ChipInput/ChipInput.svelte.d.ts +3 -2
- package/dist/components/Library/Dropdown/Action.svelte +1 -1
- package/dist/components/Library/Dropdown/Dropdown.demo.svelte +10 -10
- package/dist/components/Library/Dropdown/Dropdown.svelte +2 -6
- package/dist/components/Library/Dropdown/Item.svelte +2 -2
- package/dist/components/Library/Dropdown/Section.svelte +1 -1
- package/dist/components/Library/Dropdown/Trigger.svelte +3 -7
- package/dist/components/Library/Image/Image.demo.svelte +3 -3
- package/dist/components/Library/Image/Image.svelte +57 -12
- package/dist/components/Library/Image/Image.svelte.d.ts +1 -2
- package/dist/components/Library/Image/ImagePlaceholder.demo.svelte +12 -0
- package/dist/components/Library/Image/ImagePlaceholder.demo.svelte.d.ts +23 -0
- package/dist/components/Library/Image/ImagePlaceholder.svelte +28 -4
- package/dist/components/Library/Image/ImagePlaceholder.svelte.d.ts +1 -1
- package/dist/components/Library/Image/index.d.ts +1 -0
- package/dist/components/Library/Image/index.js +1 -0
- package/dist/components/Library/ImageMask/BrushPreview.svelte +6 -6
- package/dist/components/Library/ImageMask/ImageMask.demo.svelte +10 -8
- package/dist/components/Library/ImageMask/ImageMask.svelte +14 -6
- package/dist/components/Library/ImageMask/ImageMask.svelte.d.ts +1 -2
- package/dist/components/Library/ImageMask/MaskLayer.svelte +12 -6
- package/dist/components/Library/Label/Label.demo.svelte +16 -3
- package/dist/components/Library/Label/Label.svelte +15 -3
- package/dist/components/Library/Label/Label.svelte.d.ts +1 -0
- package/dist/components/Library/Link/Link.svelte +10 -22
- package/dist/components/Library/Link/Link.svelte.d.ts +2 -3
- package/dist/components/Library/Loader/Loader.demo.svelte +9 -3
- package/dist/components/Library/NavigationStack/Link.svelte +8 -12
- package/dist/components/Library/NavigationStack/Link.svelte.d.ts +1 -3
- package/dist/components/Library/NavigationStack/SidebarToggle.svelte +8 -2
- package/dist/components/Library/NumberField/NumberField.svelte +21 -17
- package/dist/components/Library/NumberField/NumberField.svelte.d.ts +4 -2
- package/dist/components/Library/Pagination/Pagination.svelte +3 -3
- package/dist/components/Library/Popover/Popover.svelte +2 -7
- package/dist/components/Library/ScrollView/ScrollView.demo.svelte +50 -0
- package/dist/components/Library/ScrollView/ScrollView.demo.svelte.d.ts +10 -0
- package/dist/components/Library/ScrollView/ScrollView.svelte +414 -67
- package/dist/components/Library/ScrollView/ScrollView.svelte.d.ts +17 -1
- package/dist/components/Library/ScrollView/index.d.ts +1 -1
- package/dist/components/Library/SearchField/SearchField.demo.svelte +2 -2
- package/dist/components/Library/SearchField/SearchField.svelte +9 -4
- package/dist/components/Library/SearchField/SearchField.svelte.d.ts +2 -1
- package/dist/components/Library/SegmentedPicker/SegmentedPicker.demo.svelte +2 -2
- package/dist/components/Library/SegmentedPicker/SegmentedPicker.svelte +7 -7
- package/dist/components/Library/Sheet/Sheet.demo.svelte +1 -1
- package/dist/components/Library/Sheet/Sheet.svelte +2 -7
- package/dist/components/Library/Slider/Slider.demo.svelte +1 -1
- package/dist/components/Library/Slider/Slider.svelte +11 -7
- package/dist/components/Library/Slider/Slider.svelte.d.ts +2 -1
- package/dist/components/Library/Spinner/Spinner.demo.svelte +1 -1
- package/dist/components/Library/Switch/Switch.demo.svelte +7 -4
- package/dist/components/Library/Switch/Switch.svelte +28 -68
- package/dist/components/Library/Switch/Switch.svelte.d.ts +2 -4
- package/dist/components/Library/Table/Column.svelte +81 -0
- package/dist/components/Library/Table/Column.svelte.d.ts +39 -0
- package/dist/components/Library/Table/Table.demo.svelte +148 -0
- package/dist/components/Library/Table/Table.demo.svelte.d.ts +10 -0
- package/dist/components/Library/Table/Table.svelte +624 -0
- package/dist/components/Library/Table/Table.svelte.d.ts +42 -0
- package/dist/components/Library/Table/context.d.ts +5 -0
- package/dist/components/Library/Table/context.js +2 -0
- package/dist/components/Library/Table/index.js +5 -0
- package/dist/components/Library/Table/types.d.ts +37 -0
- package/dist/components/Library/Table/types.js +1 -0
- package/dist/components/Library/Text/Text.demo.svelte +21 -0
- package/dist/components/Library/Text/Text.demo.svelte.d.ts +24 -0
- package/dist/components/Library/Text/Text.svelte +41 -0
- package/dist/components/Library/Text/Text.svelte.d.ts +9 -0
- package/dist/components/Library/Text/index.d.ts +1 -0
- package/dist/components/Library/Text/index.js +1 -0
- package/dist/components/Library/TextEditor/TextEditor.svelte +15 -9
- package/dist/components/Library/TextEditor/TextEditor.svelte.d.ts +2 -4
- package/dist/components/Library/TextField/TextField.demo.svelte +1 -1
- package/dist/components/Library/TextField/TextField.svelte +21 -18
- package/dist/components/Library/TextField/TextField.svelte.d.ts +4 -2
- package/dist/components/Library/TextShimmer/TextShimmer.demo.svelte +1 -1
- package/dist/components/Library/TimePicker/TimePicker.demo.svelte +10 -2
- package/dist/components/Library/TimePicker/TimePicker.svelte +10 -5
- package/dist/components/Library/TokenSearchField/TokenSearchField.demo.svelte +4 -2
- package/dist/components/Library/TokenSearchField/TokenSearchField.svelte +11 -11
- package/dist/components/Library/TokenSearchField/TokenSearchField.svelte.d.ts +2 -1
- package/dist/components/Library/WheelPicker/WheelColumn.svelte +183 -126
- package/dist/components/Library/WheelPicker/WheelPicker.svelte +4 -4
- package/dist/components/Library/WheelPicker/WheelPicker.svelte.d.ts +2 -2
- package/dist/components/Library/WheelPicker/index.d.ts +1 -1
- package/dist/components/Library/WheelPicker/types.d.ts +6 -0
- package/dist/components/Local/ColorStyleControls.svelte +201 -0
- package/dist/components/Local/ColorStyleControls.svelte.d.ts +13 -0
- package/dist/components/Local/HeroCard.svelte +3 -3
- package/dist/components/Local/LayoutStyleControls.svelte +67 -0
- package/dist/components/Local/LayoutStyleControls.svelte.d.ts +11 -0
- package/dist/components/Local/StyleControls.svelte +48 -124
- package/dist/components/Local/StyleControls.svelte.d.ts +7 -5
- package/dist/index.d.ts +9 -2
- package/dist/index.js +5 -1
- package/dist/style/index.css +7 -12
- package/dist/style/label.d.ts +2 -1
- package/dist/style/label.js +2 -1
- package/dist/style/surface.js +4 -0
- package/dist/style/text-editor.d.ts +2 -13
- package/dist/style/text-editor.js +1 -12
- package/dist/style/text.d.ts +26 -0
- package/dist/style/text.js +69 -0
- package/dist/style/tooltip.d.ts +4 -0
- package/dist/style/tooltip.js +1 -0
- package/dist/style.css +44 -111
- package/package.json +1 -1
- package/dist/components/Library/ArticleEditor/Blocks/ImagePreview.svelte +0 -71
- package/dist/components/Library/ArticleEditor/Blocks/ImagePreview.svelte.d.ts +0 -8
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
+
import { ImageOffIcon } from '@lucide/svelte';
|
|
2
3
|
import type { Snippet } from 'svelte';
|
|
3
4
|
import type { HTMLImgAttributes } from 'svelte/elements';
|
|
5
|
+
import { loader as loaderAction } from '../../../actions/loader';
|
|
4
6
|
import type { ImageFit, ImageLoading } from '../../../style/media';
|
|
5
|
-
import ImagePlaceholder from './ImagePlaceholder.svelte';
|
|
6
7
|
|
|
7
8
|
type Props = {
|
|
8
9
|
src?: string | null;
|
|
9
10
|
alt?: string;
|
|
10
11
|
fit?: ImageFit;
|
|
11
12
|
busy?: boolean;
|
|
12
|
-
placeholderKey?: string;
|
|
13
13
|
loading?: ImageLoading;
|
|
14
14
|
decoding?: HTMLImgAttributes['decoding'];
|
|
15
|
+
aspectRatio?: string;
|
|
15
16
|
children?: Snippet;
|
|
16
|
-
class?: string;
|
|
17
17
|
};
|
|
18
18
|
|
|
19
19
|
let {
|
|
@@ -21,28 +21,57 @@
|
|
|
21
21
|
alt = '',
|
|
22
22
|
fit = 'contain',
|
|
23
23
|
busy = false,
|
|
24
|
-
placeholderKey = 'default',
|
|
25
24
|
loading = 'lazy',
|
|
26
25
|
decoding = 'async',
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
aspectRatio,
|
|
27
|
+
children
|
|
29
28
|
}: Props = $props();
|
|
30
29
|
|
|
31
|
-
|
|
30
|
+
let imageLoaded = $state(false);
|
|
31
|
+
let imageFailed = $state(false);
|
|
32
|
+
|
|
33
|
+
$effect(() => {
|
|
34
|
+
src;
|
|
35
|
+
busy;
|
|
36
|
+
imageLoaded = false;
|
|
37
|
+
imageFailed = false;
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
const canRenderImage = $derived(Boolean(src) && !busy && !imageFailed);
|
|
41
|
+
const showLoader = $derived(busy || (Boolean(src) && !imageLoaded && !imageFailed));
|
|
42
|
+
const showMissingImage = $derived(!showLoader && (!src || imageFailed));
|
|
32
43
|
</script>
|
|
33
44
|
|
|
34
|
-
<div
|
|
35
|
-
|
|
45
|
+
<div
|
|
46
|
+
class="image relative overflow-hidden bg-zinc-100"
|
|
47
|
+
style={aspectRatio ? `aspect-ratio: ${aspectRatio}; height: auto;` : ''}
|
|
48
|
+
use:loaderAction={{
|
|
49
|
+
loading: showLoader,
|
|
50
|
+
background: 'color-mix(in oklab, var(--sveltely-text-secondary-color) 8%, transparent)',
|
|
51
|
+
color: 'color-mix(in oklab, var(--sveltely-text-secondary-color) 72%, transparent)'
|
|
52
|
+
}}
|
|
53
|
+
>
|
|
54
|
+
{#if canRenderImage}
|
|
36
55
|
<img
|
|
37
56
|
{src}
|
|
38
57
|
{alt}
|
|
39
58
|
{loading}
|
|
40
59
|
{decoding}
|
|
41
60
|
draggable="false"
|
|
42
|
-
class="absolute inset-0 size-full {fit === 'cover'
|
|
61
|
+
class="absolute inset-0 size-full {fit === 'cover'
|
|
62
|
+
? 'object-cover'
|
|
63
|
+
: 'object-contain'} {imageLoaded
|
|
64
|
+
? 'opacity-100'
|
|
65
|
+
: 'opacity-0'} transition-opacity duration-150"
|
|
66
|
+
onload={() => (imageLoaded = true)}
|
|
67
|
+
onerror={() => (imageFailed = true)}
|
|
43
68
|
/>
|
|
44
|
-
{
|
|
45
|
-
|
|
69
|
+
{/if}
|
|
70
|
+
|
|
71
|
+
{#if showMissingImage}
|
|
72
|
+
<div class="image-fallback" aria-hidden="true">
|
|
73
|
+
<ImageOffIcon strokeWidth={1.5} />
|
|
74
|
+
</div>
|
|
46
75
|
{/if}
|
|
47
76
|
|
|
48
77
|
{#if children}
|
|
@@ -52,6 +81,22 @@
|
|
|
52
81
|
|
|
53
82
|
<style>
|
|
54
83
|
.image {
|
|
84
|
+
width: 100%;
|
|
85
|
+
height: 100%;
|
|
55
86
|
border-radius: var(--image-border-radius, var(--sveltely-border-radius));
|
|
56
87
|
}
|
|
88
|
+
|
|
89
|
+
.image-fallback {
|
|
90
|
+
position: absolute;
|
|
91
|
+
inset: 0;
|
|
92
|
+
display: grid;
|
|
93
|
+
place-items: center;
|
|
94
|
+
background: color-mix(in oklab, var(--sveltely-text-secondary-color) 8%, transparent);
|
|
95
|
+
color: color-mix(in oklab, var(--sveltely-text-secondary-color) 72%, transparent);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.image-fallback :global(svg) {
|
|
99
|
+
width: clamp(3rem, 18%, 7rem);
|
|
100
|
+
height: clamp(3rem, 18%, 7rem);
|
|
101
|
+
}
|
|
57
102
|
</style>
|
|
@@ -6,11 +6,10 @@ type Props = {
|
|
|
6
6
|
alt?: string;
|
|
7
7
|
fit?: ImageFit;
|
|
8
8
|
busy?: boolean;
|
|
9
|
-
placeholderKey?: string;
|
|
10
9
|
loading?: ImageLoading;
|
|
11
10
|
decoding?: HTMLImgAttributes['decoding'];
|
|
11
|
+
aspectRatio?: string;
|
|
12
12
|
children?: Snippet;
|
|
13
|
-
class?: string;
|
|
14
13
|
};
|
|
15
14
|
declare const Image: import("svelte").Component<Props, {}, "">;
|
|
16
15
|
type Image = ReturnType<typeof Image>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
export const demo = {
|
|
3
|
+
name: 'ImagePlaceholder',
|
|
4
|
+
description: 'Animated generated placeholder for custom image surfaces.'
|
|
5
|
+
};
|
|
6
|
+
</script>
|
|
7
|
+
|
|
8
|
+
<script lang="ts">
|
|
9
|
+
import { ImagePlaceholder } from './index';
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<ImagePlaceholder seed="image-placeholder-demo" aspectRatio="4 / 3" />
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export declare const demo: {
|
|
2
|
+
name: string;
|
|
3
|
+
description: string;
|
|
4
|
+
};
|
|
5
|
+
import { ImagePlaceholder } from './index';
|
|
6
|
+
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> {
|
|
7
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
8
|
+
$$bindings?: Bindings;
|
|
9
|
+
} & Exports;
|
|
10
|
+
(internal: unknown, props: {
|
|
11
|
+
$$events?: Events;
|
|
12
|
+
$$slots?: Slots;
|
|
13
|
+
}): Exports & {
|
|
14
|
+
$set?: any;
|
|
15
|
+
$on?: any;
|
|
16
|
+
};
|
|
17
|
+
z_$$bindings?: Bindings;
|
|
18
|
+
}
|
|
19
|
+
declare const ImagePlaceholder: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
|
|
20
|
+
[evt: string]: CustomEvent<any>;
|
|
21
|
+
}, {}, {}, string>;
|
|
22
|
+
type ImagePlaceholder = InstanceType<typeof ImagePlaceholder>;
|
|
23
|
+
export default ImagePlaceholder;
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
import { onMount } from 'svelte';
|
|
3
3
|
|
|
4
4
|
let {
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
seed = 'default',
|
|
6
|
+
aspectRatio
|
|
7
7
|
}: {
|
|
8
|
-
class?: string;
|
|
9
8
|
seed?: string;
|
|
9
|
+
aspectRatio?: string;
|
|
10
10
|
} = $props();
|
|
11
11
|
|
|
12
12
|
const fps = 24;
|
|
@@ -199,4 +199,28 @@
|
|
|
199
199
|
});
|
|
200
200
|
</script>
|
|
201
201
|
|
|
202
|
-
<
|
|
202
|
+
<div
|
|
203
|
+
class="image-placeholder"
|
|
204
|
+
style={aspectRatio ? `aspect-ratio: ${aspectRatio}; height: auto;` : ''}
|
|
205
|
+
aria-hidden="true"
|
|
206
|
+
>
|
|
207
|
+
<canvas bind:this={canvas} class="image-placeholder-canvas"></canvas>
|
|
208
|
+
</div>
|
|
209
|
+
|
|
210
|
+
<style>
|
|
211
|
+
.image-placeholder {
|
|
212
|
+
position: relative;
|
|
213
|
+
width: 100%;
|
|
214
|
+
height: 100%;
|
|
215
|
+
overflow: hidden;
|
|
216
|
+
border-radius: var(--image-placeholder-border-radius, var(--sveltely-border-radius));
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
.image-placeholder-canvas {
|
|
220
|
+
position: absolute;
|
|
221
|
+
inset: 0;
|
|
222
|
+
display: block;
|
|
223
|
+
width: 100%;
|
|
224
|
+
height: 100%;
|
|
225
|
+
}
|
|
226
|
+
</style>
|
|
@@ -56,9 +56,9 @@
|
|
|
56
56
|
pointer-events: none;
|
|
57
57
|
border: 1.5px solid rgb(255 255 255 / 0.95);
|
|
58
58
|
border-radius: 9999px;
|
|
59
|
-
background: color-mix(in oklab, var(--sveltely-active-color) 16%, transparent);
|
|
59
|
+
background: color-mix(in oklab, var(--sveltely-control-active-color) 16%, transparent);
|
|
60
60
|
box-shadow:
|
|
61
|
-
0 0 0 1px color-mix(in oklab, var(--sveltely-active-color) 90%, transparent),
|
|
61
|
+
0 0 0 1px color-mix(in oklab, var(--sveltely-control-active-color) 90%, transparent),
|
|
62
62
|
0 1px 4px rgb(0 0 0 / 0.22);
|
|
63
63
|
will-change: transform, width, height;
|
|
64
64
|
}
|
|
@@ -88,16 +88,16 @@
|
|
|
88
88
|
box-sizing: border-box;
|
|
89
89
|
border-radius: 9999px;
|
|
90
90
|
border: 1.5px solid rgb(255 255 255 / 0.95);
|
|
91
|
-
background: color-mix(in oklab, var(--sveltely-active-color) 20%, transparent);
|
|
91
|
+
background: color-mix(in oklab, var(--sveltely-control-active-color) 20%, transparent);
|
|
92
92
|
box-shadow:
|
|
93
|
-
0 0 0 1px color-mix(in oklab, var(--sveltely-active-color) 95%, transparent),
|
|
93
|
+
0 0 0 1px color-mix(in oklab, var(--sveltely-control-active-color) 95%, transparent),
|
|
94
94
|
0 8px 24px rgb(0 0 0 / 0.24);
|
|
95
95
|
}
|
|
96
96
|
|
|
97
97
|
.brush-size-preview-label {
|
|
98
98
|
border-radius: 9999px;
|
|
99
99
|
background: rgb(255 255 255 / 0.88);
|
|
100
|
-
color: var(--sveltely-primary-color);
|
|
100
|
+
color: var(--sveltely-text-primary-color);
|
|
101
101
|
font-size: 0.75rem;
|
|
102
102
|
font-weight: 650;
|
|
103
103
|
line-height: 1;
|
|
@@ -113,7 +113,7 @@
|
|
|
113
113
|
.brush-size-preview-erase .brush-size-preview-circle {
|
|
114
114
|
background: rgb(255 255 255 / 0.2);
|
|
115
115
|
box-shadow:
|
|
116
|
-
0 0 0 1px color-mix(in oklab, var(--sveltely-active-color) 85%, transparent),
|
|
116
|
+
0 0 0 1px color-mix(in oklab, var(--sveltely-control-active-color) 85%, transparent),
|
|
117
117
|
0 8px 24px rgb(0 0 0 / 0.24);
|
|
118
118
|
}
|
|
119
119
|
</style>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script module lang="ts">
|
|
2
2
|
export const demo = {
|
|
3
|
-
name: '
|
|
3
|
+
name: 'Image Mask',
|
|
4
4
|
description: 'Image mask editor that exposes the exported mask through bind:mask.',
|
|
5
5
|
columnSpan: 2,
|
|
6
6
|
rowSpan: 2
|
|
@@ -28,17 +28,19 @@
|
|
|
28
28
|
bind:tool
|
|
29
29
|
bind:clearRevision
|
|
30
30
|
fit="cover"
|
|
31
|
-
|
|
31
|
+
aspectRatio="1 / 1"
|
|
32
32
|
/>
|
|
33
|
-
<div class="vstack gap-2 text-sm text-[var(--sveltely-secondary-color)]">
|
|
34
|
-
<div class="font-medium text-[var(--sveltely-primary-color)]">Mask</div>
|
|
33
|
+
<div class="vstack gap-2 text-sm text-[var(--sveltely-text-secondary-color)]">
|
|
34
|
+
<div class="font-medium text-[var(--sveltely-text-primary-color)]">Mask</div>
|
|
35
35
|
<div class="aspect-square overflow-hidden rounded-md border border-zinc-200 bg-black">
|
|
36
36
|
{#if mask}
|
|
37
37
|
<img src={mask.dataUrl} alt="Exported mask" class="size-full object-contain" />
|
|
38
38
|
{/if}
|
|
39
39
|
</div>
|
|
40
40
|
<label class="vstack gap-2 bg-white p-3">
|
|
41
|
-
<span class="font-medium text-[var(--sveltely-primary-color)]"
|
|
41
|
+
<span class="font-medium text-[var(--sveltely-text-primary-color)]"
|
|
42
|
+
>Brush size {brushSize}px</span
|
|
43
|
+
>
|
|
42
44
|
<Slider bind:value={brushSize} min={6} max={72} step={1} />
|
|
43
45
|
<div class="image-mask-controls">
|
|
44
46
|
<button
|
|
@@ -97,7 +99,7 @@
|
|
|
97
99
|
align-items: center;
|
|
98
100
|
justify-content: center;
|
|
99
101
|
border-radius: 9999px;
|
|
100
|
-
color: var(--sveltely-secondary-color);
|
|
102
|
+
color: var(--sveltely-text-secondary-color);
|
|
101
103
|
transition:
|
|
102
104
|
background-color 150ms,
|
|
103
105
|
color 150ms,
|
|
@@ -106,8 +108,8 @@
|
|
|
106
108
|
|
|
107
109
|
.image-mask-controls button:hover:not(:disabled),
|
|
108
110
|
.image-mask-controls button.active {
|
|
109
|
-
background: var(--sveltely-active-color);
|
|
110
|
-
color: var(--sveltely-background-color);
|
|
111
|
+
background: var(--sveltely-control-active-color);
|
|
112
|
+
color: var(--sveltely-control-background-color);
|
|
111
113
|
}
|
|
112
114
|
|
|
113
115
|
.image-mask-controls button:disabled {
|
|
@@ -11,13 +11,12 @@
|
|
|
11
11
|
fit = 'contain',
|
|
12
12
|
busy = false,
|
|
13
13
|
disabled = false,
|
|
14
|
-
placeholderKey = 'default',
|
|
15
14
|
loading = 'lazy',
|
|
16
15
|
brushSize = $bindable(24),
|
|
17
16
|
tool = $bindable<MaskTool>('paint'),
|
|
18
17
|
clearRevision = $bindable(0),
|
|
19
18
|
exportSize = 2048,
|
|
20
|
-
|
|
19
|
+
aspectRatio
|
|
21
20
|
}: {
|
|
22
21
|
src?: string | null;
|
|
23
22
|
alt?: string;
|
|
@@ -25,22 +24,31 @@
|
|
|
25
24
|
fit?: ImageFit;
|
|
26
25
|
busy?: boolean;
|
|
27
26
|
disabled?: boolean;
|
|
28
|
-
placeholderKey?: string;
|
|
29
27
|
loading?: ImageLoading;
|
|
30
28
|
brushSize?: number;
|
|
31
29
|
tool?: MaskTool;
|
|
32
30
|
clearRevision?: number;
|
|
33
31
|
exportSize?: number;
|
|
34
|
-
|
|
32
|
+
aspectRatio?: string;
|
|
35
33
|
} = $props();
|
|
36
34
|
|
|
37
35
|
const canEdit = $derived(Boolean(src) && !busy && !disabled);
|
|
38
36
|
</script>
|
|
39
37
|
|
|
40
|
-
<div
|
|
41
|
-
|
|
38
|
+
<div
|
|
39
|
+
class="image-mask relative"
|
|
40
|
+
style={aspectRatio ? `aspect-ratio: ${aspectRatio}; height: auto;` : ''}
|
|
41
|
+
>
|
|
42
|
+
<Image {src} {alt} {fit} {busy} {loading}>
|
|
42
43
|
{#if canEdit}
|
|
43
44
|
<MaskLayer bind:mask {tool} {brushSize} {exportSize} {disabled} {clearRevision} />
|
|
44
45
|
{/if}
|
|
45
46
|
</Image>
|
|
46
47
|
</div>
|
|
48
|
+
|
|
49
|
+
<style>
|
|
50
|
+
.image-mask {
|
|
51
|
+
width: 100%;
|
|
52
|
+
height: 100%;
|
|
53
|
+
}
|
|
54
|
+
</style>
|
|
@@ -7,13 +7,12 @@ type $$ComponentProps = {
|
|
|
7
7
|
fit?: ImageFit;
|
|
8
8
|
busy?: boolean;
|
|
9
9
|
disabled?: boolean;
|
|
10
|
-
placeholderKey?: string;
|
|
11
10
|
loading?: ImageLoading;
|
|
12
11
|
brushSize?: number;
|
|
13
12
|
tool?: MaskTool;
|
|
14
13
|
clearRevision?: number;
|
|
15
14
|
exportSize?: number;
|
|
16
|
-
|
|
15
|
+
aspectRatio?: string;
|
|
17
16
|
};
|
|
18
17
|
declare const ImageMask: import("svelte").Component<$$ComponentProps, {}, "mask" | "brushSize" | "tool" | "clearRevision">;
|
|
19
18
|
type ImageMask = ReturnType<typeof ImageMask>;
|
|
@@ -130,6 +130,11 @@
|
|
|
130
130
|
}
|
|
131
131
|
|
|
132
132
|
function drawOutlineSurface() {
|
|
133
|
+
if (isDrawing) {
|
|
134
|
+
outlineContext?.clearRect(0, 0, viewportWidth, viewportHeight);
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
|
|
133
138
|
drawMarchingAnts({
|
|
134
139
|
context: outlineContext,
|
|
135
140
|
contours,
|
|
@@ -144,14 +149,14 @@
|
|
|
144
149
|
drawOutlineSurface();
|
|
145
150
|
context.clearRect(0, 0, viewportWidth, viewportHeight);
|
|
146
151
|
if (!surfaceCanvas) return;
|
|
147
|
-
const
|
|
148
|
-
? getComputedStyle(canvas).getPropertyValue('--sveltely-active-color').trim() ||
|
|
149
|
-
'var(--sveltely-active-color)'
|
|
150
|
-
: 'var(--sveltely-active-color)';
|
|
152
|
+
const maskColor = canvas
|
|
153
|
+
? getComputedStyle(canvas).getPropertyValue('--sveltely-control-active-color').trim() ||
|
|
154
|
+
'var(--sveltely-control-active-color)'
|
|
155
|
+
: 'var(--sveltely-control-active-color)';
|
|
151
156
|
context.save();
|
|
152
157
|
context.drawImage(surfaceCanvas, 0, 0, viewportWidth, viewportHeight);
|
|
153
158
|
context.globalCompositeOperation = 'source-in';
|
|
154
|
-
context.fillStyle =
|
|
159
|
+
context.fillStyle = maskColor;
|
|
155
160
|
context.globalAlpha = 0.32;
|
|
156
161
|
context.fillRect(0, 0, viewportWidth, viewportHeight);
|
|
157
162
|
context.restore();
|
|
@@ -160,7 +165,7 @@
|
|
|
160
165
|
context.save();
|
|
161
166
|
context.drawImage(outlineCanvas, 0, 0, viewportWidth, viewportHeight);
|
|
162
167
|
context.globalCompositeOperation = 'source-in';
|
|
163
|
-
context.fillStyle =
|
|
168
|
+
context.fillStyle = maskColor;
|
|
164
169
|
context.globalAlpha = 0.9;
|
|
165
170
|
context.fillRect(0, 0, viewportWidth, viewportHeight);
|
|
166
171
|
context.restore();
|
|
@@ -253,6 +258,7 @@
|
|
|
253
258
|
isDrawing = false;
|
|
254
259
|
lastPoint = null;
|
|
255
260
|
rebuildContours();
|
|
261
|
+
drawFrame();
|
|
256
262
|
emitMask();
|
|
257
263
|
}
|
|
258
264
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script module lang="ts">
|
|
2
2
|
export const demo = {
|
|
3
3
|
name: 'Label',
|
|
4
|
-
description: 'Form label wrapper with top and
|
|
4
|
+
description: 'Form label wrapper with top, leading, and trailing placement.',
|
|
5
5
|
columnSpan: 2
|
|
6
6
|
};
|
|
7
7
|
</script>
|
|
@@ -9,20 +9,33 @@
|
|
|
9
9
|
<script lang="ts">
|
|
10
10
|
import { HashIcon, UserIcon } from '@lucide/svelte';
|
|
11
11
|
import HStack from '../HStack';
|
|
12
|
+
import Switch from '../Switch';
|
|
12
13
|
import NumberField from '../NumberField';
|
|
13
14
|
import TextField from '../TextField';
|
|
14
15
|
import Label from './Label.svelte';
|
|
15
16
|
|
|
16
17
|
let name = $state('');
|
|
17
18
|
let amount = $state<number | null>(35);
|
|
19
|
+
let enabled = $state(true);
|
|
18
20
|
</script>
|
|
19
21
|
|
|
20
22
|
<HStack gap={10} align="center">
|
|
21
|
-
<Label label="Name" icon={UserIcon} orientation="top">
|
|
23
|
+
<Label label="Name" icon={UserIcon} orientation="top" width="fit">
|
|
22
24
|
<TextField bind:value={name} placeholder="Sveltely" />
|
|
23
25
|
</Label>
|
|
24
26
|
|
|
25
|
-
<Label label="Amount" icon={HashIcon} orientation="
|
|
27
|
+
<Label label="Amount" icon={HashIcon} orientation="leading" width="fit">
|
|
26
28
|
<NumberField bind:value={amount} min={0} max={100} />
|
|
27
29
|
</Label>
|
|
30
|
+
|
|
31
|
+
<Label label="Enabled" orientation="trailing" width="fit">
|
|
32
|
+
<Switch bind:checked={enabled} />
|
|
33
|
+
</Label>
|
|
34
|
+
|
|
35
|
+
<Label orientation="leading" width="fit">
|
|
36
|
+
{#snippet labelContent()}
|
|
37
|
+
<span>Name <span class="text-[var(--sveltely-text-tertiary-color)]">optional</span></span>
|
|
38
|
+
{/snippet}
|
|
39
|
+
<TextField bind:value={name} placeholder="Sveltely" />
|
|
40
|
+
</Label>
|
|
28
41
|
</HStack>
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
type Props = {
|
|
8
8
|
children?: Snippet;
|
|
9
9
|
label?: string;
|
|
10
|
+
labelContent?: Snippet;
|
|
10
11
|
icon?: Component<{ class?: string; size?: number | string }>;
|
|
11
12
|
iconSize?: number | string;
|
|
12
13
|
iconColor?: string;
|
|
@@ -17,6 +18,7 @@
|
|
|
17
18
|
let {
|
|
18
19
|
children,
|
|
19
20
|
label,
|
|
21
|
+
labelContent,
|
|
20
22
|
icon,
|
|
21
23
|
iconSize,
|
|
22
24
|
iconColor,
|
|
@@ -93,7 +95,7 @@
|
|
|
93
95
|
</script>
|
|
94
96
|
|
|
95
97
|
<div class="label" data-orientation={orientation} style={rootStyle}>
|
|
96
|
-
{#if icon || label}
|
|
98
|
+
{#if icon || label || labelContent}
|
|
97
99
|
<span class="label-heading">
|
|
98
100
|
{#if icon}
|
|
99
101
|
{@const Icon = icon}
|
|
@@ -104,6 +106,10 @@
|
|
|
104
106
|
|
|
105
107
|
{#if label}
|
|
106
108
|
<span class="label-text">{label}</span>
|
|
109
|
+
{:else if labelContent}
|
|
110
|
+
<span class="label-text">
|
|
111
|
+
{@render labelContent()}
|
|
112
|
+
</span>
|
|
107
113
|
{/if}
|
|
108
114
|
</span>
|
|
109
115
|
{/if}
|
|
@@ -125,7 +131,7 @@
|
|
|
125
131
|
min-height: min-content;
|
|
126
132
|
gap: var(--label-gap, calc(var(--sveltely-gap) * 0.75));
|
|
127
133
|
border-radius: var(--label-border-radius, 0px);
|
|
128
|
-
color: var(--label-color, var(--sveltely-primary-color));
|
|
134
|
+
color: var(--label-color, var(--sveltely-text-primary-color));
|
|
129
135
|
font-size: var(--label-font-size);
|
|
130
136
|
padding: var(--label-padding-y, 0px) var(--label-padding-x, 0px);
|
|
131
137
|
}
|
|
@@ -135,11 +141,17 @@
|
|
|
135
141
|
align-items: stretch;
|
|
136
142
|
}
|
|
137
143
|
|
|
138
|
-
.label[data-orientation='
|
|
144
|
+
.label[data-orientation='leading'],
|
|
145
|
+
.label[data-orientation='trailing'] {
|
|
139
146
|
flex-direction: row;
|
|
140
147
|
align-items: center;
|
|
141
148
|
}
|
|
142
149
|
|
|
150
|
+
.label[data-orientation='trailing'] {
|
|
151
|
+
flex-direction: row-reverse;
|
|
152
|
+
justify-content: flex-end;
|
|
153
|
+
}
|
|
154
|
+
|
|
143
155
|
.label-heading {
|
|
144
156
|
display: inline-flex;
|
|
145
157
|
min-width: max-content;
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import type { Snippet } from 'svelte';
|
|
3
3
|
import type { HTMLAnchorAttributes } from 'svelte/elements';
|
|
4
|
+
import { tooltip as tooltipAction } from '../../../actions/tooltip';
|
|
4
5
|
import { extractStyleProps, surfaceStyle, type StyleProps } from '../../../style/surface';
|
|
6
|
+
import type { TooltipProps } from '../../../style/tooltip';
|
|
5
7
|
|
|
6
8
|
type Props = {
|
|
7
9
|
children?: Snippet;
|
|
8
10
|
label?: string;
|
|
9
11
|
} & StyleProps &
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
};
|
|
12
|
+
TooltipProps &
|
|
13
|
+
Omit<HTMLAnchorAttributes, 'children' | 'class' | 'style'>;
|
|
13
14
|
|
|
14
|
-
let { children, label,
|
|
15
|
+
let { children, label, tooltip, ...restProps }: Props = $props();
|
|
15
16
|
|
|
16
17
|
const extractedStyleProps = $derived.by(() => extractStyleProps(restProps));
|
|
17
18
|
const styleProps = $derived(extractedStyleProps.styleProps);
|
|
@@ -35,11 +36,10 @@
|
|
|
35
36
|
</script>
|
|
36
37
|
|
|
37
38
|
<a
|
|
38
|
-
class="link inline-flex items-center justify-center {iconOnly
|
|
39
|
-
? 'link-icon-only'
|
|
40
|
-
: ''} {className}"
|
|
39
|
+
class="link inline-flex items-center justify-center {iconOnly ? 'link-icon-only' : ''}"
|
|
41
40
|
style={rootStyle}
|
|
42
41
|
{...props}
|
|
42
|
+
use:tooltipAction={tooltip}
|
|
43
43
|
>
|
|
44
44
|
{#if children}
|
|
45
45
|
{@render children()}
|
|
@@ -55,8 +55,8 @@
|
|
|
55
55
|
--link-icon-size: calc(var(--link-font-size) * 1.143);
|
|
56
56
|
border: 1px solid var(--link-border-color, var(--sveltely-border-color));
|
|
57
57
|
border-radius: var(--link-border-radius, var(--sveltely-border-radius));
|
|
58
|
-
background: var(--link-background, var(--sveltely-background-color));
|
|
59
|
-
color: var(--link-color, var(--sveltely-primary-color));
|
|
58
|
+
background: var(--link-background, var(--sveltely-control-background-color));
|
|
59
|
+
color: var(--link-color, var(--sveltely-text-primary-color));
|
|
60
60
|
gap: var(--link-gap, var(--sveltely-gap));
|
|
61
61
|
font-size: var(--link-font-size);
|
|
62
62
|
line-height: 1.25;
|
|
@@ -65,19 +65,7 @@
|
|
|
65
65
|
text-decoration: none;
|
|
66
66
|
transition:
|
|
67
67
|
color 150ms,
|
|
68
|
-
border-color 150ms
|
|
69
|
-
background-color 150ms;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
.link:hover {
|
|
73
|
-
background: var(
|
|
74
|
-
--link-hover-background,
|
|
75
|
-
color-mix(
|
|
76
|
-
in oklab,
|
|
77
|
-
var(--link-background, var(--sveltely-background-color)) 88%,
|
|
78
|
-
var(--link-color, var(--sveltely-primary-color))
|
|
79
|
-
)
|
|
80
|
-
);
|
|
68
|
+
border-color 150ms;
|
|
81
69
|
}
|
|
82
70
|
|
|
83
71
|
.link-icon-only {
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
2
|
import type { HTMLAnchorAttributes } from 'svelte/elements';
|
|
3
3
|
import { type StyleProps } from '../../../style/surface';
|
|
4
|
+
import type { TooltipProps } from '../../../style/tooltip';
|
|
4
5
|
type Props = {
|
|
5
6
|
children?: Snippet;
|
|
6
7
|
label?: string;
|
|
7
|
-
} & StyleProps & Omit<HTMLAnchorAttributes, 'children' | 'class' | 'style'
|
|
8
|
-
class?: HTMLAnchorAttributes['class'];
|
|
9
|
-
};
|
|
8
|
+
} & StyleProps & TooltipProps & Omit<HTMLAnchorAttributes, 'children' | 'class' | 'style'>;
|
|
10
9
|
declare const Link: import("svelte").Component<Props, {}, "">;
|
|
11
10
|
type Link = ReturnType<typeof Link>;
|
|
12
11
|
export default Link;
|
|
@@ -28,10 +28,16 @@
|
|
|
28
28
|
</script>
|
|
29
29
|
|
|
30
30
|
<ScrollView
|
|
31
|
-
background="color-mix(in oklab, var(--sveltely-background-color) 94%, var(--sveltely-primary-color))"
|
|
31
|
+
background="color-mix(in oklab, var(--sveltely-background-color) 94%, var(--sveltely-text-primary-color))"
|
|
32
32
|
borderRadius={7.5}
|
|
33
33
|
scrollGradient={false}
|
|
34
|
-
loader={{
|
|
34
|
+
loader={{
|
|
35
|
+
text: 'Loading preview...',
|
|
36
|
+
promise: pending,
|
|
37
|
+
background:
|
|
38
|
+
'color-mix(in oklab, var(--sveltely-background-color) 94%, var(--sveltely-text-primary-color))',
|
|
39
|
+
fontSize: 12
|
|
40
|
+
}}
|
|
35
41
|
>
|
|
36
42
|
<div class="loader-demo">
|
|
37
43
|
<div class="loader-demo-copy">
|
|
@@ -67,7 +73,7 @@
|
|
|
67
73
|
}
|
|
68
74
|
|
|
69
75
|
.loader-demo-copy span {
|
|
70
|
-
color: var(--sveltely-secondary-color);
|
|
76
|
+
color: var(--sveltely-text-secondary-color);
|
|
71
77
|
font-size: calc(var(--sveltely-font-size) * 0.875);
|
|
72
78
|
line-height: 1.3;
|
|
73
79
|
}
|