@widgetic/design-system 0.5.37 → 0.5.39
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/ChatHeader.svelte +1 -1
- package/dist/components/creator/CanvasBoardStatusChip.svelte +14 -1
- package/dist/components/creator/CreatorBar.svelte +44 -4
- package/dist/components/creator/CreatorBar.svelte.d.ts +8 -1
- package/dist/components/shell/SettingsNav.svelte +19 -4
- package/dist/components/shell/WidgetRow.svelte +16 -2
- package/dist/components/shell/WidgetRow.svelte.d.ts +5 -0
- package/dist/components/toast/ToasterModal.svelte +14 -2
- package/dist/components/ui/dropdown-menu/dropdown-menu-item.svelte +4 -0
- package/dist/components/ui/dropdown-menu/dropdown-menu-item.svelte.d.ts +2 -0
- package/dist/styles/global.css +4 -2
- package/dist/utils/toastLineLayout.d.ts +24 -0
- package/dist/utils/toastLineLayout.js +26 -0
- package/package.json +1 -1
|
@@ -27,6 +27,17 @@
|
|
|
27
27
|
|
|
28
28
|
/** Whether the chip carries an action button (and so must receive clicks). */
|
|
29
29
|
const hasAction = $derived(Boolean(actionLabel) && typeof onAction === 'function');
|
|
30
|
+
const isCompactReady = $derived(variant === 'ready' && !hasAction);
|
|
31
|
+
/** Figma absolute widths (centred in the 960px sketch canvas): generating 262, failed 347, ready 177. */
|
|
32
|
+
const figmaWidthClass = $derived(
|
|
33
|
+
variant === 'failed'
|
|
34
|
+
? 'w-[21.6875rem]'
|
|
35
|
+
: variant === 'generating'
|
|
36
|
+
? 'w-[16.375rem]'
|
|
37
|
+
: isCompactReady
|
|
38
|
+
? 'w-[11.0625rem]'
|
|
39
|
+
: '',
|
|
40
|
+
);
|
|
30
41
|
</script>
|
|
31
42
|
|
|
32
43
|
<div
|
|
@@ -34,7 +45,9 @@
|
|
|
34
45
|
data-testid="canvas-board-status-chip"
|
|
35
46
|
data-variant={variant}
|
|
36
47
|
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
|
|
48
|
+
'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 rounded-full border',
|
|
49
|
+
figmaWidthClass,
|
|
50
|
+
isCompactReady ? 'h-7 justify-center gap-1.5 px-3 py-0' : 'min-h-10 justify-between gap-2 py-[3px] ps-[11px] pe-[3px]',
|
|
38
51
|
hasAction ? 'pointer-events-auto' : 'pointer-events-none',
|
|
39
52
|
className
|
|
40
53
|
)}
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
import { cn } from '../../utils.js';
|
|
12
12
|
import { Button } from '../ui/button/index.js';
|
|
13
13
|
import { IconButton } from '../ui/icon-button/index.js';
|
|
14
|
+
import * as DropdownMenu from '../ui/dropdown-menu/index.js';
|
|
14
15
|
|
|
15
16
|
export type CreatorBarStatus = string;
|
|
16
17
|
|
|
@@ -34,6 +35,13 @@
|
|
|
34
35
|
onCustomize?: () => void;
|
|
35
36
|
/** Figma: title row always shows ▾ when a sketch menu is available, even before an action is wired. */
|
|
36
37
|
showTitleChevron?: boolean;
|
|
38
|
+
/** Figma Title Menu (526:2320): dropdown anchored on the title control. */
|
|
39
|
+
titleMenu?: Snippet;
|
|
40
|
+
titleMenuOpen?: boolean;
|
|
41
|
+
/** Figma 528:2922 loading bar: caption-style title at y=20, not the 32px title button. */
|
|
42
|
+
titleAsCaption?: boolean;
|
|
43
|
+
/** Figma title button min width varies by state (Failed 143px vs Ready 201px). */
|
|
44
|
+
titleButtonClass?: string;
|
|
37
45
|
trailing?: Snippet;
|
|
38
46
|
};
|
|
39
47
|
|
|
@@ -55,11 +63,18 @@
|
|
|
55
63
|
onPublish,
|
|
56
64
|
onCustomize,
|
|
57
65
|
showTitleChevron = false,
|
|
66
|
+
titleMenu,
|
|
67
|
+
titleMenuOpen = $bindable(false),
|
|
68
|
+
titleAsCaption = false,
|
|
69
|
+
// Figma 514:52 — the title hugs its text (143 px for "Untitled widget", 201 px for "Black Friday countdown"), so it has no minimum width.
|
|
70
|
+
titleButtonClass = 'min-w-0',
|
|
58
71
|
trailing,
|
|
59
72
|
...restProps
|
|
60
73
|
}: Props = $props();
|
|
61
74
|
|
|
62
|
-
const titleIsInteractive = $derived(
|
|
75
|
+
const titleIsInteractive = $derived(
|
|
76
|
+
!titleAsCaption && (Boolean(titleMenu) || Boolean(onTitleClick) || showTitleChevron),
|
|
77
|
+
);
|
|
63
78
|
</script>
|
|
64
79
|
|
|
65
80
|
<header
|
|
@@ -79,12 +94,37 @@
|
|
|
79
94
|
</IconButton>
|
|
80
95
|
{/if}
|
|
81
96
|
|
|
82
|
-
{#if
|
|
97
|
+
{#if titleAsCaption}
|
|
98
|
+
<span
|
|
99
|
+
data-testid="creator-bar-title"
|
|
100
|
+
class="text-caption text-muted-foreground max-w-[10rem] truncate px-2 leading-4"
|
|
101
|
+
>
|
|
102
|
+
{title}
|
|
103
|
+
</span>
|
|
104
|
+
{:else if titleMenu}
|
|
105
|
+
<DropdownMenu.Root bind:open={titleMenuOpen}>
|
|
106
|
+
<DropdownMenu.Trigger>
|
|
107
|
+
{#snippet child({ props }: { props: Record<string, unknown> })}
|
|
108
|
+
<Button
|
|
109
|
+
{...props}
|
|
110
|
+
data-testid="creator-bar-title"
|
|
111
|
+
variant="ghost"
|
|
112
|
+
size="sm"
|
|
113
|
+
class={cn('h-8 w-fit max-w-[min(100%,14rem)] shrink-0 gap-1 ps-3 pe-2', titleButtonClass)}
|
|
114
|
+
>
|
|
115
|
+
<span class="truncate">{title}</span>
|
|
116
|
+
<IconChevronDown class="size-4 shrink-0 stroke-2" aria-hidden="true" />
|
|
117
|
+
</Button>
|
|
118
|
+
{/snippet}
|
|
119
|
+
</DropdownMenu.Trigger>
|
|
120
|
+
{@render titleMenu()}
|
|
121
|
+
</DropdownMenu.Root>
|
|
122
|
+
{:else if titleIsInteractive}
|
|
83
123
|
<Button
|
|
84
124
|
data-testid="creator-bar-title"
|
|
85
125
|
variant="ghost"
|
|
86
126
|
size="sm"
|
|
87
|
-
class=
|
|
127
|
+
class={cn('h-8 w-fit max-w-[min(100%,14rem)] shrink-0 gap-1 ps-3 pe-2', titleButtonClass)}
|
|
88
128
|
onclick={onTitleClick}
|
|
89
129
|
disabled={!onTitleClick}
|
|
90
130
|
>
|
|
@@ -106,7 +146,7 @@
|
|
|
106
146
|
{/if}
|
|
107
147
|
|
|
108
148
|
{#if showStatus && status}
|
|
109
|
-
<span data-testid="creator-bar-status" class="text-caption text-muted-foreground shrink-0 whitespace-nowrap">{status}</span>
|
|
149
|
+
<span data-testid="creator-bar-status" class="text-caption text-muted-foreground min-w-9 shrink-0 whitespace-nowrap">{status}</span>
|
|
110
150
|
{/if}
|
|
111
151
|
|
|
112
152
|
<span class="min-w-0 flex-1" aria-hidden="true"></span>
|
|
@@ -21,8 +21,15 @@ type Props = HTMLAttributes<HTMLElement> & {
|
|
|
21
21
|
onCustomize?: () => void;
|
|
22
22
|
/** Figma: title row always shows ▾ when a sketch menu is available, even before an action is wired. */
|
|
23
23
|
showTitleChevron?: boolean;
|
|
24
|
+
/** Figma Title Menu (526:2320): dropdown anchored on the title control. */
|
|
25
|
+
titleMenu?: Snippet;
|
|
26
|
+
titleMenuOpen?: boolean;
|
|
27
|
+
/** Figma 528:2922 loading bar: caption-style title at y=20, not the 32px title button. */
|
|
28
|
+
titleAsCaption?: boolean;
|
|
29
|
+
/** Figma title button min width varies by state (Failed 143px vs Ready 201px). */
|
|
30
|
+
titleButtonClass?: string;
|
|
24
31
|
trailing?: Snippet;
|
|
25
32
|
};
|
|
26
|
-
declare const CreatorBar: import("svelte").Component<Props, {}, "ref">;
|
|
33
|
+
declare const CreatorBar: import("svelte").Component<Props, {}, "ref" | "titleMenuOpen">;
|
|
27
34
|
type CreatorBar = ReturnType<typeof CreatorBar>;
|
|
28
35
|
export default CreatorBar;
|
|
@@ -43,6 +43,20 @@
|
|
|
43
43
|
{ id: 'workspace', labelWidth: 'w-16', labelWidths: ['w-24', 'w-28', 'w-20', 'w-24', 'w-16'] },
|
|
44
44
|
{ id: 'account', labelWidth: 'w-14', labelWidths: ['w-20', 'w-28'] }
|
|
45
45
|
];
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* The margin above every group after the first. Tailwind reads whole class names from the source, so the class is
|
|
49
|
+
* written here once and used by the real menu and by the skeleton, which must not move when the menu is known.
|
|
50
|
+
*
|
|
51
|
+
* What a person sees between the last row of a group and the label of the next one (Stats, then Account) is 24px, from
|
|
52
|
+
* the bottom of the text of the row to the top of the text of the label:
|
|
53
|
+
* 6px the row under its 20px line (Nav Row: h-8, 14/20)
|
|
54
|
+
* + 2px the gap between the children of the menu (gap-0.5)
|
|
55
|
+
* + 4px this margin (mt-1)
|
|
56
|
+
* + 12px the label above its 16px line (Nav Section Label: pt-3, as in Figma)
|
|
57
|
+
* = 24px. It was mt-3 (12px, 32px in all) up to 14 Nov 2026, when 24px was asked for.
|
|
58
|
+
*/
|
|
59
|
+
const groupGapClass = 'mt-1';
|
|
46
60
|
</script>
|
|
47
61
|
|
|
48
62
|
{#if pending}
|
|
@@ -55,9 +69,10 @@
|
|
|
55
69
|
{...restProps}
|
|
56
70
|
>
|
|
57
71
|
<span class="sr-only" role="status">{pendingLabel}</span>
|
|
58
|
-
{#each pendingGroups as group (group.id)}
|
|
59
|
-
<div class=
|
|
60
|
-
|
|
72
|
+
{#each pendingGroups as group, groupIndex (group.id)}
|
|
73
|
+
<div class={cn('flex flex-col gap-0.5', groupIndex > 0 && groupGapClass)} aria-hidden="true">
|
|
74
|
+
<!-- The label box of the real menu (Nav Section Label: px-2 pt-3 pb-1): the bar sits where its text will. -->
|
|
75
|
+
<div class="flex h-8 w-full min-w-0 items-center px-2 pt-3 pb-1">
|
|
61
76
|
<Skeleton class={cn('h-3', group.labelWidth)} pulse="low" />
|
|
62
77
|
</div>
|
|
63
78
|
{#each group.labelWidths as labelWidth, rowIndex (rowIndex)}
|
|
@@ -78,7 +93,7 @@
|
|
|
78
93
|
>
|
|
79
94
|
{#each groups as group, groupIndex (group.id)}
|
|
80
95
|
<div
|
|
81
|
-
class={cn('flex flex-col gap-0.5', groupIndex > 0 &&
|
|
96
|
+
class={cn('flex flex-col gap-0.5', groupIndex > 0 && groupGapClass)}
|
|
82
97
|
data-testid="settings-nav-group-{group.id}"
|
|
83
98
|
>
|
|
84
99
|
<NavSectionLabel label={group.label} />
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
import type { HTMLAttributes } from 'svelte/elements';
|
|
29
29
|
import type { Snippet } from 'svelte';
|
|
30
30
|
import { cn, tv } from '../../utils.js';
|
|
31
|
-
import { Badge } from '../ui/badge/index.js';
|
|
31
|
+
import { Badge, type BadgeVariant } from '../ui/badge/index.js';
|
|
32
32
|
import { Skeleton } from '../ui/skeleton/index.js';
|
|
33
33
|
|
|
34
34
|
let {
|
|
@@ -38,11 +38,13 @@
|
|
|
38
38
|
showBadge = true,
|
|
39
39
|
badgeLabel = 'Published',
|
|
40
40
|
badgeTone = 'published',
|
|
41
|
+
badgeVariant = undefined,
|
|
41
42
|
selected = false,
|
|
42
43
|
loading = false,
|
|
43
44
|
visualState = undefined,
|
|
44
45
|
actionsAlwaysVisible = false,
|
|
45
46
|
thumbnail,
|
|
47
|
+
persistentActions,
|
|
46
48
|
actions,
|
|
47
49
|
...restProps
|
|
48
50
|
}: HTMLAttributes<HTMLDivElement> & {
|
|
@@ -52,12 +54,16 @@
|
|
|
52
54
|
badgeLabel?: string;
|
|
53
55
|
/** Figma Badge — Published uses `secondary` (brand) with dot; Draft uses `default` (neutral grey) without dot. */
|
|
54
56
|
badgeTone?: 'published' | 'draft';
|
|
57
|
+
/** When set, renders Badge with this variant (overrides badgeTone mapping). */
|
|
58
|
+
badgeVariant?: BadgeVariant;
|
|
55
59
|
selected?: boolean;
|
|
56
60
|
loading?: boolean;
|
|
57
61
|
visualState?: WidgetRowVisualState;
|
|
58
62
|
/** Touch / mobile: keep row actions visible without hover. */
|
|
59
63
|
actionsAlwaysVisible?: boolean;
|
|
60
64
|
thumbnail?: Snippet;
|
|
65
|
+
/** Always visible trailing controls (e.g. Figma sync Retry beside the status badge). */
|
|
66
|
+
persistentActions?: Snippet;
|
|
61
67
|
actions?: Snippet;
|
|
62
68
|
} = $props();
|
|
63
69
|
|
|
@@ -112,7 +118,9 @@
|
|
|
112
118
|
</div>
|
|
113
119
|
|
|
114
120
|
{#if showBadge}
|
|
115
|
-
{#if
|
|
121
|
+
{#if badgeVariant}
|
|
122
|
+
<Badge variant={badgeVariant} class="max-sm:hidden shrink-0">{badgeLabel}</Badge>
|
|
123
|
+
{:else if badgeTone === 'draft'}
|
|
116
124
|
<!-- Selected: the row is light green, so the grey chip would stand out. It takes the green of the selection ring. -->
|
|
117
125
|
<Badge
|
|
118
126
|
variant="default"
|
|
@@ -128,6 +136,12 @@
|
|
|
128
136
|
{/if}
|
|
129
137
|
{/if}
|
|
130
138
|
|
|
139
|
+
{#if persistentActions}
|
|
140
|
+
<div class="flex shrink-0 items-center gap-2">
|
|
141
|
+
{@render persistentActions()}
|
|
142
|
+
</div>
|
|
143
|
+
{/if}
|
|
144
|
+
|
|
131
145
|
{#if actions}
|
|
132
146
|
<div
|
|
133
147
|
class={cn(
|
|
@@ -60,6 +60,7 @@ export declare const widgetRowVariants: import("tailwind-variants").TVReturnType
|
|
|
60
60
|
export type WidgetRowVisualState = 'default' | 'hover' | 'focus' | 'selected' | 'loading';
|
|
61
61
|
import type { HTMLAttributes } from 'svelte/elements';
|
|
62
62
|
import type { Snippet } from 'svelte';
|
|
63
|
+
import { type BadgeVariant } from '../ui/badge/index.js';
|
|
63
64
|
type $$ComponentProps = HTMLAttributes<HTMLDivElement> & {
|
|
64
65
|
title: string;
|
|
65
66
|
meta?: string;
|
|
@@ -67,12 +68,16 @@ type $$ComponentProps = HTMLAttributes<HTMLDivElement> & {
|
|
|
67
68
|
badgeLabel?: string;
|
|
68
69
|
/** Figma Badge — Published uses `secondary` (brand) with dot; Draft uses `default` (neutral grey) without dot. */
|
|
69
70
|
badgeTone?: 'published' | 'draft';
|
|
71
|
+
/** When set, renders Badge with this variant (overrides badgeTone mapping). */
|
|
72
|
+
badgeVariant?: BadgeVariant;
|
|
70
73
|
selected?: boolean;
|
|
71
74
|
loading?: boolean;
|
|
72
75
|
visualState?: WidgetRowVisualState;
|
|
73
76
|
/** Touch / mobile: keep row actions visible without hover. */
|
|
74
77
|
actionsAlwaysVisible?: boolean;
|
|
75
78
|
thumbnail?: Snippet;
|
|
79
|
+
/** Always visible trailing controls (e.g. Figma sync Retry beside the status badge). */
|
|
80
|
+
persistentActions?: Snippet;
|
|
76
81
|
actions?: Snippet;
|
|
77
82
|
};
|
|
78
83
|
declare const WidgetRow: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
import IconInfoCircle from '@tabler/icons-svelte/icons/info-circle';
|
|
7
7
|
import { toastLookupRoots } from './toasterRoots';
|
|
8
8
|
import { toastEnterDurationMs, toastExitDurationMs, toastMaxWidthClass } from '../../utils/toastMotion.js';
|
|
9
|
+
import { toastBoxClassesForLine } from '../../utils/toastLineLayout.js';
|
|
9
10
|
import {
|
|
10
11
|
holdActiveToastsDuringKeyboardFocus,
|
|
11
12
|
restartDismissCountdownForActiveToasts
|
|
@@ -68,11 +69,22 @@
|
|
|
68
69
|
toastKey = 'info';
|
|
69
70
|
}
|
|
70
71
|
|
|
72
|
+
// The box is as wide as the message on one line, up to a width that depends on the length of the message (a short one
|
|
73
|
+
// may take the whole screen, a long one wraps at a readable width): the one max-width class of the toast is chosen here.
|
|
74
|
+
const existingClasses =
|
|
75
|
+
typeof toastOptions.classes === 'object' && toastOptions.classes !== null
|
|
76
|
+
? (toastOptions.classes as Record<string, string>)
|
|
77
|
+
: {};
|
|
78
|
+
const boxClasses = [existingClasses.toast, toastBoxClassesForLine(line)].filter(Boolean).join(' ');
|
|
71
79
|
return queueShowToast(toastKey, line, {
|
|
72
80
|
...toastOptions,
|
|
73
81
|
duration,
|
|
74
82
|
unstyled: true,
|
|
75
|
-
description: undefined
|
|
83
|
+
description: undefined,
|
|
84
|
+
classes: {
|
|
85
|
+
...existingClasses,
|
|
86
|
+
toast: boxClasses
|
|
87
|
+
}
|
|
76
88
|
});
|
|
77
89
|
}
|
|
78
90
|
</script>
|
|
@@ -127,7 +139,7 @@
|
|
|
127
139
|
classes: {
|
|
128
140
|
toast:
|
|
129
141
|
toastMainClass +
|
|
130
|
-
` !relative !flex !w-max !min-w-0
|
|
142
|
+
` !relative !inline-flex !w-max !min-w-0 !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]]:!w-max [&>[data-content]]:!max-w-none [&>[data-content]]:!min-w-0`,
|
|
131
143
|
title:
|
|
132
144
|
toastMainClass +
|
|
133
145
|
'-title !min-w-0 !flex-1 !whitespace-normal !break-words !text-balance !text-inherit',
|
|
@@ -6,12 +6,15 @@
|
|
|
6
6
|
ref = $bindable(null),
|
|
7
7
|
class: className,
|
|
8
8
|
inset,
|
|
9
|
+
variant = "default",
|
|
9
10
|
description,
|
|
10
11
|
label,
|
|
11
12
|
children,
|
|
12
13
|
...restProps
|
|
13
14
|
}: DropdownMenuPrimitive.ItemProps & {
|
|
14
15
|
inset?: boolean;
|
|
16
|
+
/** `destructive` paints the row (text and icon) with the destructive colour — the Delete row of a row menu in Figma. The class list below styles it through `data-variant`. */
|
|
17
|
+
variant?: "default" | "destructive";
|
|
15
18
|
/** Second line (Menu Item with description — 48px row). */
|
|
16
19
|
description?: string;
|
|
17
20
|
/** Primary line when `description` is set (icons stay in the default slot). */
|
|
@@ -21,6 +24,7 @@
|
|
|
21
24
|
|
|
22
25
|
<DropdownMenuPrimitive.Item
|
|
23
26
|
bind:ref
|
|
27
|
+
data-variant={variant}
|
|
24
28
|
class={cn(
|
|
25
29
|
"text-body aria-current:bg-brand-subtle data-highlighted:aria-current:bg-brand-subtle data-highlighted:not-aria-current:bg-accent data-highlighted:text-foreground relative flex cursor-pointer select-none items-center gap-2 rounded-lg px-2 py-1.5 outline-hidden transition-colors duration-fast data-disabled:pointer-events-none data-disabled:cursor-not-allowed data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 [&_svg]:stroke-2 data-[variant=destructive]:text-destructive data-highlighted:data-[variant=destructive]:text-destructive",
|
|
26
30
|
description ? "min-h-12" : "min-h-8",
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { DropdownMenu as DropdownMenuPrimitive } from "bits-ui";
|
|
2
2
|
type $$ComponentProps = DropdownMenuPrimitive.ItemProps & {
|
|
3
3
|
inset?: boolean;
|
|
4
|
+
/** `destructive` paints the row (text and icon) with the destructive colour — the Delete row of a row menu in Figma. The class list below styles it through `data-variant`. */
|
|
5
|
+
variant?: "default" | "destructive";
|
|
4
6
|
/** Second line (Menu Item with description — 48px row). */
|
|
5
7
|
description?: string;
|
|
6
8
|
/** Primary line when `description` is set (icons stay in the default slot). */
|
package/dist/styles/global.css
CHANGED
|
@@ -936,13 +936,15 @@ go 3 levels up in development mode, 2 levels up in production mode*/
|
|
|
936
936
|
}
|
|
937
937
|
} /* End of Base Layer Styles */
|
|
938
938
|
|
|
939
|
-
/* Toast (ToasterModal): width fits copy; stack stays above dialogs (Portal ~1e8, sonner default ~1e9).
|
|
939
|
+
/* Toast (ToasterModal): width fits copy; stack stays above dialogs (Portal ~1e8, sonner default ~1e9).
|
|
940
|
+
The host is never narrower than the toast in it (a short message may take the whole screen): the toast caps its own width
|
|
941
|
+
(see toastLineLayout.ts), and a host that is narrower than its toast makes the toast spill out of the centre. */
|
|
940
942
|
.toast-modal-host[data-sonner-toaster] {
|
|
941
943
|
left: 50% !important;
|
|
942
944
|
right: auto !important;
|
|
943
945
|
transform: translateX(-50%) !important;
|
|
944
946
|
width: max-content !important;
|
|
945
|
-
max-width:
|
|
947
|
+
max-width: calc(100vw - 2rem);
|
|
946
948
|
}
|
|
947
949
|
|
|
948
950
|
.toast-modal-host [data-sonner-toast].toast-modal {
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A message of this many characters or fewer stays on one line whenever the screen is wide enough for it (see `toastBoxClassesForLine`).
|
|
3
|
+
* A longer one wraps at a width that is comfortable to read.
|
|
4
|
+
*/
|
|
5
|
+
export declare const TOAST_SINGLE_LINE_MAX_CHARS = 180;
|
|
6
|
+
/**
|
|
7
|
+
* The room a short message may take: the whole screen, less a margin of 1rem on each side.
|
|
8
|
+
*
|
|
9
|
+
* From `sm` up the lines of the title are not balanced (`text-wrap: wrap` instead of the `text-balance` of the toaster): when a
|
|
10
|
+
* short message does not fit on one line of a window that wide, balancing would make two even lines of about half the box and leave
|
|
11
|
+
* a gap before the close button, while the box is as wide as the window. A phone keeps the balance: its box is narrow.
|
|
12
|
+
*/
|
|
13
|
+
export declare const TOAST_WIDE_BOX_CLASS = "!max-w-[calc(100vw-2rem)] sm:[&_[data-title]]:!text-wrap";
|
|
14
|
+
/** The room a long message may take: a width that is comfortable to read, never wider than the screen less its margins. */
|
|
15
|
+
export declare const TOAST_READABLE_BOX_CLASS = "!max-w-[min(42rem,calc(100vw-2rem))]";
|
|
16
|
+
/**
|
|
17
|
+
* The maximum width of the box of a toast, as one class. The box is `w-max`: as wide as the message on one line, up to this
|
|
18
|
+
* width, and the title wraps only when the message does not fit in it.
|
|
19
|
+
*
|
|
20
|
+
* Exactly one `max-w` class belongs on a toast: the toaster joins the classes of the toast with a plain join (it does not
|
|
21
|
+
* merge Tailwind classes), so two of them would be decided by the order of the stylesheet, not by the order of the classes.
|
|
22
|
+
* (The wide answer also carries the `text-wrap` class described above; that one is not a width.)
|
|
23
|
+
*/
|
|
24
|
+
export declare function toastBoxClassesForLine(line: string): string;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A message of this many characters or fewer stays on one line whenever the screen is wide enough for it (see `toastBoxClassesForLine`).
|
|
3
|
+
* A longer one wraps at a width that is comfortable to read.
|
|
4
|
+
*/
|
|
5
|
+
export const TOAST_SINGLE_LINE_MAX_CHARS = 180;
|
|
6
|
+
/**
|
|
7
|
+
* The room a short message may take: the whole screen, less a margin of 1rem on each side.
|
|
8
|
+
*
|
|
9
|
+
* From `sm` up the lines of the title are not balanced (`text-wrap: wrap` instead of the `text-balance` of the toaster): when a
|
|
10
|
+
* short message does not fit on one line of a window that wide, balancing would make two even lines of about half the box and leave
|
|
11
|
+
* a gap before the close button, while the box is as wide as the window. A phone keeps the balance: its box is narrow.
|
|
12
|
+
*/
|
|
13
|
+
export const TOAST_WIDE_BOX_CLASS = '!max-w-[calc(100vw-2rem)] sm:[&_[data-title]]:!text-wrap';
|
|
14
|
+
/** The room a long message may take: a width that is comfortable to read, never wider than the screen less its margins. */
|
|
15
|
+
export const TOAST_READABLE_BOX_CLASS = '!max-w-[min(42rem,calc(100vw-2rem))]';
|
|
16
|
+
/**
|
|
17
|
+
* The maximum width of the box of a toast, as one class. The box is `w-max`: as wide as the message on one line, up to this
|
|
18
|
+
* width, and the title wraps only when the message does not fit in it.
|
|
19
|
+
*
|
|
20
|
+
* Exactly one `max-w` class belongs on a toast: the toaster joins the classes of the toast with a plain join (it does not
|
|
21
|
+
* merge Tailwind classes), so two of them would be decided by the order of the stylesheet, not by the order of the classes.
|
|
22
|
+
* (The wide answer also carries the `text-wrap` class described above; that one is not a width.)
|
|
23
|
+
*/
|
|
24
|
+
export function toastBoxClassesForLine(line) {
|
|
25
|
+
return line.trim().length <= TOAST_SINGLE_LINE_MAX_CHARS ? TOAST_WIDE_BOX_CLASS : TOAST_READABLE_BOX_CLASS;
|
|
26
|
+
}
|