@widgetic/design-system 0.5.32 → 0.5.34
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/components/chat/ChatAlertCard.svelte +56 -0
- package/dist/components/chat/ChatAlertCard.svelte.d.ts +12 -0
- package/dist/components/chat/ChatHeader.svelte +5 -3
- package/dist/components/chat/Composer.svelte +8 -2
- package/dist/components/chat/Composer.svelte.d.ts +2 -0
- package/dist/components/chat/SuggestionCard.svelte +3 -2
- package/dist/components/chat/chatHeaderLogic.d.ts +1 -1
- package/dist/components/chat/chatHeaderLogic.js +3 -1
- package/dist/components/chat/composerLogic.d.ts +3 -2
- package/dist/components/chat/composerLogic.js +3 -2
- package/dist/components/chat/index.d.ts +1 -0
- package/dist/components/chat/index.js +2 -0
- package/dist/components/color-picker/ColorPicker.svelte +5 -1
- package/dist/components/color-picker/ColorPicker.svelte.d.ts +2 -0
- package/dist/components/creator/CanvasBoardStatusChip.svelte +62 -0
- package/dist/components/creator/CanvasBoardStatusChip.svelte.d.ts +14 -0
- package/dist/components/creator/CreatorBar.svelte +147 -0
- package/dist/components/creator/CreatorBar.svelte.d.ts +28 -0
- package/dist/components/creator/index.d.ts +3 -0
- package/dist/components/creator/index.js +2 -0
- package/dist/components/index.d.ts +2 -0
- package/dist/components/index.js +1 -0
- package/dist/components/navigation/Breadcrumbs.svelte +15 -4
- package/dist/components/navigation/Breadcrumbs.svelte.d.ts +2 -0
- package/dist/components/navigation/types.d.ts +4 -0
- package/dist/components/shell/AppShell.svelte +16 -4
- package/dist/components/shell/AppShell.svelte.d.ts +1 -0
- package/dist/components/shell/NavSectionLabel.svelte +4 -1
- package/dist/components/shell/SettingsDialog.svelte +6 -1
- package/dist/components/shell/SettingsNav.svelte +11 -3
- package/dist/components/shell/WidgetRow.svelte +2 -2
- package/dist/components/shell/WidgetRow.svelte.d.ts +1 -1
- package/dist/components/toast/ToasterModal.svelte +14 -9
- package/dist/components/toast/ToasterModal.svelte.d.ts +1 -1
- package/dist/components/toast/toastQueue.d.ts +13 -0
- package/dist/components/toast/toastQueue.js +78 -0
- package/dist/styles/global.css +3 -3
- package/dist/styles/tokens.css +19 -7
- package/dist/utils/toastMotion.d.ts +4 -4
- package/dist/utils/toastMotion.js +4 -4
- package/package.json +1 -1
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
Figma Alert (526:3205): the card the chat shows when a reply failed, in place of a red line of text.
|
|
3
|
+
408x86 in the 440px panel: rounded-xl, border, px 16 / py 12, a 16px warning icon, a title (Body/Medium) and a description
|
|
4
|
+
(Body, 90% of the destructive colour), and one outline Small button ("Try again") on the right, 8px below the text's centre.
|
|
5
|
+
Built on the DS Alert (grid with an icon column): the button is a third grid column. The Figma stroke sits inside the frame,
|
|
6
|
+
so the padding is one pixel smaller on every side than the Figma value (the border adds it back).
|
|
7
|
+
-->
|
|
8
|
+
<script lang="ts">
|
|
9
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
10
|
+
import IconAlertTriangle from '@tabler/icons-svelte/icons/alert-triangle';
|
|
11
|
+
import { cn } from '../../utils.js';
|
|
12
|
+
import { Alert, AlertDescription, AlertTitle } from '../ui/alert/index.js';
|
|
13
|
+
import { Button } from '../ui/button/index.js';
|
|
14
|
+
|
|
15
|
+
export type ChatAlertCardProps = HTMLAttributes<HTMLDivElement> & {
|
|
16
|
+
title: string;
|
|
17
|
+
description?: string;
|
|
18
|
+
/** Text of the button; no button when empty. */
|
|
19
|
+
actionLabel?: string;
|
|
20
|
+
onAction?: () => void;
|
|
21
|
+
class?: string;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
let { title, description = '', actionLabel = '', onAction, class: className, ...restProps }: ChatAlertCardProps = $props();
|
|
25
|
+
|
|
26
|
+
/** Whether the card has a button (a label and a handler). */
|
|
27
|
+
const hasAction = $derived(Boolean(actionLabel) && typeof onAction === 'function');
|
|
28
|
+
</script>
|
|
29
|
+
|
|
30
|
+
<Alert
|
|
31
|
+
{...restProps}
|
|
32
|
+
variant="destructive"
|
|
33
|
+
data-testid="chat-alert-card"
|
|
34
|
+
class={cn(
|
|
35
|
+
'w-full gap-x-3 gap-y-0.5 p-[11px] ps-[15px] pe-[15px]',
|
|
36
|
+
hasAction && 'has-[>svg]:grid-cols-[auto_1fr_auto]',
|
|
37
|
+
className
|
|
38
|
+
)}
|
|
39
|
+
>
|
|
40
|
+
<IconAlertTriangle aria-hidden="true" />
|
|
41
|
+
<AlertTitle>{title}</AlertTitle>
|
|
42
|
+
{#if description}
|
|
43
|
+
<AlertDescription class="text-destructive/90">{description}</AlertDescription>
|
|
44
|
+
{/if}
|
|
45
|
+
{#if hasAction}
|
|
46
|
+
<Button
|
|
47
|
+
data-testid="chat-alert-card-action"
|
|
48
|
+
variant="outline"
|
|
49
|
+
size="sm"
|
|
50
|
+
class="col-start-3 row-span-2 row-start-1 mt-2 h-8 self-center"
|
|
51
|
+
onclick={onAction}
|
|
52
|
+
>
|
|
53
|
+
{actionLabel}
|
|
54
|
+
</Button>
|
|
55
|
+
{/if}
|
|
56
|
+
</Alert>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
2
|
+
export type ChatAlertCardProps = HTMLAttributes<HTMLDivElement> & {
|
|
3
|
+
title: string;
|
|
4
|
+
description?: string;
|
|
5
|
+
/** Text of the button; no button when empty. */
|
|
6
|
+
actionLabel?: string;
|
|
7
|
+
onAction?: () => void;
|
|
8
|
+
class?: string;
|
|
9
|
+
};
|
|
10
|
+
declare const ChatAlertCard: import("svelte").Component<ChatAlertCardProps, {}, "">;
|
|
11
|
+
type ChatAlertCard = ReturnType<typeof ChatAlertCard>;
|
|
12
|
+
export default ChatAlertCard;
|
|
@@ -74,7 +74,8 @@
|
|
|
74
74
|
|
|
75
75
|
const messages = $derived({ ...defaultMessages, ...messagesProp });
|
|
76
76
|
const displayTitle = $derived(title?.trim() || messages.newChat);
|
|
77
|
-
const consoleVisible = $derived(shouldShowConsoleButton(showConsole, onToggleConsole));
|
|
77
|
+
const consoleVisible = $derived(shouldShowConsoleButton(showConsole, onToggleConsole, layout));
|
|
78
|
+
const consoleDisabled = $derived(consoleVisible && typeof onToggleConsole !== 'function');
|
|
78
79
|
const pinVisible = $derived(shouldShowPinButton(showConsole, onToggleConsole, onPin));
|
|
79
80
|
</script>
|
|
80
81
|
|
|
@@ -82,7 +83,7 @@
|
|
|
82
83
|
bind:this={ref}
|
|
83
84
|
class={cn(
|
|
84
85
|
'flex h-14 shrink-0 items-center gap-1 px-3',
|
|
85
|
-
layout === 'panel' && 'w-
|
|
86
|
+
layout === 'panel' && 'w-full max-w-full',
|
|
86
87
|
layout === 'fullscreen' && 'max-w-content w-full',
|
|
87
88
|
className
|
|
88
89
|
)}
|
|
@@ -110,7 +111,8 @@
|
|
|
110
111
|
variant="ghost"
|
|
111
112
|
label={messages.console}
|
|
112
113
|
aria-pressed={consoleOpen}
|
|
113
|
-
|
|
114
|
+
disabled={consoleDisabled}
|
|
115
|
+
onclick={() => onToggleConsole?.()}
|
|
114
116
|
>
|
|
115
117
|
<IconTerminal2 class="stroke-2" />
|
|
116
118
|
</IconButton>
|
|
@@ -33,6 +33,8 @@
|
|
|
33
33
|
messages?: Partial<ComposerMessages>;
|
|
34
34
|
onSend?: (text: string) => void;
|
|
35
35
|
onStop?: () => void;
|
|
36
|
+
/** Figma side panel uses arrow-up on the primary send control; default is paper-plane. */
|
|
37
|
+
sendIcon?: 'send' | 'arrow-up';
|
|
36
38
|
leading?: Snippet;
|
|
37
39
|
trailing?: Snippet;
|
|
38
40
|
attachments?: Snippet;
|
|
@@ -43,6 +45,7 @@
|
|
|
43
45
|
import IconCheck from '@tabler/icons-svelte/icons/check';
|
|
44
46
|
import IconChevronDown from '@tabler/icons-svelte/icons/chevron-down';
|
|
45
47
|
import IconPlayerStop from '@tabler/icons-svelte/icons/player-stop';
|
|
48
|
+
import IconArrowUp from '@tabler/icons-svelte/icons/arrow-up';
|
|
46
49
|
import IconSend from '@tabler/icons-svelte/icons/send';
|
|
47
50
|
import { cn } from '../../utils.js';
|
|
48
51
|
import { Button } from '../ui/button/index.js';
|
|
@@ -77,6 +80,7 @@
|
|
|
77
80
|
messages: messagesProp,
|
|
78
81
|
onSend,
|
|
79
82
|
onStop,
|
|
83
|
+
sendIcon = 'send',
|
|
80
84
|
leading,
|
|
81
85
|
trailing,
|
|
82
86
|
attachments,
|
|
@@ -138,7 +142,7 @@
|
|
|
138
142
|
<div
|
|
139
143
|
bind:this={ref}
|
|
140
144
|
class={cn(
|
|
141
|
-
'max-w-content rounded-card border-input bg-background flex w-full flex-col gap-2 border p-
|
|
145
|
+
'max-w-content rounded-card border-input bg-background flex w-full flex-col gap-2 border p-[11px]',
|
|
142
146
|
disabled && 'pointer-events-none opacity-50',
|
|
143
147
|
className
|
|
144
148
|
)}
|
|
@@ -153,7 +157,7 @@
|
|
|
153
157
|
bind:this={textareaRef}
|
|
154
158
|
bind:value
|
|
155
159
|
class="text-body text-foreground placeholder:text-muted-foreground block w-full resize-none overflow-y-auto border-0 bg-transparent outline-hidden focus-visible:outline-hidden disabled:cursor-not-allowed"
|
|
156
|
-
style="min-height:
|
|
160
|
+
style="min-height: 2.75rem; max-height: 7.5rem;"
|
|
157
161
|
{placeholder}
|
|
158
162
|
{disabled}
|
|
159
163
|
aria-invalid={overLimit ? true : undefined}
|
|
@@ -221,6 +225,8 @@
|
|
|
221
225
|
>
|
|
222
226
|
{#if busy}
|
|
223
227
|
<IconPlayerStop class="size-4 stroke-2" aria-hidden="true" />
|
|
228
|
+
{:else if sendIcon === 'arrow-up'}
|
|
229
|
+
<IconArrowUp class="size-4 stroke-2" aria-hidden="true" />
|
|
224
230
|
{:else}
|
|
225
231
|
<IconSend class="size-4 stroke-2" aria-hidden="true" />
|
|
226
232
|
{/if}
|
|
@@ -26,6 +26,8 @@ export type ComposerProps = HTMLAttributes<HTMLDivElement> & {
|
|
|
26
26
|
messages?: Partial<ComposerMessages>;
|
|
27
27
|
onSend?: (text: string) => void;
|
|
28
28
|
onStop?: () => void;
|
|
29
|
+
/** Figma side panel uses arrow-up on the primary send control; default is paper-plane. */
|
|
30
|
+
sendIcon?: 'send' | 'arrow-up';
|
|
29
31
|
leading?: Snippet;
|
|
30
32
|
trailing?: Snippet;
|
|
31
33
|
attachments?: Snippet;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<!--
|
|
2
|
-
Figma: Suggestion Card (component set 48:3, page Suggestion Card)
|
|
2
|
+
Figma: Suggestion Card (component set 48:3, page Suggestion Card). The Figma stroke sits inside the frame, so the padding is 15/11 plus the 1px
|
|
3
|
+
border (16/12 in Figma): a card is 44 tall (76 with a two-line description), as in the frames.
|
|
3
4
|
-->
|
|
4
5
|
<script lang="ts">
|
|
5
6
|
import type { Snippet } from 'svelte';
|
|
@@ -57,7 +58,7 @@
|
|
|
57
58
|
disabled={disabled || undefined}
|
|
58
59
|
title={disabled ? messages.unavailable : undefined}
|
|
59
60
|
class={cn(
|
|
60
|
-
'group rounded-card border-border bg-card duration-fast flex w-full max-w-full items-center gap-3 border px-
|
|
61
|
+
'group rounded-card border-border bg-card duration-fast flex w-full max-w-full items-center gap-3 border px-[15px] py-[11px] text-start transition-colors',
|
|
61
62
|
'hover:bg-accent focus-visible:ring-ring focus-visible:ring-offset-background focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-hidden',
|
|
62
63
|
'disabled:pointer-events-none disabled:opacity-50',
|
|
63
64
|
className
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Whether the chat header shows the debug console control instead of the pin control.
|
|
3
3
|
*/
|
|
4
|
-
export declare function shouldShowConsoleButton(showConsole: boolean, onToggleConsole?: (() => void) | null): boolean;
|
|
4
|
+
export declare function shouldShowConsoleButton(showConsole: boolean, onToggleConsole?: (() => void) | null, layout?: 'panel' | 'fullscreen'): boolean;
|
|
5
5
|
/**
|
|
6
6
|
* Pin stays available for hosts that still use it; hidden when the console control is shown.
|
|
7
7
|
*/
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Whether the chat header shows the debug console control instead of the pin control.
|
|
3
3
|
*/
|
|
4
|
-
export function shouldShowConsoleButton(showConsole, onToggleConsole) {
|
|
4
|
+
export function shouldShowConsoleButton(showConsole, onToggleConsole, layout = 'fullscreen') {
|
|
5
|
+
if (layout === 'panel' && showConsole)
|
|
6
|
+
return true;
|
|
5
7
|
return showConsole && typeof onToggleConsole === 'function';
|
|
6
8
|
}
|
|
7
9
|
/**
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/** Max auto-grow height for the composer textarea (matches product chat input). */
|
|
2
2
|
export declare const COMPOSER_TEXTAREA_MAX_HEIGHT_PX = 120;
|
|
3
|
-
/** Initial textarea
|
|
4
|
-
|
|
3
|
+
/** Initial textarea height: the Figma Composer default tree has a 48px text frame with 4px of padding on top, so 44px of
|
|
4
|
+
* text area (the composer is then 112px: 2px border + 22px padding + 48 + 8 gap + 32 footer). */
|
|
5
|
+
export declare const COMPOSER_TEXTAREA_MIN_HEIGHT_PX = 44;
|
|
5
6
|
/** Whether Enter should submit (Shift+Enter inserts a newline; IME composition must not send). */
|
|
6
7
|
export declare function shouldSendOnKeyDown(key: string, shiftKey: boolean, isComposing: boolean): boolean;
|
|
7
8
|
/** Clamp measured scroll height between min and max for autosize. */
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/** Max auto-grow height for the composer textarea (matches product chat input). */
|
|
2
2
|
export const COMPOSER_TEXTAREA_MAX_HEIGHT_PX = 120;
|
|
3
|
-
/** Initial textarea
|
|
4
|
-
|
|
3
|
+
/** Initial textarea height: the Figma Composer default tree has a 48px text frame with 4px of padding on top, so 44px of
|
|
4
|
+
* text area (the composer is then 112px: 2px border + 22px padding + 48 + 8 gap + 32 footer). */
|
|
5
|
+
export const COMPOSER_TEXTAREA_MIN_HEIGHT_PX = 44;
|
|
5
6
|
/** Whether Enter should submit (Shift+Enter inserts a newline; IME composition must not send). */
|
|
6
7
|
export function shouldSendOnKeyDown(key, shiftKey, isComposing) {
|
|
7
8
|
if (isComposing)
|
|
@@ -2,6 +2,7 @@ export { Chip } from '../ui/chip';
|
|
|
2
2
|
export { IconButton } from '../ui/icon-button';
|
|
3
3
|
export { default as Composer, type ComposerMessages, type ComposerProps } from './Composer.svelte';
|
|
4
4
|
export { default as Message, type MessageMessages, type MessageProps, type MessageRole } from './Message.svelte';
|
|
5
|
+
export { default as ChatAlertCard, type ChatAlertCardProps } from './ChatAlertCard.svelte';
|
|
5
6
|
export { default as ActivityRow, type ActivityRowProps, type ActivityRowStatus } from './ActivityRow.svelte';
|
|
6
7
|
export { default as OptionRow, type OptionRowProps, type OptionRowSelectionMode } from './OptionRow.svelte';
|
|
7
8
|
export { default as TaskRow, type TaskRowProps, type TaskRowStatus } from './TaskRow.svelte';
|
|
@@ -6,6 +6,8 @@ export { Chip } from '../ui/chip';
|
|
|
6
6
|
export { IconButton } from '../ui/icon-button';
|
|
7
7
|
export { default as Composer } from './Composer.svelte';
|
|
8
8
|
export { default as Message } from './Message.svelte';
|
|
9
|
+
// The card a failed reply is shown in (Figma Alert 526:3205), with its "Try again" button.
|
|
10
|
+
export { default as ChatAlertCard } from './ChatAlertCard.svelte';
|
|
9
11
|
export { default as ActivityRow } from './ActivityRow.svelte';
|
|
10
12
|
export { default as OptionRow } from './OptionRow.svelte';
|
|
11
13
|
export { default as TaskRow } from './TaskRow.svelte';
|
|
@@ -42,6 +42,8 @@
|
|
|
42
42
|
onConfirm?: (hex: string) => void;
|
|
43
43
|
/** Called with `#RRGGBB` every time the colour changes, while the person drags or types. */
|
|
44
44
|
onChange?: (hex: string) => void;
|
|
45
|
+
/** Live preview while dragging or typing; same timing as `onChange`, for callers that prefer an input-style name. */
|
|
46
|
+
onInput?: (hex: string) => void;
|
|
45
47
|
messages?: Partial<ColorPickerMessages>;
|
|
46
48
|
};
|
|
47
49
|
</script>
|
|
@@ -87,6 +89,7 @@
|
|
|
87
89
|
showConfirm = true,
|
|
88
90
|
onConfirm,
|
|
89
91
|
onChange,
|
|
92
|
+
onInput,
|
|
90
93
|
messages: messagesProp,
|
|
91
94
|
...restProps
|
|
92
95
|
}: ColorPickerProps = $props();
|
|
@@ -135,6 +138,7 @@
|
|
|
135
138
|
if (!keepTyped) hexText = hex;
|
|
136
139
|
value = hex;
|
|
137
140
|
onChange?.(hex);
|
|
141
|
+
onInput?.(hex);
|
|
138
142
|
}
|
|
139
143
|
|
|
140
144
|
// ---- saturation and brightness area
|
|
@@ -240,7 +244,7 @@
|
|
|
240
244
|
<div class={cn('flex w-full flex-col', className)} {...restProps}>
|
|
241
245
|
<div class="flex flex-col gap-3 p-3">
|
|
242
246
|
{#if shownSwatches.length > 0}
|
|
243
|
-
<div class="flex gap-2">
|
|
247
|
+
<div class="flex w-full justify-start gap-2" dir="ltr">
|
|
244
248
|
{#each shownSwatches as swatch (swatch)}
|
|
245
249
|
<button
|
|
246
250
|
type="button"
|
|
@@ -27,6 +27,8 @@ export type ColorPickerProps = Omit<HTMLAttributes<HTMLDivElement>, 'children'>
|
|
|
27
27
|
onConfirm?: (hex: string) => void;
|
|
28
28
|
/** Called with `#RRGGBB` every time the colour changes, while the person drags or types. */
|
|
29
29
|
onChange?: (hex: string) => void;
|
|
30
|
+
/** Live preview while dragging or typing; same timing as `onChange`, for callers that prefer an input-style name. */
|
|
31
|
+
onInput?: (hex: string) => void;
|
|
30
32
|
messages?: Partial<ColorPickerMessages>;
|
|
31
33
|
};
|
|
32
34
|
declare const ColorPicker: import("svelte").Component<ColorPickerProps, {}, "value">;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
Figma Generation Chip (Ready 177x28 / Generating / Failed 347x40), centred 16px under the top of the sketch canvas.
|
|
3
|
+
One pill: pl-3 pr-1 py-1, gap 8, a 16px icon, the label in Body/Medium (14/20), an optional action button (32px, Figma "action")
|
|
4
|
+
and the Shadow/Floating shadow. The Figma stroke sits inside the frame, so the border is part of the 4px padding (no extra size).
|
|
5
|
+
-->
|
|
6
|
+
<script lang="ts">
|
|
7
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
8
|
+
import IconCircleCheck from '@tabler/icons-svelte/icons/circle-check';
|
|
9
|
+
import IconLoader2 from '@tabler/icons-svelte/icons/loader-2';
|
|
10
|
+
import IconAlertTriangle from '@tabler/icons-svelte/icons/alert-triangle';
|
|
11
|
+
import { cn } from '../../utils.js';
|
|
12
|
+
import { Button } from '../ui/button/index.js';
|
|
13
|
+
|
|
14
|
+
export type CanvasBoardStatusChipVariant = 'ready' | 'generating' | 'failed';
|
|
15
|
+
|
|
16
|
+
type Props = HTMLAttributes<HTMLDivElement> & {
|
|
17
|
+
variant: CanvasBoardStatusChipVariant;
|
|
18
|
+
label: string;
|
|
19
|
+
/** Text of the action button inside the chip (Figma "Customize" on Ready, "Try again" on Failed); no button when empty. */
|
|
20
|
+
actionLabel?: string;
|
|
21
|
+
/** Click handler of the action button; the chip takes pointer events only when it has an action. */
|
|
22
|
+
onAction?: () => void;
|
|
23
|
+
class?: string;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
let { variant, label, actionLabel = '', onAction, class: className, ...restProps }: Props = $props();
|
|
27
|
+
|
|
28
|
+
/** Whether the chip carries an action button (and so must receive clicks). */
|
|
29
|
+
const hasAction = $derived(Boolean(actionLabel) && typeof onAction === 'function');
|
|
30
|
+
</script>
|
|
31
|
+
|
|
32
|
+
<div
|
|
33
|
+
{...restProps}
|
|
34
|
+
data-testid="canvas-board-status-chip"
|
|
35
|
+
data-variant={variant}
|
|
36
|
+
class={cn(
|
|
37
|
+
'border-border bg-background text-foreground text-body-medium shadow-floating absolute top-4 left-1/2 z-30 flex -translate-x-1/2 items-center gap-2 rounded-full border py-[3px] ps-[11px] pe-[3px]',
|
|
38
|
+
hasAction ? 'pointer-events-auto' : 'pointer-events-none',
|
|
39
|
+
className
|
|
40
|
+
)}
|
|
41
|
+
role="status"
|
|
42
|
+
>
|
|
43
|
+
{#if variant === 'ready'}
|
|
44
|
+
<IconCircleCheck class="text-brand-foreground size-4 shrink-0 stroke-2" aria-hidden="true" />
|
|
45
|
+
{:else if variant === 'generating'}
|
|
46
|
+
<IconLoader2 class="text-muted-foreground size-4 shrink-0 animate-spin stroke-2" aria-hidden="true" />
|
|
47
|
+
{:else}
|
|
48
|
+
<IconAlertTriangle class="text-destructive size-4 shrink-0 stroke-2" aria-hidden="true" />
|
|
49
|
+
{/if}
|
|
50
|
+
<span class="whitespace-nowrap">{label}</span>
|
|
51
|
+
{#if hasAction}
|
|
52
|
+
<Button
|
|
53
|
+
data-testid="canvas-board-status-chip-action"
|
|
54
|
+
variant="ghost"
|
|
55
|
+
size="sm"
|
|
56
|
+
class="h-8 shrink-0"
|
|
57
|
+
onclick={onAction}
|
|
58
|
+
>
|
|
59
|
+
{actionLabel}
|
|
60
|
+
</Button>
|
|
61
|
+
{/if}
|
|
62
|
+
</div>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
2
|
+
export type CanvasBoardStatusChipVariant = 'ready' | 'generating' | 'failed';
|
|
3
|
+
type Props = HTMLAttributes<HTMLDivElement> & {
|
|
4
|
+
variant: CanvasBoardStatusChipVariant;
|
|
5
|
+
label: string;
|
|
6
|
+
/** Text of the action button inside the chip (Figma "Customize" on Ready, "Try again" on Failed); no button when empty. */
|
|
7
|
+
actionLabel?: string;
|
|
8
|
+
/** Click handler of the action button; the chip takes pointer events only when it has an action. */
|
|
9
|
+
onAction?: () => void;
|
|
10
|
+
class?: string;
|
|
11
|
+
};
|
|
12
|
+
declare const CanvasBoardStatusChip: import("svelte").Component<Props, {}, "">;
|
|
13
|
+
type CanvasBoardStatusChip = ReturnType<typeof CanvasBoardStatusChip>;
|
|
14
|
+
export default CanvasBoardStatusChip;
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
Figma: Creator Bar (component set 514:43, node 514:43)
|
|
3
|
+
-->
|
|
4
|
+
<script lang="ts">
|
|
5
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
6
|
+
import type { Snippet } from 'svelte';
|
|
7
|
+
import IconChevronDown from '@tabler/icons-svelte/icons/chevron-down';
|
|
8
|
+
import IconArrowLeft from '@tabler/icons-svelte/icons/arrow-left';
|
|
9
|
+
import IconAdjustments from '@tabler/icons-svelte/icons/adjustments-horizontal';
|
|
10
|
+
import IconLink from '@tabler/icons-svelte/icons/link';
|
|
11
|
+
import { cn } from '../../utils.js';
|
|
12
|
+
import { Button } from '../ui/button/index.js';
|
|
13
|
+
import { IconButton } from '../ui/icon-button/index.js';
|
|
14
|
+
|
|
15
|
+
export type CreatorBarStatus = string;
|
|
16
|
+
|
|
17
|
+
type Props = HTMLAttributes<HTMLElement> & {
|
|
18
|
+
ref?: HTMLElement | null;
|
|
19
|
+
class?: string;
|
|
20
|
+
title: string;
|
|
21
|
+
/** e.g. "Draft" / "Saved" — Figma Caption/Default, muted */
|
|
22
|
+
status?: string;
|
|
23
|
+
showStatus?: boolean;
|
|
24
|
+
showLiveBadge?: boolean;
|
|
25
|
+
liveLabel?: string;
|
|
26
|
+
showPublish?: boolean;
|
|
27
|
+
publishLabel?: string;
|
|
28
|
+
publishDisabled?: boolean;
|
|
29
|
+
showCustomize?: boolean;
|
|
30
|
+
customizeLabel?: string;
|
|
31
|
+
onBack?: () => void;
|
|
32
|
+
onTitleClick?: () => void;
|
|
33
|
+
onPublish?: () => void;
|
|
34
|
+
onCustomize?: () => void;
|
|
35
|
+
/** Figma: title row always shows ▾ when a sketch menu is available, even before an action is wired. */
|
|
36
|
+
showTitleChevron?: boolean;
|
|
37
|
+
trailing?: Snippet;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
let {
|
|
41
|
+
ref = $bindable(null),
|
|
42
|
+
class: className,
|
|
43
|
+
title,
|
|
44
|
+
status = 'Draft',
|
|
45
|
+
showStatus = true,
|
|
46
|
+
showLiveBadge = false,
|
|
47
|
+
liveLabel = 'Live',
|
|
48
|
+
showPublish = false,
|
|
49
|
+
publishLabel = 'Publish',
|
|
50
|
+
publishDisabled = false,
|
|
51
|
+
showCustomize = false,
|
|
52
|
+
customizeLabel = 'Customize',
|
|
53
|
+
onBack,
|
|
54
|
+
onTitleClick,
|
|
55
|
+
onPublish,
|
|
56
|
+
onCustomize,
|
|
57
|
+
showTitleChevron = false,
|
|
58
|
+
trailing,
|
|
59
|
+
...restProps
|
|
60
|
+
}: Props = $props();
|
|
61
|
+
|
|
62
|
+
const titleIsInteractive = $derived(Boolean(onTitleClick) || showTitleChevron);
|
|
63
|
+
</script>
|
|
64
|
+
|
|
65
|
+
<header
|
|
66
|
+
bind:this={ref}
|
|
67
|
+
data-testid="creator-bar"
|
|
68
|
+
data-creator-bar
|
|
69
|
+
class={cn(
|
|
70
|
+
'border-border flex h-14 shrink-0 items-center gap-2 px-4 py-3',
|
|
71
|
+
'[--creator-bar-btn-h:2rem]',
|
|
72
|
+
className
|
|
73
|
+
)}
|
|
74
|
+
{...restProps}
|
|
75
|
+
>
|
|
76
|
+
{#if onBack}
|
|
77
|
+
<IconButton data-testid="creator-bar-back" variant="ghost" size="default" class="size-8 shrink-0" label="Back" onclick={onBack}>
|
|
78
|
+
<IconArrowLeft class="size-4 stroke-2" />
|
|
79
|
+
</IconButton>
|
|
80
|
+
{/if}
|
|
81
|
+
|
|
82
|
+
{#if titleIsInteractive}
|
|
83
|
+
<Button
|
|
84
|
+
data-testid="creator-bar-title"
|
|
85
|
+
variant="ghost"
|
|
86
|
+
size="sm"
|
|
87
|
+
class="h-8 max-w-[min(100%,14rem)] shrink-0 gap-1 px-2"
|
|
88
|
+
onclick={onTitleClick}
|
|
89
|
+
disabled={!onTitleClick}
|
|
90
|
+
>
|
|
91
|
+
<span class="truncate">{title}</span>
|
|
92
|
+
<IconChevronDown class="size-4 shrink-0 stroke-2" aria-hidden="true" />
|
|
93
|
+
</Button>
|
|
94
|
+
{:else}
|
|
95
|
+
<span class="text-body-medium max-w-[min(100%,14rem)] truncate px-2">{title}</span>
|
|
96
|
+
{/if}
|
|
97
|
+
|
|
98
|
+
{#if showLiveBadge}
|
|
99
|
+
<span
|
|
100
|
+
data-testid="creator-bar-live-badge"
|
|
101
|
+
class="bg-brand-subtle text-brand-foreground text-caption-medium inline-flex h-5 shrink-0 items-center gap-1.5 rounded-full px-2"
|
|
102
|
+
>
|
|
103
|
+
<span class="bg-brand-foreground size-1.5 shrink-0 rounded-full" aria-hidden="true"></span>
|
|
104
|
+
<span class="text-caption-medium">{liveLabel}</span>
|
|
105
|
+
</span>
|
|
106
|
+
{/if}
|
|
107
|
+
|
|
108
|
+
{#if showStatus && status}
|
|
109
|
+
<span data-testid="creator-bar-status" class="text-caption text-muted-foreground shrink-0 whitespace-nowrap">{status}</span>
|
|
110
|
+
{/if}
|
|
111
|
+
|
|
112
|
+
<span class="min-w-0 flex-1" aria-hidden="true"></span>
|
|
113
|
+
|
|
114
|
+
<!--
|
|
115
|
+
Figma 514:69 (Customize) and 514:84 (Publish) are Button Small: h 32, padding 8 and a label box of 4 (so text + 40 with the
|
|
116
|
+
icon, text + 24 without), text 14/20 medium, radius 8, border `input`. The design system's `Button size="sm"` draws exactly
|
|
117
|
+
that, so the buttons stay the design system's Button; no gap or padding is overridden here (a `gap-1.5` made Customize 2px
|
|
118
|
+
wider than Figma) and no colour is written by hand.
|
|
119
|
+
-->
|
|
120
|
+
{#if showCustomize && onCustomize}
|
|
121
|
+
<Button data-testid="creator-bar-customize" variant="outline" size="sm" class="h-8 shrink-0" onclick={onCustomize}>
|
|
122
|
+
{#if showLiveBadge}
|
|
123
|
+
<IconLink class="size-4 shrink-0 stroke-[1.75]" aria-hidden="true" />
|
|
124
|
+
{:else}
|
|
125
|
+
<IconAdjustments class="size-4 shrink-0 stroke-[1.75]" aria-hidden="true" />
|
|
126
|
+
{/if}
|
|
127
|
+
{customizeLabel}
|
|
128
|
+
</Button>
|
|
129
|
+
{/if}
|
|
130
|
+
|
|
131
|
+
{#if showPublish && onPublish}
|
|
132
|
+
<Button
|
|
133
|
+
data-testid="creator-bar-publish"
|
|
134
|
+
variant="default"
|
|
135
|
+
size="sm"
|
|
136
|
+
class="h-8 shrink-0"
|
|
137
|
+
disabled={publishDisabled}
|
|
138
|
+
onclick={onPublish}
|
|
139
|
+
>
|
|
140
|
+
{publishLabel}
|
|
141
|
+
</Button>
|
|
142
|
+
{/if}
|
|
143
|
+
|
|
144
|
+
{#if trailing}
|
|
145
|
+
{@render trailing()}
|
|
146
|
+
{/if}
|
|
147
|
+
</header>
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
export type CreatorBarStatus = string;
|
|
4
|
+
type Props = HTMLAttributes<HTMLElement> & {
|
|
5
|
+
ref?: HTMLElement | null;
|
|
6
|
+
class?: string;
|
|
7
|
+
title: string;
|
|
8
|
+
/** e.g. "Draft" / "Saved" — Figma Caption/Default, muted */
|
|
9
|
+
status?: string;
|
|
10
|
+
showStatus?: boolean;
|
|
11
|
+
showLiveBadge?: boolean;
|
|
12
|
+
liveLabel?: string;
|
|
13
|
+
showPublish?: boolean;
|
|
14
|
+
publishLabel?: string;
|
|
15
|
+
publishDisabled?: boolean;
|
|
16
|
+
showCustomize?: boolean;
|
|
17
|
+
customizeLabel?: string;
|
|
18
|
+
onBack?: () => void;
|
|
19
|
+
onTitleClick?: () => void;
|
|
20
|
+
onPublish?: () => void;
|
|
21
|
+
onCustomize?: () => void;
|
|
22
|
+
/** Figma: title row always shows ▾ when a sketch menu is available, even before an action is wired. */
|
|
23
|
+
showTitleChevron?: boolean;
|
|
24
|
+
trailing?: Snippet;
|
|
25
|
+
};
|
|
26
|
+
declare const CreatorBar: import("svelte").Component<Props, {}, "ref">;
|
|
27
|
+
type CreatorBar = ReturnType<typeof CreatorBar>;
|
|
28
|
+
export default CreatorBar;
|
|
@@ -5,6 +5,8 @@ export { default as PasswordInput } from './PasswordInput.svelte';
|
|
|
5
5
|
export { default as ThumbHashImage } from './ThumbHashImage.svelte';
|
|
6
6
|
export { default as WScrollArea } from './WScrollArea.svelte';
|
|
7
7
|
export { Composer, type ComposerMessages, type ComposerProps, Message, type MessageMessages, type MessageProps, type MessageRole, ActivityRow, type ActivityRowProps, type ActivityRowStatus, OptionRow, type OptionRowProps, type OptionRowSelectionMode, TaskRow, type TaskRowProps, type TaskRowStatus, ScrollToBottom, type ScrollToBottomProps, canSendText, clampTextareaHeight, shouldSendOnKeyDown, ChatHeader, PlanCard, QuestionCard, canSubmitQuestion, formatQuestionStep, isFirstQuestion, isLastQuestion, moveFocusedIndex, optionItemRole, primaryQuestionLabel, selectionRole, toggleOption, SuggestionCard } from './chat';
|
|
8
|
+
export { CreatorBar, CanvasBoardStatusChip } from './creator';
|
|
9
|
+
export type { CanvasBoardStatusChipVariant } from './creator';
|
|
8
10
|
export { ColorPicker, type ColorPickerMessages, type ColorPickerProps, normalizeHex, hexToHsv, hsvToHex, type Hsv } from './color-picker';
|
|
9
11
|
export { default as DebugGrid } from './debug-grid/DebugGrid.svelte';
|
|
10
12
|
export { FontPicker, type FontPickerMessages, type FontPickerProps, filterFonts, fontFamilyCss, type FontPickerFont } from './font-picker';
|
package/dist/components/index.js
CHANGED
|
@@ -6,6 +6,7 @@ export { default as PasswordInput } from './PasswordInput.svelte';
|
|
|
6
6
|
export { default as ThumbHashImage } from './ThumbHashImage.svelte';
|
|
7
7
|
export { default as WScrollArea } from './WScrollArea.svelte';
|
|
8
8
|
export { Composer, Message, ActivityRow, OptionRow, TaskRow, ScrollToBottom, canSendText, clampTextareaHeight, shouldSendOnKeyDown, ChatHeader, PlanCard, QuestionCard, canSubmitQuestion, formatQuestionStep, isFirstQuestion, isLastQuestion, moveFocusedIndex, optionItemRole, primaryQuestionLabel, selectionRole, toggleOption, SuggestionCard } from './chat';
|
|
9
|
+
export { CreatorBar, CanvasBoardStatusChip } from './creator';
|
|
9
10
|
export { ColorPicker, normalizeHex, hexToHsv, hsvToHex } from './color-picker';
|
|
10
11
|
export { default as DebugGrid } from './debug-grid/DebugGrid.svelte';
|
|
11
12
|
export { FontPicker, filterFonts, fontFamilyCss } from './font-picker';
|
|
@@ -52,6 +52,9 @@
|
|
|
52
52
|
export let onForward: BreadcrumbsProps['onForward'] = () => {};
|
|
53
53
|
// debug settings
|
|
54
54
|
export let showDebugVisualizer: boolean = false;
|
|
55
|
+
/** When true, ancestor crumbs are valid folder drop targets for the file browser. */
|
|
56
|
+
export let enableFolderDropTargets: boolean = false;
|
|
57
|
+
export let rootDropTargetId: string = 'root';
|
|
55
58
|
|
|
56
59
|
// A name a visitor wrote keeps a direction of its own on a right to left screen (a Latin folder name reads left to
|
|
57
60
|
// right inside it); on a left to right screen no attribute is written and nothing changes.
|
|
@@ -294,7 +297,10 @@
|
|
|
294
297
|
<Breadcrumb.Item class="shrink-0">
|
|
295
298
|
{#if currentPath.length === 0}
|
|
296
299
|
<!-- At the root the root crumb is the page you are on (Figma Crumbs Depth=Root: foreground) -->
|
|
297
|
-
<span
|
|
300
|
+
<span
|
|
301
|
+
class="{crumbTextClass} text-foreground whitespace-nowrap rounded-md px-1"
|
|
302
|
+
aria-current="page"
|
|
303
|
+
>
|
|
298
304
|
{rootLabel}
|
|
299
305
|
</span>
|
|
300
306
|
{:else}
|
|
@@ -302,8 +308,9 @@
|
|
|
302
308
|
<span
|
|
303
309
|
role="link"
|
|
304
310
|
tabindex="0"
|
|
305
|
-
class="{crumbTextClass} text-muted-foreground hover:text-foreground cursor-pointer whitespace-nowrap transition-
|
|
311
|
+
class="{crumbTextClass} text-muted-foreground hover:text-foreground cursor-pointer whitespace-nowrap rounded-md px-1 transition-all duration-fast hover:underline data-[folder-drop-hover=true]:bg-accent data-[folder-drop-hover=true]:text-foreground data-[folder-drop-hover=true]:ring-2 data-[folder-drop-hover=true]:ring-brand"
|
|
306
312
|
class:opacity-50={isLoading}
|
|
313
|
+
data-folder-drop-target={enableFolderDropTargets ? rootDropTargetId : undefined}
|
|
307
314
|
style="pointer-events: {isLoading ? 'none' : 'auto'};"
|
|
308
315
|
on:click={(e) => handleClick(e, -1)}
|
|
309
316
|
on:keydown={(e) => handleKeyDown(e, -1)}
|
|
@@ -357,8 +364,11 @@
|
|
|
357
364
|
dir={nameDirection}
|
|
358
365
|
role="link"
|
|
359
366
|
tabindex="0"
|
|
360
|
-
class="{crumbTextClass} text-muted-foreground hover:text-foreground cursor-pointer transition-
|
|
367
|
+
class="{crumbTextClass} text-muted-foreground hover:text-foreground cursor-pointer rounded-md px-1 transition-all duration-fast hover:underline data-[folder-drop-hover=true]:bg-accent data-[folder-drop-hover=true]:text-foreground data-[folder-drop-hover=true]:ring-2 data-[folder-drop-hover=true]:ring-brand"
|
|
361
368
|
class:opacity-50={isLoading}
|
|
369
|
+
data-folder-drop-target={enableFolderDropTargets
|
|
370
|
+
? currentPath[currentPath.length - itemsToShow + 1 + index]
|
|
371
|
+
: undefined}
|
|
362
372
|
style="pointer-events: {isLoading ? 'none' : 'auto'};"
|
|
363
373
|
on:click={(e) => handleClick(e, currentPath.length - itemsToShow + 1 + index)}
|
|
364
374
|
on:keydown={(e) =>
|
|
@@ -383,8 +393,9 @@
|
|
|
383
393
|
dir={nameDirection}
|
|
384
394
|
role="link"
|
|
385
395
|
tabindex="0"
|
|
386
|
-
class="{crumbTextClass} text-muted-foreground hover:text-foreground cursor-pointer transition-
|
|
396
|
+
class="{crumbTextClass} text-muted-foreground hover:text-foreground cursor-pointer rounded-md px-1 transition-all duration-fast hover:underline data-[folder-drop-hover=true]:bg-accent data-[folder-drop-hover=true]:text-foreground data-[folder-drop-hover=true]:ring-2 data-[folder-drop-hover=true]:ring-brand"
|
|
387
397
|
class:opacity-50={isLoading}
|
|
398
|
+
data-folder-drop-target={enableFolderDropTargets ? currentPath[index] : undefined}
|
|
388
399
|
style="pointer-events: {isLoading ? 'none' : 'auto'};"
|
|
389
400
|
on:click={(e) => handleClick(e, index)}
|
|
390
401
|
on:keydown={(e) => handleKeyDown(e, index)}
|
|
@@ -33,6 +33,8 @@ declare const Breadcrumbs: $$__sveltets_2_IsomorphicComponent<{
|
|
|
33
33
|
onBack?: BreadcrumbsProps["onBack"];
|
|
34
34
|
onForward?: BreadcrumbsProps["onForward"];
|
|
35
35
|
showDebugVisualizer?: boolean;
|
|
36
|
+
/** When true, ancestor crumbs are valid folder drop targets for the file browser. */ enableFolderDropTargets?: boolean;
|
|
37
|
+
rootDropTargetId?: string;
|
|
36
38
|
}, {
|
|
37
39
|
[evt: string]: CustomEvent<any>;
|
|
38
40
|
}, {}, {}, string>;
|
|
@@ -19,4 +19,8 @@ export interface BreadcrumbsProps {
|
|
|
19
19
|
breadcrumbLabel?: string;
|
|
20
20
|
/** Figma Crumbs Size=Compact: Heading/Section text and a 4px gap (a narrow header). Default: false (Size=Page). */
|
|
21
21
|
compact?: boolean;
|
|
22
|
+
/** When true, ancestor crumbs accept file-browser drag-to-folder drops (`data-folder-drop-target`). */
|
|
23
|
+
enableFolderDropTargets?: boolean;
|
|
24
|
+
/** Folder id for the root crumb drop target (defaults to `root`). */
|
|
25
|
+
rootDropTargetId?: string;
|
|
22
26
|
}
|
|
@@ -10,6 +10,8 @@
|
|
|
10
10
|
topBarTitle,
|
|
11
11
|
menuLabel = 'Open navigation',
|
|
12
12
|
drawerOpen = $bindable(false),
|
|
13
|
+
/** `panel` (default) = rounded white content card; `plain` = grey field, children supply their own cards (Figma project dashboard). */
|
|
14
|
+
contentSurface = 'panel',
|
|
13
15
|
sidebar,
|
|
14
16
|
children,
|
|
15
17
|
topBarAction
|
|
@@ -18,10 +20,17 @@
|
|
|
18
20
|
topBarTitle: string;
|
|
19
21
|
menuLabel?: string;
|
|
20
22
|
drawerOpen?: boolean;
|
|
23
|
+
contentSurface?: 'panel' | 'plain';
|
|
21
24
|
sidebar?: Snippet;
|
|
22
25
|
children?: Snippet;
|
|
23
26
|
topBarAction?: Snippet;
|
|
24
27
|
} = $props();
|
|
28
|
+
|
|
29
|
+
const contentSurfaceClass = $derived(
|
|
30
|
+
contentSurface === 'plain'
|
|
31
|
+
? 'border-transparent bg-transparent shadow-none rounded-none'
|
|
32
|
+
: 'rounded-panel border-border bg-background border shadow-none'
|
|
33
|
+
);
|
|
25
34
|
</script>
|
|
26
35
|
|
|
27
36
|
<div class={cn('bg-muted flex h-full min-h-screen', className)}>
|
|
@@ -37,10 +46,13 @@
|
|
|
37
46
|
action={topBarAction}
|
|
38
47
|
/>
|
|
39
48
|
|
|
40
|
-
<div
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
49
|
+
<div
|
|
50
|
+
class={cn(
|
|
51
|
+
'flex min-h-0 flex-1 flex-col gap-2 lg:ps-0',
|
|
52
|
+
contentSurface === 'plain' ? 'pt-2 pe-2 pb-2 ps-0' : 'p-2'
|
|
53
|
+
)}
|
|
54
|
+
>
|
|
55
|
+
<div class={cn('flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden', contentSurfaceClass)}>
|
|
44
56
|
{@render children?.()}
|
|
45
57
|
</div>
|
|
46
58
|
</div>
|
|
@@ -17,7 +17,10 @@
|
|
|
17
17
|
</script>
|
|
18
18
|
|
|
19
19
|
<div
|
|
20
|
-
class={cn(
|
|
20
|
+
class={cn(
|
|
21
|
+
'flex h-8 w-full min-w-0 items-center gap-2 px-2 pt-3 pb-1 text-start',
|
|
22
|
+
className
|
|
23
|
+
)}
|
|
21
24
|
{...restProps}
|
|
22
25
|
>
|
|
23
26
|
<span class="text-caption-medium text-muted-foreground min-w-0 flex-1 truncate">{label}</span>
|
|
@@ -114,6 +114,8 @@
|
|
|
114
114
|
// (1) pull the scroll area into that padding and (2) add matching padding-right so the cards stay on the
|
|
115
115
|
// pe-8 line and the bar is centred in the leftover space between the cards and the dialog edge.
|
|
116
116
|
const PANE_RIGHT_PADDING_PX = 32;
|
|
117
|
+
/** Moves the scroll rail toward the dialog edge while the content line stays on pe-8. */
|
|
118
|
+
const SCROLLBAR_SHIFT_TOWARD_EDGE_PX = 8;
|
|
117
119
|
let paneScrollStyle = $state('');
|
|
118
120
|
|
|
119
121
|
function overlayScrollbar(node: HTMLElement) {
|
|
@@ -125,7 +127,10 @@
|
|
|
125
127
|
}
|
|
126
128
|
// Read the real bar width (often ~14px in Chromium, 8px when thin styles apply).
|
|
127
129
|
const barWidth = Math.max(node.offsetWidth - node.clientWidth, 8);
|
|
128
|
-
const outerGap = Math.max(
|
|
130
|
+
const outerGap = Math.max(
|
|
131
|
+
(PANE_RIGHT_PADDING_PX - barWidth) / 2 - SCROLLBAR_SHIFT_TOWARD_EDGE_PX,
|
|
132
|
+
0
|
|
133
|
+
);
|
|
129
134
|
const pull = PANE_RIGHT_PADDING_PX - outerGap;
|
|
130
135
|
// End side, not the right: the bar sits at the inline end of the page, so a dialog read right to left mirrors it
|
|
131
136
|
// (tests/rtl/sourcePlacement.test.ts fails on a physical side). Left to right, this is margin-right/padding-right.
|
|
@@ -70,9 +70,17 @@
|
|
|
70
70
|
{/each}
|
|
71
71
|
</nav>
|
|
72
72
|
{:else}
|
|
73
|
-
<nav
|
|
74
|
-
{
|
|
75
|
-
|
|
73
|
+
<nav
|
|
74
|
+
class={cn('flex w-full flex-col gap-0.5', className)}
|
|
75
|
+
aria-label="Settings"
|
|
76
|
+
data-testid="settings-nav"
|
|
77
|
+
{...restProps}
|
|
78
|
+
>
|
|
79
|
+
{#each groups as group, groupIndex (group.id)}
|
|
80
|
+
<div
|
|
81
|
+
class={cn('flex flex-col gap-0.5', groupIndex > 0 && 'mt-3')}
|
|
82
|
+
data-testid="settings-nav-group-{group.id}"
|
|
83
|
+
>
|
|
76
84
|
<NavSectionLabel label={group.label} />
|
|
77
85
|
{#each group.items as item (item.id)}
|
|
78
86
|
{@const active = settingsNavItemIsActive(activeId, item.id)}
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
meta?: string;
|
|
51
51
|
showBadge?: boolean;
|
|
52
52
|
badgeLabel?: string;
|
|
53
|
-
/** Figma
|
|
53
|
+
/** Figma Badge — Published uses `secondary` (brand) with dot; Draft uses `default` (neutral grey) without dot. */
|
|
54
54
|
badgeTone?: 'published' | 'draft';
|
|
55
55
|
selected?: boolean;
|
|
56
56
|
loading?: boolean;
|
|
@@ -113,7 +113,7 @@
|
|
|
113
113
|
|
|
114
114
|
{#if showBadge}
|
|
115
115
|
{#if badgeTone === 'draft'}
|
|
116
|
-
<
|
|
116
|
+
<Badge variant="default" class="shrink-0 max-sm:hidden">{badgeLabel}</Badge>
|
|
117
117
|
{:else}
|
|
118
118
|
<Badge variant="secondary" showDot class="shrink-0 max-sm:hidden">{badgeLabel}</Badge>
|
|
119
119
|
{/if}
|
|
@@ -65,7 +65,7 @@ type $$ComponentProps = HTMLAttributes<HTMLDivElement> & {
|
|
|
65
65
|
meta?: string;
|
|
66
66
|
showBadge?: boolean;
|
|
67
67
|
badgeLabel?: string;
|
|
68
|
-
/** Figma
|
|
68
|
+
/** Figma Badge — Published uses `secondary` (brand) with dot; Draft uses `default` (neutral grey) without dot. */
|
|
69
69
|
badgeTone?: 'published' | 'draft';
|
|
70
70
|
selected?: boolean;
|
|
71
71
|
loading?: boolean;
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
holdActiveToastsDuringKeyboardFocus,
|
|
11
11
|
restartDismissCountdownForActiveToasts
|
|
12
12
|
} from './toastDismissCountdown';
|
|
13
|
+
import { queueShowToast } from './toastQueue.js';
|
|
13
14
|
|
|
14
15
|
type ToastTypes = 'success' | 'error' | 'warning' | 'info' | 'loading';
|
|
15
16
|
|
|
@@ -54,7 +55,12 @@
|
|
|
54
55
|
const toneIcon = toneIcons[type as ToastTypes];
|
|
55
56
|
if (toneIcon) options.icon = toneIcon;
|
|
56
57
|
|
|
57
|
-
const {
|
|
58
|
+
const {
|
|
59
|
+
description: _ignoredDescription,
|
|
60
|
+
action: _stripAction,
|
|
61
|
+
cancel: _stripCancel,
|
|
62
|
+
...toastOptions
|
|
63
|
+
} = options;
|
|
58
64
|
|
|
59
65
|
let toastKey: ToastTypes = type as ToastTypes;
|
|
60
66
|
if (typeof toast[toastKey] !== 'function') {
|
|
@@ -62,7 +68,7 @@
|
|
|
62
68
|
toastKey = 'info';
|
|
63
69
|
}
|
|
64
70
|
|
|
65
|
-
return
|
|
71
|
+
return queueShowToast(toastKey, line, {
|
|
66
72
|
...toastOptions,
|
|
67
73
|
duration,
|
|
68
74
|
unstyled: true,
|
|
@@ -121,13 +127,12 @@
|
|
|
121
127
|
classes: {
|
|
122
128
|
toast:
|
|
123
129
|
toastMainClass +
|
|
124
|
-
` !relative !flex !w-max !min-w-0 ${toastMaxWidthClass} !
|
|
130
|
+
` !relative !flex !w-max !min-w-0 ${toastMaxWidthClass} !items-center !gap-2 !rounded-xl !border !px-4 !py-2.5 !pe-9 !text-sm !font-medium !shadow-none [&>[data-icon]]:!hidden [&>[data-button]]:!hidden [&>[data-content]]:!min-w-0 [&>[data-content]]:!flex-1`,
|
|
125
131
|
title:
|
|
126
132
|
toastMainClass +
|
|
127
|
-
'-title !min-w-0 !flex-1 !
|
|
133
|
+
'-title !min-w-0 !flex-1 !whitespace-normal !break-words !text-balance !text-inherit',
|
|
128
134
|
description: toastMainClass + '-description !hidden',
|
|
129
|
-
actionButton:
|
|
130
|
-
'!h-8 !rounded-lg !border !border-current/30 !bg-transparent !px-2 !text-label !text-inherit hover:!bg-current/15',
|
|
135
|
+
actionButton: '!hidden !pointer-events-none',
|
|
131
136
|
cancelButton: '',
|
|
132
137
|
closeButton:
|
|
133
138
|
toastMainClass +
|
|
@@ -140,9 +145,9 @@
|
|
|
140
145
|
'!border-transparent !bg-destructive !text-destructive-foreground [&>[data-icon]]:!hidden'
|
|
141
146
|
}
|
|
142
147
|
}}
|
|
143
|
-
expand={
|
|
144
|
-
visibleToasts={
|
|
145
|
-
offset="
|
|
148
|
+
expand={false}
|
|
149
|
+
visibleToasts={1}
|
|
150
|
+
offset="16px"
|
|
146
151
|
class="{className} toast-modal-host"
|
|
147
152
|
style="--width: max-content; --toast-enter-ms: {toastEnterDurationMs}ms; --toast-exit-ms: {toastExitDurationMs}ms;{style}"
|
|
148
153
|
/>
|
|
@@ -8,7 +8,7 @@ export declare let element: HTMLElement | null;
|
|
|
8
8
|
* `message` is the sentence users see. Legacy callers may still pass `options.description`; it is
|
|
9
9
|
* only used when `message` is empty, otherwise ignored so the toast stays one line.
|
|
10
10
|
*/
|
|
11
|
-
export declare function showToast(type: string | undefined, message: string, options?: Record<string, unknown> | null):
|
|
11
|
+
export declare function showToast(type: string | undefined, message: string, options?: Record<string, unknown> | null): unknown;
|
|
12
12
|
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> {
|
|
13
13
|
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
14
14
|
$$bindings?: Bindings;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** When the wait list is full, drop the oldest entry so the newest toast is still shown eventually. */
|
|
2
|
+
export declare const TOAST_QUEUE_OVERFLOW_POLICY: "drop-oldest";
|
|
3
|
+
export declare const TOAST_QUEUE_MAX_PENDING = 3;
|
|
4
|
+
export type QueuedToast = {
|
|
5
|
+
key: string;
|
|
6
|
+
type: string;
|
|
7
|
+
line: string;
|
|
8
|
+
options: Record<string, unknown>;
|
|
9
|
+
};
|
|
10
|
+
/** One toast on screen at a time; further `showToast` calls wait in a short queue. */
|
|
11
|
+
export declare function queueShowToast(type: string, line: string, options: Record<string, unknown> | null): unknown;
|
|
12
|
+
/** Test-only reset. */
|
|
13
|
+
export declare function resetToastQueueForTests(): void;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { toast } from '../ui/sonner/index.js';
|
|
2
|
+
/** When the wait list is full, drop the oldest entry so the newest toast is still shown eventually. */
|
|
3
|
+
export const TOAST_QUEUE_OVERFLOW_POLICY = 'drop-oldest';
|
|
4
|
+
export const TOAST_QUEUE_MAX_PENDING = 3;
|
|
5
|
+
let pending = [];
|
|
6
|
+
let presenting = false;
|
|
7
|
+
function queueKey(line) {
|
|
8
|
+
return line.trim();
|
|
9
|
+
}
|
|
10
|
+
function stripInteractiveToastOptions(options) {
|
|
11
|
+
const { action: _action, cancel: _cancel, ...rest } = options;
|
|
12
|
+
return rest;
|
|
13
|
+
}
|
|
14
|
+
function enqueue(item) {
|
|
15
|
+
if (pending.some((entry) => entry.key === item.key))
|
|
16
|
+
return;
|
|
17
|
+
if (pending.length >= TOAST_QUEUE_MAX_PENDING) {
|
|
18
|
+
if (TOAST_QUEUE_OVERFLOW_POLICY === 'drop-oldest')
|
|
19
|
+
pending.shift();
|
|
20
|
+
else
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
pending.push(item);
|
|
24
|
+
}
|
|
25
|
+
function releaseSlot() {
|
|
26
|
+
presenting = false;
|
|
27
|
+
flushQueue();
|
|
28
|
+
}
|
|
29
|
+
function flushQueue() {
|
|
30
|
+
if (presenting || pending.length === 0)
|
|
31
|
+
return;
|
|
32
|
+
presenting = true;
|
|
33
|
+
const item = pending.shift();
|
|
34
|
+
const toastOptions = stripInteractiveToastOptions(item.options);
|
|
35
|
+
const userOnDismiss = toastOptions.onDismiss;
|
|
36
|
+
const userOnAutoClose = toastOptions.onAutoClose;
|
|
37
|
+
const chainedOptions = {
|
|
38
|
+
...toastOptions,
|
|
39
|
+
onDismiss: (toastInstance) => {
|
|
40
|
+
if (typeof userOnDismiss === 'function')
|
|
41
|
+
userOnDismiss(toastInstance);
|
|
42
|
+
releaseSlot();
|
|
43
|
+
},
|
|
44
|
+
onAutoClose: (toastInstance) => {
|
|
45
|
+
if (typeof userOnAutoClose === 'function')
|
|
46
|
+
userOnAutoClose(toastInstance);
|
|
47
|
+
releaseSlot();
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
const presentersByType = toast;
|
|
51
|
+
const presenter = presentersByType[item.type];
|
|
52
|
+
if (typeof presenter === 'function') {
|
|
53
|
+
presenter(item.line, chainedOptions);
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
toast(item.line, {
|
|
57
|
+
...chainedOptions,
|
|
58
|
+
type: item.type
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
/** One toast on screen at a time; further `showToast` calls wait in a short queue. */
|
|
62
|
+
export function queueShowToast(type, line, options) {
|
|
63
|
+
const normalized = stripInteractiveToastOptions(options ?? {});
|
|
64
|
+
const item = { key: queueKey(line), type, line, options: normalized };
|
|
65
|
+
const active = toast.getActiveToasts().filter((entry) => entry.type !== 'loading');
|
|
66
|
+
if (presenting || active.length > 0) {
|
|
67
|
+
enqueue(item);
|
|
68
|
+
return undefined;
|
|
69
|
+
}
|
|
70
|
+
pending.push(item);
|
|
71
|
+
flushQueue();
|
|
72
|
+
return undefined;
|
|
73
|
+
}
|
|
74
|
+
/** Test-only reset. */
|
|
75
|
+
export function resetToastQueueForTests() {
|
|
76
|
+
pending = [];
|
|
77
|
+
presenting = false;
|
|
78
|
+
}
|
package/dist/styles/global.css
CHANGED
|
@@ -942,12 +942,12 @@ go 3 levels up in development mode, 2 levels up in production mode*/
|
|
|
942
942
|
right: auto !important;
|
|
943
943
|
transform: translateX(-50%) !important;
|
|
944
944
|
width: max-content !important;
|
|
945
|
-
max-width: min(
|
|
945
|
+
max-width: min(32rem, calc(100vw - 32px));
|
|
946
946
|
}
|
|
947
947
|
|
|
948
948
|
.toast-modal-host [data-sonner-toast].toast-modal {
|
|
949
949
|
width: max-content;
|
|
950
|
-
max-width:
|
|
950
|
+
max-width: min(32rem, calc(100vw - 32px));
|
|
951
951
|
}
|
|
952
952
|
|
|
953
953
|
.toast-modal-host [data-sonner-toast].toast-modal [data-title] {
|
|
@@ -1015,7 +1015,7 @@ go 3 levels up in development mode, 2 levels up in production mode*/
|
|
|
1015
1015
|
left: auto !important;
|
|
1016
1016
|
right: auto !important;
|
|
1017
1017
|
width: max-content !important;
|
|
1018
|
-
max-width: min(
|
|
1018
|
+
max-width: min(32rem, calc(100vw - 32px));
|
|
1019
1019
|
}
|
|
1020
1020
|
}
|
|
1021
1021
|
|
package/dist/styles/tokens.css
CHANGED
|
@@ -55,10 +55,13 @@
|
|
|
55
55
|
--muted-foreground: var(--color-neutral-550);
|
|
56
56
|
--accent: var(--color-alpha-dark-04);
|
|
57
57
|
--accent-foreground: var(--color-dark);
|
|
58
|
-
/*
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
58
|
+
/*
|
|
59
|
+
* Hover of a surface that is already accent (soft controls, the search field, the rows of the editor).
|
|
60
|
+
* The Figma Hover variants stack a second accent fill on the first (4% over 4%); the nearest alpha primitive is 8%.
|
|
61
|
+
* Opaque mix of page background and ink so outline and ghost hovers stay solid on a dark band behind them (transparent
|
|
62
|
+
* alpha tints would show the parent). Derived from the primitives, not a Figma variable.
|
|
63
|
+
*/
|
|
64
|
+
--accent-hover: color-mix(in oklab, var(--background) 92%, var(--foreground) 8%);
|
|
62
65
|
--destructive: var(--color-error);
|
|
63
66
|
--destructive-foreground: var(--color-white);
|
|
64
67
|
/* Warning icon and text, 5.0:1 on white, and the surface of the Warning toast (white text on it is 5.0:1 too). Never a button. */
|
|
@@ -159,9 +162,8 @@
|
|
|
159
162
|
--muted-foreground: var(--color-alpha-light-70);
|
|
160
163
|
--accent: var(--color-alpha-light-10);
|
|
161
164
|
--accent-foreground: var(--color-white);
|
|
162
|
-
/* Not a Figma variable, like
|
|
163
|
-
|
|
164
|
-
--accent-hover: color-mix(in oklab, var(--color-white) 20%, transparent);
|
|
165
|
+
/* Not a Figma variable, like `--accent-hover` of `:root`: the hover of a surface that is already accent — opaque 20% ink. */
|
|
166
|
+
--accent-hover: color-mix(in oklab, var(--background) 80%, var(--foreground) 20%);
|
|
165
167
|
--destructive: var(--color-error-light);
|
|
166
168
|
--destructive-foreground: var(--color-dark);
|
|
167
169
|
--warning: var(--color-amber-light);
|
|
@@ -177,6 +179,16 @@
|
|
|
177
179
|
--sidebar-ring: var(--color-sage-green);
|
|
178
180
|
}
|
|
179
181
|
|
|
182
|
+
/*
|
|
183
|
+
* Inverse / marketing bands that are not a full `.dark` theme: only interactive tints flip so ghost, outline-like controls
|
|
184
|
+
* and fields use a light ink on the dark canvas. Text colours stay whatever the band sets; put `data-surface="dark"` on the
|
|
185
|
+
* wrapper (Tailwind does not read it — it is a hook for these tokens only).
|
|
186
|
+
*/
|
|
187
|
+
[data-surface="dark"] {
|
|
188
|
+
--accent: color-mix(in oklab, var(--color-dark) 96%, var(--color-white) 4%);
|
|
189
|
+
--accent-hover: color-mix(in oklab, var(--color-dark) 92%, var(--color-white) 8%);
|
|
190
|
+
}
|
|
191
|
+
|
|
180
192
|
@theme inline {
|
|
181
193
|
--color-background: var(--background);
|
|
182
194
|
--color-foreground: var(--foreground);
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
export declare const toastEnterDurationMs = 200;
|
|
7
7
|
/** Dismiss fades in place (no slide), slightly quicker than enter. */
|
|
8
8
|
export declare const toastExitDurationMs = 150;
|
|
9
|
-
/** Long titles wrap inside this width (px). */
|
|
10
|
-
export declare const toastMaxWidthPx =
|
|
11
|
-
/** Literal for Tailwind scanner — keep in sync with
|
|
12
|
-
export declare const toastMaxWidthClass = "!max-w-[
|
|
9
|
+
/** Long titles wrap inside this width (px), capped for narrow viewports. */
|
|
10
|
+
export declare const toastMaxWidthPx = 512;
|
|
11
|
+
/** Literal for Tailwind scanner — keep in sync with the toast max-width spec. */
|
|
12
|
+
export declare const toastMaxWidthClass = "!max-w-[min(32rem,calc(100vw-32px))]";
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
export const toastEnterDurationMs = 200;
|
|
7
7
|
/** Dismiss fades in place (no slide), slightly quicker than enter. */
|
|
8
8
|
export const toastExitDurationMs = 150;
|
|
9
|
-
/** Long titles wrap inside this width (px). */
|
|
10
|
-
export const toastMaxWidthPx =
|
|
11
|
-
/** Literal for Tailwind scanner — keep in sync with
|
|
12
|
-
export const toastMaxWidthClass = '!max-w-[
|
|
9
|
+
/** Long titles wrap inside this width (px), capped for narrow viewports. */
|
|
10
|
+
export const toastMaxWidthPx = 512;
|
|
11
|
+
/** Literal for Tailwind scanner — keep in sync with the toast max-width spec. */
|
|
12
|
+
export const toastMaxWidthClass = '!max-w-[min(32rem,calc(100vw-32px))]';
|