@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
|
@@ -4,15 +4,39 @@
|
|
|
4
4
|
|
|
5
5
|
type Props = {
|
|
6
6
|
text: string;
|
|
7
|
+
background?: string;
|
|
8
|
+
color?: string;
|
|
9
|
+
fontSize?: number;
|
|
7
10
|
};
|
|
8
11
|
|
|
9
|
-
let { text }: Props = $props();
|
|
12
|
+
let { text, background, color, fontSize }: Props = $props();
|
|
13
|
+
|
|
14
|
+
const toRem = (value: number | undefined) =>
|
|
15
|
+
value === undefined ? undefined : `${value / 10}rem`;
|
|
16
|
+
|
|
17
|
+
const overlayStyle = $derived.by(() =>
|
|
18
|
+
[
|
|
19
|
+
background ? `--sveltely-loader-background: ${background};` : '',
|
|
20
|
+
color ? `--sveltely-loader-color: ${color};` : '',
|
|
21
|
+
fontSize !== undefined ? `--sveltely-loader-font-size: ${toRem(fontSize)};` : ''
|
|
22
|
+
]
|
|
23
|
+
.filter(Boolean)
|
|
24
|
+
.join(' ')
|
|
25
|
+
);
|
|
10
26
|
</script>
|
|
11
27
|
|
|
12
|
-
<div
|
|
28
|
+
<div
|
|
29
|
+
class="sveltely-loader-overlay"
|
|
30
|
+
role="status"
|
|
31
|
+
aria-live="polite"
|
|
32
|
+
aria-label={text || 'Loading'}
|
|
33
|
+
style={overlayStyle}
|
|
34
|
+
>
|
|
13
35
|
<VStack align="center" justify="center" gap={5}>
|
|
14
|
-
<Spinner />
|
|
15
|
-
|
|
36
|
+
<Spinner size="calc(var(--sveltely-loader-font-size) * 1.143)" />
|
|
37
|
+
{#if text}
|
|
38
|
+
<span class="sveltely-loader-text">{text}</span>
|
|
39
|
+
{/if}
|
|
16
40
|
</VStack>
|
|
17
41
|
</div>
|
|
18
42
|
|
|
@@ -25,8 +49,9 @@
|
|
|
25
49
|
align-items: center;
|
|
26
50
|
justify-content: center;
|
|
27
51
|
border-radius: inherit;
|
|
28
|
-
background: var(--sveltely-background-color, white);
|
|
29
|
-
color: var(--sveltely-primary-color, black);
|
|
52
|
+
background: var(--sveltely-loader-background, var(--sveltely-background-color, white));
|
|
53
|
+
color: var(--sveltely-loader-color, var(--sveltely-text-primary-color, black));
|
|
54
|
+
font-size: var(--sveltely-loader-font-size, var(--sveltely-font-size, 1rem));
|
|
30
55
|
padding: var(--sveltely-padding-y, 0.75rem) var(--sveltely-padding-x, 0.75rem);
|
|
31
56
|
pointer-events: auto;
|
|
32
57
|
text-align: center;
|
|
@@ -35,8 +60,8 @@
|
|
|
35
60
|
.sveltely-loader-text {
|
|
36
61
|
max-width: 100%;
|
|
37
62
|
overflow: hidden;
|
|
38
|
-
color: var(--sveltely-
|
|
39
|
-
font-size:
|
|
63
|
+
color: var(--sveltely-loader-text-color, currentColor);
|
|
64
|
+
font-size: var(--sveltely-loader-font-size, var(--sveltely-font-size, 1rem));
|
|
40
65
|
line-height: 1.25;
|
|
41
66
|
text-overflow: ellipsis;
|
|
42
67
|
white-space: nowrap;
|
package/dist/actions/loader.d.ts
CHANGED
|
@@ -5,6 +5,9 @@ export type LoaderOptions = LoaderTrigger | [text: string, loading: LoaderTrigge
|
|
|
5
5
|
loading?: LoaderTrigger;
|
|
6
6
|
active?: LoaderTrigger;
|
|
7
7
|
promise?: PromiseLike<unknown> | null;
|
|
8
|
+
background?: string;
|
|
9
|
+
color?: string;
|
|
10
|
+
fontSize?: number;
|
|
8
11
|
disabled?: boolean;
|
|
9
12
|
};
|
|
10
13
|
export declare const loader: Action<HTMLElement, LoaderOptions>;
|
package/dist/actions/loader.js
CHANGED
|
@@ -8,21 +8,30 @@ const isPromiseLike = (value) => typeof value === 'object' &&
|
|
|
8
8
|
const parseOptions = (value = false) => {
|
|
9
9
|
if (Array.isArray(value)) {
|
|
10
10
|
return {
|
|
11
|
-
text: value[0]
|
|
11
|
+
text: value[0] ?? DEFAULT_TEXT,
|
|
12
12
|
loading: value[1],
|
|
13
|
+
background: undefined,
|
|
14
|
+
color: undefined,
|
|
15
|
+
fontSize: undefined,
|
|
13
16
|
disabled: false
|
|
14
17
|
};
|
|
15
18
|
}
|
|
16
19
|
if (typeof value === 'object' && value !== null && !isPromiseLike(value)) {
|
|
17
20
|
return {
|
|
18
|
-
text: value.text
|
|
21
|
+
text: value.text ?? '',
|
|
19
22
|
loading: value.loading ?? value.active ?? value.promise ?? false,
|
|
23
|
+
background: value.background,
|
|
24
|
+
color: value.color,
|
|
25
|
+
fontSize: value.fontSize,
|
|
20
26
|
disabled: value.disabled ?? false
|
|
21
27
|
};
|
|
22
28
|
}
|
|
23
29
|
return {
|
|
24
30
|
text: DEFAULT_TEXT,
|
|
25
31
|
loading: value,
|
|
32
|
+
background: undefined,
|
|
33
|
+
color: undefined,
|
|
34
|
+
fontSize: undefined,
|
|
26
35
|
disabled: false
|
|
27
36
|
};
|
|
28
37
|
};
|
|
@@ -37,7 +46,7 @@ export const loader = (node, initialOptions = false) => {
|
|
|
37
46
|
const originalAriaBusy = node.getAttribute('aria-busy');
|
|
38
47
|
let options = parseOptions(initialOptions);
|
|
39
48
|
let overlay = null;
|
|
40
|
-
let
|
|
49
|
+
let overlayKey = '';
|
|
41
50
|
let promiseVersion = 0;
|
|
42
51
|
let appliedPosition = false;
|
|
43
52
|
const ensureHostPosition = () => {
|
|
@@ -57,17 +66,21 @@ export const loader = (node, initialOptions = false) => {
|
|
|
57
66
|
const show = () => {
|
|
58
67
|
ensureHostPosition();
|
|
59
68
|
node.setAttribute('aria-busy', 'true');
|
|
60
|
-
|
|
69
|
+
const nextOverlayKey = [options.text, options.background, options.color, options.fontSize].join('\0');
|
|
70
|
+
if (overlay && overlayKey === nextOverlayKey) {
|
|
61
71
|
return;
|
|
62
72
|
}
|
|
63
73
|
if (overlay) {
|
|
64
74
|
void unmount(overlay);
|
|
65
75
|
}
|
|
66
|
-
|
|
76
|
+
overlayKey = nextOverlayKey;
|
|
67
77
|
overlay = mount(LoaderOverlay, {
|
|
68
78
|
target: node,
|
|
69
79
|
props: {
|
|
70
|
-
text: options.text
|
|
80
|
+
text: options.text,
|
|
81
|
+
background: options.background,
|
|
82
|
+
color: options.color,
|
|
83
|
+
fontSize: options.fontSize
|
|
71
84
|
}
|
|
72
85
|
});
|
|
73
86
|
};
|
|
@@ -75,7 +88,7 @@ export const loader = (node, initialOptions = false) => {
|
|
|
75
88
|
if (overlay) {
|
|
76
89
|
void unmount(overlay);
|
|
77
90
|
overlay = null;
|
|
78
|
-
|
|
91
|
+
overlayKey = '';
|
|
79
92
|
}
|
|
80
93
|
if (originalAriaBusy === null) {
|
|
81
94
|
node.removeAttribute('aria-busy');
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script module lang="ts">
|
|
2
2
|
export const demo = {
|
|
3
|
-
name: '
|
|
3
|
+
name: 'Animated Number',
|
|
4
4
|
description: 'Spring-driven numeric transitions.'
|
|
5
5
|
};
|
|
6
6
|
</script>
|
|
@@ -17,14 +17,8 @@
|
|
|
17
17
|
</script>
|
|
18
18
|
|
|
19
19
|
<div class="vstack center gap-3">
|
|
20
|
-
<div class="text-3xl font-semibold text-[var(--sveltely-primary-color)]">
|
|
20
|
+
<div class="text-3xl font-semibold text-[var(--sveltely-text-primary-color)]">
|
|
21
21
|
<AnimatedNumber {value} />
|
|
22
22
|
</div>
|
|
23
|
-
<Button
|
|
24
|
-
label="Change number"
|
|
25
|
-
background="var(--sveltely-active-color)"
|
|
26
|
-
borderColor="var(--sveltely-active-color)"
|
|
27
|
-
color="var(--sveltely-background-color)"
|
|
28
|
-
onclick={bump}
|
|
29
|
-
/>
|
|
23
|
+
<Button label="Change number" onclick={bump} />
|
|
30
24
|
</div>
|
|
@@ -162,6 +162,7 @@
|
|
|
162
162
|
<VStack gap={12.5}>
|
|
163
163
|
{#each faqBlocks as block (block.id)}
|
|
164
164
|
<TextEditor
|
|
165
|
+
as="h2"
|
|
165
166
|
autosize
|
|
166
167
|
value={block.text ?? 'Frequently asked questions'}
|
|
167
168
|
rows={1}
|
|
@@ -169,7 +170,6 @@
|
|
|
169
170
|
onUpdateBlock(block.id, {
|
|
170
171
|
text: (event.currentTarget as HTMLTextAreaElement).value
|
|
171
172
|
})}
|
|
172
|
-
className="text-2xl leading-tight font-semibold tracking-[-0.025em] text-zinc-950 placeholder:text-zinc-300"
|
|
173
173
|
placeholder="FAQ title"
|
|
174
174
|
/>
|
|
175
175
|
<FAQ {block} onUpdateItem={onUpdateFAQItem} />
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import VStack from '../VStack';
|
|
3
3
|
import TextEditor from '../TextEditor';
|
|
4
|
-
import
|
|
5
|
-
import type { ArticleEditorArticle } from './types.js';
|
|
4
|
+
import Image from './Blocks/Image.svelte';
|
|
5
|
+
import type { ArticleEditorArticle, BlockDraft } from './types.js';
|
|
6
6
|
|
|
7
7
|
let { article, draftTitle, draftImageAltText, onTitleChange, onImageAltTextChange } = $props<{
|
|
8
8
|
article: ArticleEditorArticle;
|
|
@@ -11,47 +11,37 @@
|
|
|
11
11
|
onTitleChange: (value: string) => void;
|
|
12
12
|
onImageAltTextChange: (value: string) => void;
|
|
13
13
|
}>();
|
|
14
|
+
|
|
15
|
+
const heroImageBlock = $derived<BlockDraft>({
|
|
16
|
+
id: article.id ? `${article.id}:hero-image` : 'article-hero-image',
|
|
17
|
+
order: -1,
|
|
18
|
+
type: 'image',
|
|
19
|
+
imageURL: article.imageURL,
|
|
20
|
+
imageAlt: draftImageAltText
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
const onHeroImageUpdate = (_id: string, patch: Partial<BlockDraft>) => {
|
|
24
|
+
if (patch.imageAlt === undefined) return;
|
|
25
|
+
onImageAltTextChange(patch.imageAlt ?? '');
|
|
26
|
+
};
|
|
14
27
|
</script>
|
|
15
28
|
|
|
16
29
|
<VStack gap={10}>
|
|
17
30
|
<TextEditor
|
|
31
|
+
as="h1"
|
|
18
32
|
autosize
|
|
19
33
|
value={draftTitle}
|
|
20
34
|
rows={1}
|
|
21
35
|
spellcheck={true}
|
|
22
36
|
onInput={(event) => onTitleChange((event.currentTarget as HTMLTextAreaElement).value)}
|
|
23
|
-
className="text-4xl leading-tight font-semibold tracking-[-0.03em] text-zinc-950 placeholder:text-zinc-300"
|
|
24
37
|
placeholder="Untitled article"
|
|
25
38
|
/>
|
|
26
39
|
|
|
27
40
|
{#if article.imageURL}
|
|
28
|
-
<
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
/>
|
|
33
|
-
<TextEditor
|
|
34
|
-
autosize
|
|
35
|
-
value={draftImageAltText}
|
|
36
|
-
rows={1}
|
|
37
|
-
onInput={(event) => onImageAltTextChange((event.currentTarget as HTMLTextAreaElement).value)}
|
|
38
|
-
className="article-editor-hero-description"
|
|
39
|
-
placeholder="Image description"
|
|
41
|
+
<Image
|
|
42
|
+
block={heroImageBlock}
|
|
43
|
+
titleFallback={draftTitle || article.title}
|
|
44
|
+
onUpdate={onHeroImageUpdate}
|
|
40
45
|
/>
|
|
41
46
|
{/if}
|
|
42
47
|
</VStack>
|
|
43
|
-
|
|
44
|
-
<style>
|
|
45
|
-
:global(.article-editor-hero-description) {
|
|
46
|
-
border: 0;
|
|
47
|
-
background: transparent;
|
|
48
|
-
padding: 0;
|
|
49
|
-
color: #3f3f46;
|
|
50
|
-
font-size: 0.875rem;
|
|
51
|
-
line-height: 1.5rem;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
:global(.article-editor-hero-description::placeholder) {
|
|
55
|
-
color: #d4d4d8;
|
|
56
|
-
}
|
|
57
|
-
</style>
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import TextEditor from '../../TextEditor';
|
|
3
|
+
import type { TextAs } from '../../../../style/text';
|
|
3
4
|
import type { BlockDraft } from '../types.js';
|
|
4
5
|
|
|
5
6
|
let {
|
|
@@ -21,9 +22,15 @@
|
|
|
21
22
|
focusPosition?: number | null;
|
|
22
23
|
onFocused?: () => void;
|
|
23
24
|
}>();
|
|
25
|
+
|
|
26
|
+
const headingAs = $derived.by<TextAs>(() => {
|
|
27
|
+
const level = Math.min(6, Math.max(1, block.level ?? 2));
|
|
28
|
+
return `h${level}` as TextAs;
|
|
29
|
+
});
|
|
24
30
|
</script>
|
|
25
31
|
|
|
26
32
|
<TextEditor
|
|
33
|
+
as={headingAs}
|
|
27
34
|
autosize
|
|
28
35
|
rows={1}
|
|
29
36
|
value={block.text ?? ''}
|
|
@@ -62,12 +69,5 @@
|
|
|
62
69
|
{shouldFocus}
|
|
63
70
|
{focusPosition}
|
|
64
71
|
{onFocused}
|
|
65
|
-
className={`placeholder:text-zinc-300 ${
|
|
66
|
-
Number(block.level ?? 2) <= 1
|
|
67
|
-
? 'text-3xl font-semibold tracking-[-0.03em]'
|
|
68
|
-
: Number(block.level ?? 2) === 2
|
|
69
|
-
? 'text-2xl font-semibold tracking-[-0.025em]'
|
|
70
|
-
: 'text-xl font-semibold'
|
|
71
|
-
}`}
|
|
72
72
|
placeholder="Heading"
|
|
73
73
|
/>
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
+
import Image from '../../Image';
|
|
2
3
|
import TextEditor from '../../TextEditor';
|
|
3
|
-
import
|
|
4
|
+
import VStack from '../../VStack';
|
|
4
5
|
import type { BlockDraft } from '../types.js';
|
|
5
6
|
|
|
6
7
|
let { block, titleFallback, onUpdate } = $props<{
|
|
@@ -10,39 +11,22 @@
|
|
|
10
11
|
}>();
|
|
11
12
|
</script>
|
|
12
13
|
|
|
13
|
-
<
|
|
14
|
-
<
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
value={block.imageAlt ?? ''}
|
|
21
|
-
onInput={(event) =>
|
|
22
|
-
onUpdate(block.id, {
|
|
23
|
-
imageAlt: (event.currentTarget as HTMLTextAreaElement).value
|
|
24
|
-
})}
|
|
25
|
-
placeholder="Alt text"
|
|
26
|
-
/>
|
|
27
|
-
</div>
|
|
28
|
-
</div>
|
|
14
|
+
<VStack gap={10}>
|
|
15
|
+
<Image
|
|
16
|
+
src={block.imageURL}
|
|
17
|
+
alt={block.imageAlt ?? titleFallback}
|
|
18
|
+
fit="cover"
|
|
19
|
+
aspectRatio="4 / 3"
|
|
20
|
+
/>
|
|
29
21
|
|
|
30
|
-
<
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
font-size: 0.875rem;
|
|
42
|
-
line-height: 1.5rem;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
:global(.article-block-image-description::placeholder) {
|
|
46
|
-
color: #d4d4d8;
|
|
47
|
-
}
|
|
48
|
-
</style>
|
|
22
|
+
<TextEditor
|
|
23
|
+
as="paragraph"
|
|
24
|
+
autosize
|
|
25
|
+
rows={1}
|
|
26
|
+
value={block.imageAlt ?? ''}
|
|
27
|
+
onInput={(event) =>
|
|
28
|
+
onUpdate(block.id, {
|
|
29
|
+
imageAlt: (event.currentTarget as HTMLTextAreaElement).value
|
|
30
|
+
})}
|
|
31
|
+
/>
|
|
32
|
+
</VStack>
|
|
@@ -66,6 +66,7 @@
|
|
|
66
66
|
{#each block.items ?? [] as item, index}
|
|
67
67
|
<li class="article-editor-list-item pl-2">
|
|
68
68
|
<TextEditor
|
|
69
|
+
as="paragraph"
|
|
69
70
|
autosize
|
|
70
71
|
rows={1}
|
|
71
72
|
value={item}
|
|
@@ -75,7 +76,6 @@
|
|
|
75
76
|
shouldFocus={focusItemIndex === index}
|
|
76
77
|
focusPosition={focusItemIndex === index ? focusPosition : null}
|
|
77
78
|
{onFocused}
|
|
78
|
-
className="text-[17px] leading-7 text-zinc-700 placeholder:text-zinc-300"
|
|
79
79
|
placeholder="List item"
|
|
80
80
|
/>
|
|
81
81
|
</li>
|
|
@@ -88,6 +88,7 @@
|
|
|
88
88
|
{#each block.items ?? [] as item, index}
|
|
89
89
|
<li class="article-editor-list-item pl-2">
|
|
90
90
|
<TextEditor
|
|
91
|
+
as="paragraph"
|
|
91
92
|
autosize
|
|
92
93
|
rows={1}
|
|
93
94
|
value={item}
|
|
@@ -97,7 +98,6 @@
|
|
|
97
98
|
shouldFocus={focusItemIndex === index}
|
|
98
99
|
focusPosition={focusItemIndex === index ? focusPosition : null}
|
|
99
100
|
{onFocused}
|
|
100
|
-
className="text-[17px] leading-7 text-zinc-700 placeholder:text-zinc-300"
|
|
101
101
|
placeholder="List item"
|
|
102
102
|
/>
|
|
103
103
|
</li>
|
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
</script>
|
|
27
27
|
|
|
28
28
|
<TextEditor
|
|
29
|
+
as="paragraph"
|
|
29
30
|
autosize
|
|
30
31
|
rows={1}
|
|
31
32
|
value={block.text ?? ''}
|
|
@@ -74,6 +75,5 @@
|
|
|
74
75
|
{shouldFocus}
|
|
75
76
|
{focusPosition}
|
|
76
77
|
{onFocused}
|
|
77
|
-
className="text-[17px] leading-8 text-zinc-700 placeholder:text-zinc-300"
|
|
78
78
|
placeholder="Type something thoughtful..."
|
|
79
79
|
/>
|
|
@@ -2,7 +2,6 @@ export { default as Code } from './Code.svelte';
|
|
|
2
2
|
export { default as FAQ } from './FAQ.svelte';
|
|
3
3
|
export { default as Heading } from './Heading.svelte';
|
|
4
4
|
export { default as Image } from './Image.svelte';
|
|
5
|
-
export { default as ImagePreview } from './ImagePreview.svelte';
|
|
6
5
|
export { default as List } from './List.svelte';
|
|
7
6
|
export { default as Paragraph } from './Paragraph.svelte';
|
|
8
7
|
export { default as Table } from './Table.svelte';
|
|
@@ -2,7 +2,6 @@ export { default as Code } from './Code.svelte';
|
|
|
2
2
|
export { default as FAQ } from './FAQ.svelte';
|
|
3
3
|
export { default as Heading } from './Heading.svelte';
|
|
4
4
|
export { default as Image } from './Image.svelte';
|
|
5
|
-
export { default as ImagePreview } from './ImagePreview.svelte';
|
|
6
5
|
export { default as List } from './List.svelte';
|
|
7
6
|
export { default as Paragraph } from './Paragraph.svelte';
|
|
8
7
|
export { default as Table } from './Table.svelte';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script module lang="ts">
|
|
2
2
|
export const demo = {
|
|
3
|
-
name: '
|
|
3
|
+
name: 'Async Button',
|
|
4
4
|
description: 'Async action button with loading and error states.'
|
|
5
5
|
};
|
|
6
6
|
</script>
|
|
@@ -16,8 +16,4 @@
|
|
|
16
16
|
};
|
|
17
17
|
</script>
|
|
18
18
|
|
|
19
|
-
<AsyncButton
|
|
20
|
-
icon={SaveIcon}
|
|
21
|
-
label="Run async action"
|
|
22
|
-
action={runDemo}
|
|
23
|
-
/>
|
|
19
|
+
<AsyncButton icon={SaveIcon} label="Run async action" action={runDemo} />
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
import { CircleAlertIcon } from '@lucide/svelte';
|
|
3
3
|
import type { Component } from 'svelte';
|
|
4
4
|
import type { HTMLButtonAttributes } from 'svelte/elements';
|
|
5
|
-
import { tooltip } from '../../../actions/tooltip';
|
|
6
5
|
import Button from '../Button';
|
|
7
6
|
import Spinner from '../Spinner';
|
|
8
7
|
import { extractStyleProps, type StyleProps } from '../../../style/surface';
|
|
8
|
+
import type { TooltipProps } from '../../../style/tooltip';
|
|
9
9
|
|
|
10
10
|
type Props = {
|
|
11
11
|
icon?: Component<{ class?: string; size?: number | string }>;
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
iconSize?: number | string;
|
|
20
20
|
labelColor?: string;
|
|
21
21
|
} & StyleProps &
|
|
22
|
+
TooltipProps &
|
|
22
23
|
Omit<HTMLButtonAttributes, 'children' | 'onclick' | 'class' | 'style'>;
|
|
23
24
|
|
|
24
25
|
let {
|
|
@@ -32,6 +33,7 @@
|
|
|
32
33
|
iconColor,
|
|
33
34
|
iconSize,
|
|
34
35
|
labelColor,
|
|
36
|
+
tooltip,
|
|
35
37
|
disabled = false,
|
|
36
38
|
type = 'button',
|
|
37
39
|
...restProps
|
|
@@ -48,9 +50,9 @@
|
|
|
48
50
|
const effectiveDisabled = $derived(disabled || (disableWhileLoading && effectiveLoading));
|
|
49
51
|
const buttonStyleProps = $derived({
|
|
50
52
|
...styleProps,
|
|
51
|
-
background: styleProps.background ?? 'var(--sveltely-active-color)',
|
|
52
|
-
borderColor: styleProps.borderColor ?? 'var(--sveltely-active-color)',
|
|
53
|
-
color: styleProps.color ?? 'var(--sveltely-background-color)'
|
|
53
|
+
background: styleProps.background ?? 'var(--sveltely-control-active-color)',
|
|
54
|
+
borderColor: styleProps.borderColor ?? 'var(--sveltely-control-active-color)',
|
|
55
|
+
color: styleProps.color ?? 'var(--sveltely-control-background-color)'
|
|
54
56
|
});
|
|
55
57
|
|
|
56
58
|
const handleClick = async () => {
|
|
@@ -81,6 +83,7 @@
|
|
|
81
83
|
if (error instanceof Error && error.message.trim().length > 0) return error.message;
|
|
82
84
|
return 'Something went wrong';
|
|
83
85
|
});
|
|
86
|
+
const resolvedTooltip = $derived(errorLabel ? { label: errorLabel } : tooltip);
|
|
84
87
|
|
|
85
88
|
const toRem = (value: number | string | undefined) =>
|
|
86
89
|
value === undefined ? undefined : typeof value === 'number' ? `${value}rem` : value;
|
|
@@ -106,10 +109,11 @@
|
|
|
106
109
|
});
|
|
107
110
|
</script>
|
|
108
111
|
|
|
109
|
-
<span
|
|
112
|
+
<span class="async-button">
|
|
110
113
|
<Button
|
|
111
114
|
{type}
|
|
112
115
|
{...buttonStyleProps}
|
|
116
|
+
tooltip={resolvedTooltip}
|
|
113
117
|
disabled={effectiveDisabled}
|
|
114
118
|
aria-busy={effectiveLoading}
|
|
115
119
|
aria-label={variant === 'iconOnly' ? label : undefined}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Component } from 'svelte';
|
|
2
2
|
import type { HTMLButtonAttributes } from 'svelte/elements';
|
|
3
3
|
import { type StyleProps } from '../../../style/surface';
|
|
4
|
+
import type { TooltipProps } from '../../../style/tooltip';
|
|
4
5
|
type Props = {
|
|
5
6
|
icon?: Component<{
|
|
6
7
|
class?: string;
|
|
@@ -15,7 +16,7 @@ type Props = {
|
|
|
15
16
|
iconColor?: string;
|
|
16
17
|
iconSize?: number | string;
|
|
17
18
|
labelColor?: string;
|
|
18
|
-
} & StyleProps & Omit<HTMLButtonAttributes, 'children' | 'onclick' | 'class' | 'style'>;
|
|
19
|
+
} & StyleProps & TooltipProps & Omit<HTMLButtonAttributes, 'children' | 'onclick' | 'class' | 'style'>;
|
|
19
20
|
declare const AsyncButton: Component<Props, {}, "error">;
|
|
20
21
|
type AsyncButton = ReturnType<typeof AsyncButton>;
|
|
21
22
|
export default AsyncButton;
|
|
@@ -1,27 +1,12 @@
|
|
|
1
1
|
<script module lang="ts">
|
|
2
2
|
export const demo = {
|
|
3
3
|
name: 'Button',
|
|
4
|
-
description: '
|
|
5
|
-
columnSpan: 2
|
|
4
|
+
description: 'Basic button component.'
|
|
6
5
|
};
|
|
7
6
|
</script>
|
|
8
7
|
|
|
9
8
|
<script lang="ts">
|
|
10
|
-
import { SaveIcon } from '@lucide/svelte';
|
|
11
9
|
import Button from './Button.svelte';
|
|
12
|
-
import HStack from '../HStack';
|
|
13
10
|
</script>
|
|
14
11
|
|
|
15
|
-
<
|
|
16
|
-
<Button label="Default" />
|
|
17
|
-
<Button
|
|
18
|
-
label="Solid"
|
|
19
|
-
background="var(--sveltely-active-color)"
|
|
20
|
-
borderColor="var(--sveltely-active-color)"
|
|
21
|
-
color="var(--sveltely-background-color)"
|
|
22
|
-
/>
|
|
23
|
-
<Button>
|
|
24
|
-
<SaveIcon />
|
|
25
|
-
<span>With icon</span>
|
|
26
|
-
</Button>
|
|
27
|
-
</HStack>
|
|
12
|
+
<Button label="Button" />
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
export declare const demo: {
|
|
2
2
|
name: string;
|
|
3
3
|
description: string;
|
|
4
|
-
columnSpan: number;
|
|
5
4
|
};
|
|
6
5
|
import Button from './Button.svelte';
|
|
7
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> {
|