@widgetic/design-system 0.5.41 → 0.5.42
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/EmptyState.svelte +6 -2
- package/dist/components/creator/CreatorBar.svelte +54 -1
- package/dist/components/creator/CreatorBar.svelte.d.ts +5 -0
- package/dist/components/modals/BaseModal.svelte +9 -0
- package/dist/components/modals/BaseModal.svelte.d.ts +5 -0
- package/dist/components/search-input/SearchInput.svelte +38 -3
- package/dist/components/search-input/recentSearches.d.ts +5 -1
- package/dist/components/search-input/recentSearches.js +18 -1
- package/dist/components/shell/NavRow.svelte +53 -10
- package/dist/components/shell/NavRow.svelte.d.ts +23 -2
- package/dist/components/shell/NotificationRow.svelte +3 -2
- package/dist/components/shell/ProfileRow.svelte +6 -4
- package/dist/components/shell/ProfileRow.svelte.d.ts +2 -2
- package/dist/components/shell/SettingsDialog.svelte +23 -1
- package/dist/components/shell/WidgetRow.svelte +4 -3
- package/dist/components/shell/WidgetRow.svelte.d.ts +2 -2
- package/dist/components/ui/accordion/accordion-trigger.svelte +19 -0
- package/dist/components/ui/button/button.svelte +4 -2
- package/dist/components/ui/dialog/dialog-content.svelte +24 -2
- package/dist/components/ui/dropdown-menu/dropdown-menu-content.svelte +2 -1
- package/dist/components/ui/dropdown-menu/dropdown-menu-sub-content.svelte +2 -1
- package/dist/components/ui/hover-card/hover-card-content.svelte +2 -1
- package/dist/components/ui/popover/popover-content.svelte +2 -1
- package/dist/components/ui/select/select-content.svelte +2 -1
- package/dist/components/ui/tooltip/tooltip-content.svelte +1 -1
- package/dist/styles/tokens.css +68 -1
- package/dist/utils/modalEnterKey.d.ts +139 -0
- package/dist/utils/modalEnterKey.js +276 -0
- package/dist/utils/modalFocusTrap.d.ts +7 -0
- package/dist/utils/modalFocusTrap.js +22 -0
- package/dist/utils/overlayMotion.d.ts +9 -0
- package/dist/utils/overlayMotion.js +9 -0
- package/dist/utils/revealOpeningSection.d.ts +51 -0
- package/dist/utils/revealOpeningSection.js +109 -0
- package/package.json +1 -1
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
* EmptyState — Figma: Empty State (component set 54:71, node 54:71).
|
|
3
3
|
* Centered empty view with icon tile, title, optional description, and actions.
|
|
4
4
|
*
|
|
5
|
+
* The look of Figma's "Components" empty state (node 1634:8567), the one the owner picked for every empty placeholder
|
|
6
|
+
* (18 Nov 2026): a grey tile (`muted/default`) behind the icon, a title in Body/Medium and a description in Body/Default,
|
|
7
|
+
* both in `muted/foreground`. The tile used to be `brand/subtle` (light green) and the title `foreground`.
|
|
8
|
+
*
|
|
5
9
|
* In a pane below a header, pass `class="min-h-0 flex-1"`, `height="auto"` or `height="100%"`, and put the empty state in a
|
|
6
10
|
* flex column parent so it grows into the remaining space and keeps its content centered.
|
|
7
11
|
-->
|
|
@@ -90,7 +94,7 @@
|
|
|
90
94
|
>
|
|
91
95
|
{#if shouldShowIcon}
|
|
92
96
|
<div
|
|
93
|
-
class="bg-
|
|
97
|
+
class="bg-muted flex size-12 shrink-0 items-center justify-center overflow-hidden rounded-xl"
|
|
94
98
|
>
|
|
95
99
|
<!-- Figma draws the icon of every Empty State in the foreground colour (Icon collection, Default mode); `iconColor` still overrides it, on the icon itself -->
|
|
96
100
|
<IconComponent class="text-foreground size-4" style={iconStyle} aria-hidden="true" />
|
|
@@ -98,7 +102,7 @@
|
|
|
98
102
|
{/if}
|
|
99
103
|
|
|
100
104
|
<div class="flex w-full min-w-0 flex-col gap-1">
|
|
101
|
-
<p class="text-body text-foreground font-medium" style={titleStyle}>{message}</p>
|
|
105
|
+
<p class="text-body text-muted-foreground font-medium" style={titleStyle}>{message}</p>
|
|
102
106
|
{#if description}
|
|
103
107
|
<p class="text-body text-muted-foreground">{description}</p>
|
|
104
108
|
{/if}
|
|
@@ -42,6 +42,11 @@
|
|
|
42
42
|
titleAsCaption?: boolean;
|
|
43
43
|
/** Figma title button min width varies by state (Failed 143px vs Ready 201px). */
|
|
44
44
|
titleButtonClass?: string;
|
|
45
|
+
/** Inline title rename state for the sketch bar. */
|
|
46
|
+
isRenaming?: boolean;
|
|
47
|
+
renameValue?: string;
|
|
48
|
+
onRenameCommit?: (nextTitle: string) => void;
|
|
49
|
+
onRenameCancel?: () => void;
|
|
45
50
|
trailing?: Snippet;
|
|
46
51
|
};
|
|
47
52
|
|
|
@@ -68,10 +73,39 @@
|
|
|
68
73
|
titleAsCaption = false,
|
|
69
74
|
// 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
75
|
titleButtonClass = 'min-w-0',
|
|
76
|
+
isRenaming = false,
|
|
77
|
+
renameValue = '',
|
|
78
|
+
onRenameCommit,
|
|
79
|
+
onRenameCancel,
|
|
71
80
|
trailing,
|
|
72
81
|
...restProps
|
|
73
82
|
}: Props = $props();
|
|
74
83
|
|
|
84
|
+
let renameDraft = $state('');
|
|
85
|
+
let renameInputEl = $state<HTMLInputElement | null>(null);
|
|
86
|
+
let renameCanceled = false;
|
|
87
|
+
|
|
88
|
+
$effect(() => {
|
|
89
|
+
if (isRenaming) {
|
|
90
|
+
renameCanceled = false;
|
|
91
|
+
renameDraft = renameValue || title;
|
|
92
|
+
queueMicrotask(() => {
|
|
93
|
+
renameInputEl?.focus();
|
|
94
|
+
renameInputEl?.select();
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
function commitRename() {
|
|
100
|
+
if (renameCanceled) return;
|
|
101
|
+
onRenameCommit?.(renameDraft);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function cancelRename() {
|
|
105
|
+
renameCanceled = true;
|
|
106
|
+
onRenameCancel?.();
|
|
107
|
+
}
|
|
108
|
+
|
|
75
109
|
const titleIsInteractive = $derived(
|
|
76
110
|
!titleAsCaption && (Boolean(titleMenu) || Boolean(onTitleClick) || showTitleChevron),
|
|
77
111
|
);
|
|
@@ -94,7 +128,26 @@
|
|
|
94
128
|
</IconButton>
|
|
95
129
|
{/if}
|
|
96
130
|
|
|
97
|
-
{#if
|
|
131
|
+
{#if isRenaming}
|
|
132
|
+
<input
|
|
133
|
+
bind:this={renameInputEl}
|
|
134
|
+
bind:value={renameDraft}
|
|
135
|
+
type="text"
|
|
136
|
+
data-testid="creator-bar-title-input"
|
|
137
|
+
aria-label="Rename widget"
|
|
138
|
+
class="border-input bg-background text-body-medium focus:border-ring h-8 w-52 max-w-[min(100%,16rem)] rounded-md border px-2.5 text-sm outline-none"
|
|
139
|
+
onkeydown={(e) => {
|
|
140
|
+
if (e.key === 'Enter') {
|
|
141
|
+
e.preventDefault();
|
|
142
|
+
commitRename();
|
|
143
|
+
} else if (e.key === 'Escape') {
|
|
144
|
+
e.preventDefault();
|
|
145
|
+
cancelRename();
|
|
146
|
+
}
|
|
147
|
+
}}
|
|
148
|
+
onblur={commitRename}
|
|
149
|
+
/>
|
|
150
|
+
{:else if titleAsCaption}
|
|
98
151
|
<span
|
|
99
152
|
data-testid="creator-bar-title"
|
|
100
153
|
class="text-caption text-muted-foreground max-w-[10rem] truncate px-2 leading-4"
|
|
@@ -28,6 +28,11 @@ type Props = HTMLAttributes<HTMLElement> & {
|
|
|
28
28
|
titleAsCaption?: boolean;
|
|
29
29
|
/** Figma title button min width varies by state (Failed 143px vs Ready 201px). */
|
|
30
30
|
titleButtonClass?: string;
|
|
31
|
+
/** Inline title rename state for the sketch bar. */
|
|
32
|
+
isRenaming?: boolean;
|
|
33
|
+
renameValue?: string;
|
|
34
|
+
onRenameCommit?: (nextTitle: string) => void;
|
|
35
|
+
onRenameCancel?: () => void;
|
|
31
36
|
trailing?: Snippet;
|
|
32
37
|
};
|
|
33
38
|
declare const CreatorBar: import("svelte").Component<Props, {}, "ref" | "titleMenuOpen">;
|
|
@@ -33,6 +33,8 @@
|
|
|
33
33
|
} from '../../utils/overlayMotion.js';
|
|
34
34
|
// A scrim drawn over another scrim only dims (the page is blurred once): see overlayStacking.ts.
|
|
35
35
|
import { stackedScrimMark } from '../../utils/overlayStacking.js';
|
|
36
|
+
// Enter inside the card presses the modal's main button (see utils/modalEnterKey.ts).
|
|
37
|
+
import { modalEnterKey } from '../../utils/modalEnterKey.js';
|
|
36
38
|
|
|
37
39
|
/* COMPONENT PROPS */
|
|
38
40
|
// class and style props
|
|
@@ -68,6 +70,12 @@
|
|
|
68
70
|
export let closeOnBackdropClick = true;
|
|
69
71
|
/** When false, Escape does not close. Default: Escape dismisses unless a nested control already handled the key. */
|
|
70
72
|
export let closeOnEscape = true;
|
|
73
|
+
/**
|
|
74
|
+
* When true (default), Enter inside the card presses the modal's main button: the last filled `Button` (or the one marked
|
|
75
|
+
* `data-modal-primary`), unless the control that has the focus keeps Enter for itself. See utils/modalEnterKey.ts.
|
|
76
|
+
* A modal that wants every Enter for its own content passes false.
|
|
77
|
+
*/
|
|
78
|
+
export let enterActivatesPrimary = true;
|
|
71
79
|
/** Spoken name of the dialog when there is no visible title row (a bare modal should pass one, for example the file's name). */
|
|
72
80
|
export let ariaLabel: string | undefined = undefined;
|
|
73
81
|
|
|
@@ -451,6 +459,7 @@
|
|
|
451
459
|
<!-- svelte-ignore a11y_click_events_have_key_events -->
|
|
452
460
|
<div
|
|
453
461
|
bind:this={modalPanelEl}
|
|
462
|
+
use:modalEnterKey={{ enabled: enterActivatesPrimary && open }}
|
|
454
463
|
role="dialog"
|
|
455
464
|
aria-modal="true"
|
|
456
465
|
aria-labelledby={title ? titleElementId : undefined}
|
|
@@ -31,6 +31,11 @@ declare const BaseModal: $$__sveltets_2_IsomorphicComponent<{
|
|
|
31
31
|
bare?: boolean;
|
|
32
32
|
/** When false, clicks and taps on the scrim do not close (destructive confirms can set this). Default matches Figma: scrim dismisses. */ closeOnBackdropClick?: boolean;
|
|
33
33
|
/** When false, Escape does not close. Default: Escape dismisses unless a nested control already handled the key. */ closeOnEscape?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* When true (default), Enter inside the card presses the modal's main button: the last filled `Button` (or the one marked
|
|
36
|
+
* `data-modal-primary`), unless the control that has the focus keeps Enter for itself. See utils/modalEnterKey.ts.
|
|
37
|
+
* A modal that wants every Enter for its own content passes false.
|
|
38
|
+
*/ enterActivatesPrimary?: boolean;
|
|
34
39
|
/** Spoken name of the dialog when there is no visible title row (a bare modal should pass one, for example the file's name). */ ariaLabel?: string | undefined;
|
|
35
40
|
children: any;
|
|
36
41
|
}, {
|
|
@@ -5,6 +5,10 @@
|
|
|
5
5
|
|
|
6
6
|
Optional `recentSearchesKey` (a host-built localStorage key) shows up to three recent searches under the field when it is
|
|
7
7
|
focused and empty. With `recentSearchesKey` left at `''` the field matches the original Search Field (no recents panel).
|
|
8
|
+
|
|
9
|
+
Once a person has searched and then cleared the field (the clear button, or deleting every character), the list is not shown
|
|
10
|
+
again for the rest of that session (the life of the page, per key): they just did that search, so the list would only repeat
|
|
11
|
+
it. A reload starts a new session.
|
|
8
12
|
-->
|
|
9
13
|
<script lang="ts">
|
|
10
14
|
import { tick } from 'svelte';
|
|
@@ -14,7 +18,9 @@
|
|
|
14
18
|
|
|
15
19
|
import {
|
|
16
20
|
MIN_RECENT_SEARCH_LENGTH,
|
|
21
|
+
areRecentSearchesHiddenForSession,
|
|
17
22
|
clearRecentSearches,
|
|
23
|
+
hideRecentSearchesForSession,
|
|
18
24
|
readRecentSearches,
|
|
19
25
|
rememberRecentSearch
|
|
20
26
|
} from './recentSearches.js';
|
|
@@ -59,7 +65,8 @@
|
|
|
59
65
|
}
|
|
60
66
|
|
|
61
67
|
function openRecentPanelIfApplicable(): void {
|
|
62
|
-
|
|
68
|
+
// A person who searched and then cleared the field does not get the list back in this session: they just did the search
|
|
69
|
+
if (!recentSearchesKey || value.trim() || areRecentSearchesHiddenForSession(recentSearchesKey)) {
|
|
63
70
|
recentPanelOpen = false;
|
|
64
71
|
activeRecentIndex = -1;
|
|
65
72
|
return;
|
|
@@ -137,9 +144,28 @@
|
|
|
137
144
|
onBlur(event);
|
|
138
145
|
}
|
|
139
146
|
|
|
147
|
+
/** What the field held when it was last looked at: going from words to nothing is a search that is over. */
|
|
148
|
+
let lastObservedValue = value;
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Looks at the words of the field. When there were words and now there are none (the clear button, the keyboard, or a host that
|
|
152
|
+
* empties the field), the search is over, so the recent searches are hidden for the rest of the session and the open card closes.
|
|
153
|
+
* It runs from the input event and from the reactive statement below; the second look of the same change finds nothing new.
|
|
154
|
+
*/
|
|
155
|
+
function observeValue(nextValue: string): void {
|
|
156
|
+
const hadWords = lastObservedValue.trim().length > 0;
|
|
157
|
+
lastObservedValue = nextValue;
|
|
158
|
+
if (!recentSearchesKey) return;
|
|
159
|
+
if (hadWords && !nextValue.trim()) {
|
|
160
|
+
hideRecentSearchesForSession(recentSearchesKey);
|
|
161
|
+
closeRecentPanel();
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
140
165
|
function handleInputInternal(event: Event): void {
|
|
141
166
|
void onInput(event);
|
|
142
167
|
if (!recentSearchesKey) return;
|
|
168
|
+
observeValue(value);
|
|
143
169
|
if (value.trim()) {
|
|
144
170
|
closeRecentPanel();
|
|
145
171
|
} else if (typeof document !== 'undefined' && document.activeElement === inputElement) {
|
|
@@ -219,14 +245,20 @@
|
|
|
219
245
|
}
|
|
220
246
|
|
|
221
247
|
async function handleClearClick(): Promise<void> {
|
|
248
|
+
// The button only exists while there are words: this is a search that is over, so the list of recent searches stays hidden for
|
|
249
|
+
// the rest of the session. It is hidden before the host empties the field, so that nothing can open it in between.
|
|
250
|
+
if (recentSearchesKey) {
|
|
251
|
+
hideRecentSearchesForSession(recentSearchesKey);
|
|
252
|
+
closeRecentPanel();
|
|
253
|
+
}
|
|
222
254
|
onClear();
|
|
223
255
|
try {
|
|
224
256
|
if (!recentSearchesKey) return;
|
|
225
257
|
// The clear button leaves with the words and would take the focus with it: the field takes the focus back, so the keyboard
|
|
226
|
-
// keeps working and
|
|
258
|
+
// keeps working and a new search can start at once. The list stays closed (see above). A field without recent searches is
|
|
259
|
+
// left as it was.
|
|
227
260
|
await tick();
|
|
228
261
|
inputElement?.focus();
|
|
229
|
-
openRecentPanelIfApplicable();
|
|
230
262
|
} catch (error) {
|
|
231
263
|
console.warn('[SearchInput] Could not give the field the focus back after clearing it', error);
|
|
232
264
|
} finally {
|
|
@@ -252,6 +284,9 @@
|
|
|
252
284
|
$: if (recentSearchesKey && value.trim() && recentPanelOpen) {
|
|
253
285
|
closeRecentPanel();
|
|
254
286
|
}
|
|
287
|
+
|
|
288
|
+
// A host can change the words too (restoring a search from the address, emptying the field): every change is looked at
|
|
289
|
+
$: observeValue(value);
|
|
255
290
|
</script>
|
|
256
291
|
|
|
257
292
|
<div class="w-full {recentSearchesKey ? 'relative' : ''} {containerClass}">
|
|
@@ -8,5 +8,9 @@ export declare function readRecentSearches(key: string): string[];
|
|
|
8
8
|
export declare function rememberRecentSearch(key: string, term: string): string[];
|
|
9
9
|
/** Clears the stored list for `key`. Never throws. */
|
|
10
10
|
export declare function clearRecentSearches(key: string): void;
|
|
11
|
-
/**
|
|
11
|
+
/** Hides the recent searches of `key` for the rest of this session (they stay stored). Never throws. */
|
|
12
|
+
export declare function hideRecentSearchesForSession(key: string): void;
|
|
13
|
+
/** True while the recent searches of `key` are hidden for this session. */
|
|
14
|
+
export declare function areRecentSearchesHiddenForSession(key: string): boolean;
|
|
15
|
+
/** Test-only: reset in-memory fallback, the keys hidden for the session, and log latch. */
|
|
12
16
|
export declare function __resetRecentSearchesTestState(): void;
|
|
@@ -117,8 +117,25 @@ export function clearRecentSearches(key) {
|
|
|
117
117
|
removeFromLocalStorage(key);
|
|
118
118
|
memoryFallback.delete(key);
|
|
119
119
|
}
|
|
120
|
-
/**
|
|
120
|
+
/**
|
|
121
|
+
* The keys whose recent searches stay hidden for the rest of this session. A session is the life of the page: the set lives in
|
|
122
|
+
* memory only, so a reload (or a new tab) starts a new one. It is filled when a person searched and then cleared the field:
|
|
123
|
+
* a list of what they searched would only repeat what they just did.
|
|
124
|
+
*/
|
|
125
|
+
const keysHiddenForSession = new Set();
|
|
126
|
+
/** Hides the recent searches of `key` for the rest of this session (they stay stored). Never throws. */
|
|
127
|
+
export function hideRecentSearchesForSession(key) {
|
|
128
|
+
if (!key)
|
|
129
|
+
return;
|
|
130
|
+
keysHiddenForSession.add(key);
|
|
131
|
+
}
|
|
132
|
+
/** True while the recent searches of `key` are hidden for this session. */
|
|
133
|
+
export function areRecentSearchesHiddenForSession(key) {
|
|
134
|
+
return Boolean(key) && keysHiddenForSession.has(key);
|
|
135
|
+
}
|
|
136
|
+
/** Test-only: reset in-memory fallback, the keys hidden for the session, and log latch. */
|
|
121
137
|
export function __resetRecentSearchesTestState() {
|
|
122
138
|
memoryFallback.clear();
|
|
139
|
+
keysHiddenForSession.clear();
|
|
123
140
|
loggedStorageFailure = false;
|
|
124
141
|
}
|
|
@@ -3,15 +3,19 @@
|
|
|
3
3
|
import type { WithElementRef } from 'bits-ui';
|
|
4
4
|
import type { HTMLAnchorAttributes, HTMLButtonAttributes } from 'svelte/elements';
|
|
5
5
|
|
|
6
|
+
// Keyboard focus is drawn as the hover fill, with no ring (owner, 18 Nov 2026: "remove the focus ring around the sidebar
|
|
7
|
+
// elements"). The ring showed up on a row the moment a page was reloaded with the settings dialog open, because the dialog
|
|
8
|
+
// put the focus on its first row. A row that has the focus still looks different from its neighbours, so a person who
|
|
9
|
+
// moves with the keyboard can see where they are, but nothing is drawn around it.
|
|
6
10
|
export const navRowVariants = tv({
|
|
7
|
-
base: 'group/nav-row relative before:absolute before:inset-x-0 before:-inset-y-px flex h-8 w-full min-w-0 items-center gap-2 rounded-lg py-1.5 ps-2 pe-2 text-start transition-colors duration-fast focus-visible:outline-hidden
|
|
11
|
+
base: 'group/nav-row relative before:absolute before:inset-x-0 before:-inset-y-px flex h-8 w-full min-w-0 items-center gap-2 rounded-lg py-1.5 ps-2 pe-2 text-start transition-colors duration-fast focus-visible:outline-hidden active:bg-accent-hover disabled:pointer-events-none disabled:opacity-50 [&_svg]:size-4 [&_svg]:shrink-0 [&_svg]:stroke-2',
|
|
8
12
|
variants: {
|
|
9
13
|
active: {
|
|
10
14
|
true: 'bg-sidebar-accent text-sidebar-accent-foreground text-body-medium active:bg-accent-hover',
|
|
11
15
|
// The inactive row carries its own type style (14/20 regular, Figma Nav Row): without it the label took the size
|
|
12
16
|
// of whatever it sat in (16px in a dialog), bigger than the active row's 14/20 medium.
|
|
13
17
|
false:
|
|
14
|
-
'text-body text-muted-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground active:bg-accent-hover active:text-sidebar-accent-foreground'
|
|
18
|
+
'text-body text-muted-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:bg-sidebar-accent focus-visible:text-sidebar-accent-foreground active:bg-accent-hover active:text-sidebar-accent-foreground'
|
|
15
19
|
}
|
|
16
20
|
},
|
|
17
21
|
defaultVariants: {
|
|
@@ -19,8 +23,23 @@
|
|
|
19
23
|
}
|
|
20
24
|
});
|
|
21
25
|
|
|
26
|
+
/**
|
|
27
|
+
* The filled pill of `trailingVariant="badge"`: the badge a phone draws on an app icon. A solid destructive (red) fill with the
|
|
28
|
+
* number in white, a circle for one digit (`min-w-5` is as wide as the 20px height) and a pill for more (`px-1.5`). It is
|
|
29
|
+
* the design system's Badge (`destructive`) at the size of a counter, so a count that wants attention stands out from the
|
|
30
|
+
* muted text of a count that only informs.
|
|
31
|
+
*/
|
|
32
|
+
export const navRowBadgeClass =
|
|
33
|
+
'inline-flex h-5 min-w-5 shrink-0 items-center justify-center rounded-full bg-destructive px-1.5 text-label-small text-destructive-foreground tabular-nums';
|
|
34
|
+
|
|
35
|
+
/** The muted count to the right of a row (the default): it informs, it does not ask for attention. */
|
|
36
|
+
export const navRowTrailingTextClass = 'text-caption text-muted-foreground shrink-0 tabular-nums';
|
|
37
|
+
|
|
22
38
|
export type NavRowVisualState = 'default' | 'hover' | 'pressed' | 'active' | 'focus' | 'disabled';
|
|
23
39
|
|
|
40
|
+
/** How the text on the right of the row is drawn: muted text (a count that informs) or a filled badge (a count that asks for attention). */
|
|
41
|
+
export type NavRowTrailingVariant = 'text' | 'badge';
|
|
42
|
+
|
|
24
43
|
export type NavRowProps = WithElementRef<HTMLButtonAttributes> &
|
|
25
44
|
WithElementRef<HTMLAnchorAttributes> & {
|
|
26
45
|
ref?: HTMLAnchorElement | HTMLButtonElement | null;
|
|
@@ -32,6 +51,16 @@
|
|
|
32
51
|
showIcon?: boolean;
|
|
33
52
|
showTrailing?: boolean;
|
|
34
53
|
trailing?: string;
|
|
54
|
+
/**
|
|
55
|
+
* `text` (default): muted caption. `badge`: a filled pill like the unread count on a phone's app icon, for a number that
|
|
56
|
+
* wants to be noticed (the unread count of the Inbox).
|
|
57
|
+
*/
|
|
58
|
+
trailingVariant?: NavRowTrailingVariant;
|
|
59
|
+
/**
|
|
60
|
+
* What a screen reader says for the trailing text when the text alone says too little: a badge that shows "3" is "3 unread".
|
|
61
|
+
* When it is set the visible text is hidden from assistive technology and this is read instead.
|
|
62
|
+
*/
|
|
63
|
+
trailingAccessibleLabel?: string;
|
|
35
64
|
/** Showcase-only forced visual state (CSS `:hover` / `:focus-visible` otherwise). */
|
|
36
65
|
visualState?: NavRowVisualState;
|
|
37
66
|
};
|
|
@@ -52,6 +81,8 @@
|
|
|
52
81
|
showIcon = true,
|
|
53
82
|
showTrailing = false,
|
|
54
83
|
trailing = '',
|
|
84
|
+
trailingVariant = 'text',
|
|
85
|
+
trailingAccessibleLabel = undefined,
|
|
55
86
|
visualState = undefined,
|
|
56
87
|
icon,
|
|
57
88
|
iconComponent = undefined,
|
|
@@ -73,12 +104,28 @@
|
|
|
73
104
|
if (!visualState || visualState === 'default' || visualState === 'active') return '';
|
|
74
105
|
if (visualState === 'hover') return 'bg-sidebar-accent text-sidebar-accent-foreground';
|
|
75
106
|
if (visualState === 'pressed') return 'bg-accent-hover text-sidebar-accent-foreground';
|
|
76
|
-
|
|
77
|
-
|
|
107
|
+
// Keyboard focus is the hover fill: no ring is drawn around a sidebar row (see the note above `navRowVariants`)
|
|
108
|
+
if (visualState === 'focus') return 'bg-sidebar-accent text-sidebar-accent-foreground';
|
|
78
109
|
return '';
|
|
79
110
|
});
|
|
80
111
|
</script>
|
|
81
112
|
|
|
113
|
+
<!-- The text on the right of the row, in both the link and the button form of the row -->
|
|
114
|
+
{#snippet trailingContent()}
|
|
115
|
+
{#if showTrailing && trailing}
|
|
116
|
+
{#if trailingVariant === 'badge'}
|
|
117
|
+
<span class={navRowBadgeClass} data-nav-row-badge="">
|
|
118
|
+
<span aria-hidden={trailingAccessibleLabel ? 'true' : undefined}>{trailing}</span>
|
|
119
|
+
{#if trailingAccessibleLabel}
|
|
120
|
+
<span class="sr-only">{trailingAccessibleLabel}</span>
|
|
121
|
+
{/if}
|
|
122
|
+
</span>
|
|
123
|
+
{:else}
|
|
124
|
+
<span class={navRowTrailingTextClass}>{trailing}</span>
|
|
125
|
+
{/if}
|
|
126
|
+
{/if}
|
|
127
|
+
{/snippet}
|
|
128
|
+
|
|
82
129
|
{#if href && !isDisabled}
|
|
83
130
|
<a
|
|
84
131
|
bind:this={ref}
|
|
@@ -99,9 +146,7 @@
|
|
|
99
146
|
</span>
|
|
100
147
|
{/if}
|
|
101
148
|
<span class="min-w-0 flex-1 truncate">{label}</span>
|
|
102
|
-
{
|
|
103
|
-
<span class="text-caption text-muted-foreground shrink-0 tabular-nums">{trailing}</span>
|
|
104
|
-
{/if}
|
|
149
|
+
{@render trailingContent()}
|
|
105
150
|
{@render children?.()}
|
|
106
151
|
</a>
|
|
107
152
|
{:else}
|
|
@@ -124,9 +169,7 @@
|
|
|
124
169
|
</span>
|
|
125
170
|
{/if}
|
|
126
171
|
<span class="min-w-0 flex-1 truncate">{label}</span>
|
|
127
|
-
{
|
|
128
|
-
<span class="text-caption text-muted-foreground shrink-0 tabular-nums">{trailing}</span>
|
|
129
|
-
{/if}
|
|
172
|
+
{@render trailingContent()}
|
|
130
173
|
{@render children?.()}
|
|
131
174
|
</button>
|
|
132
175
|
{/if}
|
|
@@ -5,7 +5,7 @@ export declare const navRowVariants: import("tailwind-variants").TVReturnType<{
|
|
|
5
5
|
true: string;
|
|
6
6
|
false: string;
|
|
7
7
|
};
|
|
8
|
-
}, undefined, "group/nav-row relative before:absolute before:inset-x-0 before:-inset-y-px flex h-8 w-full min-w-0 items-center gap-2 rounded-lg py-1.5 ps-2 pe-2 text-start transition-colors duration-fast focus-visible:outline-hidden
|
|
8
|
+
}, undefined, "group/nav-row relative before:absolute before:inset-x-0 before:-inset-y-px flex h-8 w-full min-w-0 items-center gap-2 rounded-lg py-1.5 ps-2 pe-2 text-start transition-colors duration-fast focus-visible:outline-hidden active:bg-accent-hover disabled:pointer-events-none disabled:opacity-50 [&_svg]:size-4 [&_svg]:shrink-0 [&_svg]:stroke-2", {
|
|
9
9
|
responsiveVariants?: boolean | (string | number | symbol)[] | {
|
|
10
10
|
active?: boolean | (string | number | symbol)[] | undefined;
|
|
11
11
|
} | undefined;
|
|
@@ -27,7 +27,7 @@ export declare const navRowVariants: import("tailwind-variants").TVReturnType<{
|
|
|
27
27
|
true: string;
|
|
28
28
|
false: string;
|
|
29
29
|
};
|
|
30
|
-
}, undefined, "group/nav-row relative before:absolute before:inset-x-0 before:-inset-y-px flex h-8 w-full min-w-0 items-center gap-2 rounded-lg py-1.5 ps-2 pe-2 text-start transition-colors duration-fast focus-visible:outline-hidden
|
|
30
|
+
}, undefined, "group/nav-row relative before:absolute before:inset-x-0 before:-inset-y-px flex h-8 w-full min-w-0 items-center gap-2 rounded-lg py-1.5 ps-2 pe-2 text-start transition-colors duration-fast focus-visible:outline-hidden active:bg-accent-hover disabled:pointer-events-none disabled:opacity-50 [&_svg]:size-4 [&_svg]:shrink-0 [&_svg]:stroke-2", import("tailwind-variants/dist/config.js").TVConfig<{
|
|
31
31
|
active: {
|
|
32
32
|
true: string;
|
|
33
33
|
false: string;
|
|
@@ -38,7 +38,18 @@ export declare const navRowVariants: import("tailwind-variants").TVReturnType<{
|
|
|
38
38
|
false: string;
|
|
39
39
|
};
|
|
40
40
|
}>, unknown, unknown, undefined>>;
|
|
41
|
+
/**
|
|
42
|
+
* The filled pill of `trailingVariant="badge"`: the badge a phone draws on an app icon. A solid destructive (red) fill with the
|
|
43
|
+
* number in white, a circle for one digit (`min-w-5` is as wide as the 20px height) and a pill for more (`px-1.5`). It is
|
|
44
|
+
* the design system's Badge (`destructive`) at the size of a counter, so a count that wants attention stands out from the
|
|
45
|
+
* muted text of a count that only informs.
|
|
46
|
+
*/
|
|
47
|
+
export declare const navRowBadgeClass = "inline-flex h-5 min-w-5 shrink-0 items-center justify-center rounded-full bg-destructive px-1.5 text-label-small text-destructive-foreground tabular-nums";
|
|
48
|
+
/** The muted count to the right of a row (the default): it informs, it does not ask for attention. */
|
|
49
|
+
export declare const navRowTrailingTextClass = "text-caption text-muted-foreground shrink-0 tabular-nums";
|
|
41
50
|
export type NavRowVisualState = 'default' | 'hover' | 'pressed' | 'active' | 'focus' | 'disabled';
|
|
51
|
+
/** How the text on the right of the row is drawn: muted text (a count that informs) or a filled badge (a count that asks for attention). */
|
|
52
|
+
export type NavRowTrailingVariant = 'text' | 'badge';
|
|
42
53
|
export type NavRowProps = WithElementRef<HTMLButtonAttributes> & WithElementRef<HTMLAnchorAttributes> & {
|
|
43
54
|
ref?: HTMLAnchorElement | HTMLButtonElement | null;
|
|
44
55
|
class?: string;
|
|
@@ -49,6 +60,16 @@ export type NavRowProps = WithElementRef<HTMLButtonAttributes> & WithElementRef<
|
|
|
49
60
|
showIcon?: boolean;
|
|
50
61
|
showTrailing?: boolean;
|
|
51
62
|
trailing?: string;
|
|
63
|
+
/**
|
|
64
|
+
* `text` (default): muted caption. `badge`: a filled pill like the unread count on a phone's app icon, for a number that
|
|
65
|
+
* wants to be noticed (the unread count of the Inbox).
|
|
66
|
+
*/
|
|
67
|
+
trailingVariant?: NavRowTrailingVariant;
|
|
68
|
+
/**
|
|
69
|
+
* What a screen reader says for the trailing text when the text alone says too little: a badge that shows "3" is "3 unread".
|
|
70
|
+
* When it is set the visible text is hidden from assistive technology and this is read instead.
|
|
71
|
+
*/
|
|
72
|
+
trailingAccessibleLabel?: string;
|
|
52
73
|
/** Showcase-only forced visual state (CSS `:hover` / `:focus-visible` otherwise). */
|
|
53
74
|
visualState?: NavRowVisualState;
|
|
54
75
|
};
|
|
@@ -39,7 +39,8 @@
|
|
|
39
39
|
|
|
40
40
|
const rowClass = $derived(
|
|
41
41
|
cn(
|
|
42
|
-
|
|
42
|
+
// No colour transition on a list row (owner, 18 Nov 2026): the hover tint is a 4% tint, a 120ms fade made the hover show late
|
|
43
|
+
'group flex w-full items-center gap-4 rounded-xl px-4 py-3 text-start hover:bg-accent focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background',
|
|
43
44
|
className
|
|
44
45
|
)
|
|
45
46
|
);
|
|
@@ -51,7 +52,7 @@
|
|
|
51
52
|
|
|
52
53
|
{#snippet rowInner()}
|
|
53
54
|
<span
|
|
54
|
-
class="bg-muted text-foreground
|
|
55
|
+
class="bg-muted text-foreground group-hover:bg-background flex size-10 shrink-0 items-center justify-center rounded-lg"
|
|
55
56
|
>
|
|
56
57
|
{@render icon()}
|
|
57
58
|
</span>
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
<!-- Figma: Profile Row (component set 53:3, node 53:3). -->
|
|
2
2
|
<script lang="ts" module>
|
|
3
|
+
// No focus ring (owner, 18 Nov 2026: "remove the focus ring around the sidebar elements"): keyboard focus is drawn as the
|
|
4
|
+
// hover fill, like a Nav Row's.
|
|
3
5
|
export const profileRowVariants = tv({
|
|
4
|
-
base: 'flex h-12 w-full min-w-0 items-center gap-2 rounded-lg p-2 text-start transition-colors duration-fast focus-visible:outline-hidden
|
|
6
|
+
base: 'flex h-12 w-full min-w-0 items-center gap-2 rounded-lg p-2 text-start transition-colors duration-fast focus-visible:outline-hidden',
|
|
5
7
|
variants: {
|
|
6
8
|
interactive: {
|
|
7
|
-
true: 'cursor-pointer hover:bg-sidebar-accent',
|
|
9
|
+
true: 'cursor-pointer hover:bg-sidebar-accent focus-visible:bg-sidebar-accent',
|
|
8
10
|
false: ''
|
|
9
11
|
}
|
|
10
12
|
},
|
|
@@ -49,8 +51,8 @@
|
|
|
49
51
|
const showcaseClass = $derived.by(() => {
|
|
50
52
|
if (!visualState || visualState === 'default') return '';
|
|
51
53
|
if (visualState === 'hover') return 'bg-sidebar-accent';
|
|
52
|
-
|
|
53
|
-
|
|
54
|
+
// Keyboard focus is the hover fill: no ring is drawn around a sidebar row
|
|
55
|
+
if (visualState === 'focus') return 'bg-sidebar-accent';
|
|
54
56
|
return '';
|
|
55
57
|
});
|
|
56
58
|
|
|
@@ -3,7 +3,7 @@ export declare const profileRowVariants: import("tailwind-variants").TVReturnTyp
|
|
|
3
3
|
true: string;
|
|
4
4
|
false: string;
|
|
5
5
|
};
|
|
6
|
-
}, undefined, "flex h-12 w-full min-w-0 items-center gap-2 rounded-lg p-2 text-start transition-colors duration-fast focus-visible:outline-hidden
|
|
6
|
+
}, undefined, "flex h-12 w-full min-w-0 items-center gap-2 rounded-lg p-2 text-start transition-colors duration-fast focus-visible:outline-hidden", {
|
|
7
7
|
responsiveVariants?: boolean | (string | number | symbol)[] | {
|
|
8
8
|
interactive?: boolean | (string | number | symbol)[] | undefined;
|
|
9
9
|
} | undefined;
|
|
@@ -25,7 +25,7 @@ export declare const profileRowVariants: import("tailwind-variants").TVReturnTyp
|
|
|
25
25
|
true: string;
|
|
26
26
|
false: string;
|
|
27
27
|
};
|
|
28
|
-
}, undefined, "flex h-12 w-full min-w-0 items-center gap-2 rounded-lg p-2 text-start transition-colors duration-fast focus-visible:outline-hidden
|
|
28
|
+
}, undefined, "flex h-12 w-full min-w-0 items-center gap-2 rounded-lg p-2 text-start transition-colors duration-fast focus-visible:outline-hidden", import("tailwind-variants/dist/config.js").TVConfig<{
|
|
29
29
|
interactive: {
|
|
30
30
|
true: string;
|
|
31
31
|
false: string;
|
|
@@ -110,6 +110,25 @@
|
|
|
110
110
|
);
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
+
// "Settings Panel": settingsPanelElement, the dialog's own box, which bits-ui makes focusable (`tabindex="-1"`) through the focus scope
|
|
114
|
+
let settingsPanelElement = $state<HTMLElement | null>(null);
|
|
115
|
+
|
|
116
|
+
// By default bits-ui puts the focus on the first tabbable element when the dialog opens, and in this dialog that is the first
|
|
117
|
+
// row of the navigation. A page reloaded with Settings open therefore opened with "Workspace settings" focused, which a
|
|
118
|
+
// keyboard-focus style is drawn on even when the page that is open is another (owner, 18 Nov 2026). The dialog takes the
|
|
119
|
+
// focus itself instead: the screen reader reads its title, Tab moves to the first row, and nothing is highlighted before
|
|
120
|
+
// the person has done anything. The focus stays inside the dialog, so the focus trap is not weakened.
|
|
121
|
+
function handleOpenAutoFocus(event: Event): void {
|
|
122
|
+
event.preventDefault();
|
|
123
|
+
requestAnimationFrame(() => {
|
|
124
|
+
try {
|
|
125
|
+
settingsPanelElement?.focus({ preventScroll: true });
|
|
126
|
+
} catch (error) {
|
|
127
|
+
console.warn('[SettingsDialog] Could not move the focus to the dialog panel', error);
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
|
|
113
132
|
// Parent keeps pe-8 (32px): the cards of a page end on that line. When the page scrolls we pull the scroll area into that
|
|
114
133
|
// padding, so the bar is drawn in the margin right of the cards, close to the dialog edge, and never over a card.
|
|
115
134
|
const PANE_RIGHT_PADDING_PX = 32;
|
|
@@ -150,10 +169,12 @@
|
|
|
150
169
|
<!-- The scrim is the shared one of every overlay (muted foreground at 80%, 3px blur), set by the dialog overlay itself -->
|
|
151
170
|
<Dialog.Overlay />
|
|
152
171
|
<DialogPrimitive.Content
|
|
172
|
+
bind:ref={settingsPanelElement}
|
|
153
173
|
forceMount
|
|
154
174
|
aria-describedby={description || descriptionSlot ? 'settings-dialog-description' : undefined}
|
|
155
175
|
trapFocus={!nestedModalOpen}
|
|
156
176
|
onEscapeKeydown={handleEscapeKeydown}
|
|
177
|
+
onOpenAutoFocus={handleOpenAutoFocus}
|
|
157
178
|
class={className}
|
|
158
179
|
>
|
|
159
180
|
{#snippet child({ props, open })}
|
|
@@ -164,7 +185,8 @@
|
|
|
164
185
|
data-widgetic-overlay="dialog-panel"
|
|
165
186
|
style:z-index|important={overlayLayerContext.ensureLayer().scrimZ + 1}
|
|
166
187
|
class={cn(
|
|
167
|
-
|
|
188
|
+
// outline-hidden: the panel holds the focus when the dialog opens (see handleOpenAutoFocus) and must not draw a ring
|
|
189
|
+
'border-border bg-background fixed flex overflow-hidden border outline-hidden',
|
|
168
190
|
overlayReducedMotionClasses,
|
|
169
191
|
'inset-0 h-full max-h-none w-full rounded-none',
|
|
170
192
|
// Centred with auto margins, not with a translate: a CSS transform would make this box the containing block
|
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
import type { VariantProps } from 'tailwind-variants';
|
|
4
4
|
|
|
5
5
|
export const widgetRowVariants = tv({
|
|
6
|
-
|
|
6
|
+
// No colour transition on a list row (owner, 18 Nov 2026: hover "used to be instant, now there's a lag"): the hover tint is a 4% tint, so a 120ms fade shows nothing for ~110ms and the row looks late; it must switch on the frame the pointer arrives.
|
|
7
|
+
base: 'group/widget-row flex h-16 max-h-16 w-full shrink-0 items-center gap-4 overflow-hidden rounded-xl py-3 ps-4 pe-4 focus-within:outline-hidden',
|
|
7
8
|
variants: {
|
|
8
9
|
selected: {
|
|
9
10
|
true: 'bg-brand-subtle ring-2 ring-brand',
|
|
@@ -101,7 +102,7 @@
|
|
|
101
102
|
>
|
|
102
103
|
<div
|
|
103
104
|
class={cn(
|
|
104
|
-
'bg-muted
|
|
105
|
+
'bg-muted group-hover/widget-row:bg-background flex size-10 shrink-0 items-center justify-center overflow-hidden rounded-lg',
|
|
105
106
|
forceHover && 'bg-background'
|
|
106
107
|
)}
|
|
107
108
|
>
|
|
@@ -145,7 +146,7 @@
|
|
|
145
146
|
{#if actions}
|
|
146
147
|
<div
|
|
147
148
|
class={cn(
|
|
148
|
-
'
|
|
149
|
+
'shrink-0 opacity-0 group-focus-within/widget-row:opacity-100 group-hover/widget-row:opacity-100',
|
|
149
150
|
(actionsAlwaysVisible || forceHover || forceFocus) && 'opacity-100'
|
|
150
151
|
)}
|
|
151
152
|
>
|
|
@@ -7,7 +7,7 @@ export declare const widgetRowVariants: import("tailwind-variants").TVReturnType
|
|
|
7
7
|
true: string;
|
|
8
8
|
false: string;
|
|
9
9
|
};
|
|
10
|
-
}, undefined, "group/widget-row flex h-16 max-h-16 w-full shrink-0 items-center gap-4 overflow-hidden rounded-xl py-3 ps-4 pe-4
|
|
10
|
+
}, undefined, "group/widget-row flex h-16 max-h-16 w-full shrink-0 items-center gap-4 overflow-hidden rounded-xl py-3 ps-4 pe-4 focus-within:outline-hidden", {
|
|
11
11
|
responsiveVariants?: boolean | (string | number | symbol)[] | {
|
|
12
12
|
selected?: boolean | (string | number | symbol)[] | undefined;
|
|
13
13
|
loading?: boolean | (string | number | symbol)[] | undefined;
|
|
@@ -38,7 +38,7 @@ export declare const widgetRowVariants: import("tailwind-variants").TVReturnType
|
|
|
38
38
|
true: string;
|
|
39
39
|
false: string;
|
|
40
40
|
};
|
|
41
|
-
}, undefined, "group/widget-row flex h-16 max-h-16 w-full shrink-0 items-center gap-4 overflow-hidden rounded-xl py-3 ps-4 pe-4
|
|
41
|
+
}, undefined, "group/widget-row flex h-16 max-h-16 w-full shrink-0 items-center gap-4 overflow-hidden rounded-xl py-3 ps-4 pe-4 focus-within:outline-hidden", import("tailwind-variants/dist/config.js").TVConfig<{
|
|
42
42
|
selected: {
|
|
43
43
|
true: string;
|
|
44
44
|
false: string;
|