@r2digisolutions/components 0.25.20 → 0.26.0
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/README.md +4 -0
- package/WORKSPACE.md +48 -0
- package/dist/components/molecules/ActionRow/ActionRow.stories.js +9 -0
- package/dist/components/molecules/ActionRow/ActionRow.svelte +84 -0
- package/dist/components/molecules/ActionRow/ActionRow.svelte.d.ts +31 -0
- package/dist/components/molecules/ActionRow/ActionRowStory.svelte +36 -0
- package/dist/components/molecules/ActionRow/ActionRowStory.svelte.d.ts +18 -0
- package/dist/components/molecules/Card/Card.svelte +4 -0
- package/dist/components/molecules/Card/Card.svelte.d.ts +2 -0
- package/dist/components/molecules/EntityHero/EntityHero.stories.js +9 -0
- package/dist/components/molecules/EntityHero/EntityHero.svelte +162 -0
- package/dist/components/molecules/EntityHero/EntityHero.svelte.d.ts +37 -0
- package/dist/components/molecules/EntityHero/EntityHeroStory.svelte +28 -0
- package/dist/components/molecules/EntityHero/EntityHeroStory.svelte.d.ts +18 -0
- package/dist/components/molecules/OrgSwitcher/OrgSwitcher.svelte +68 -23
- package/dist/components/molecules/OrgSwitcher/OrgSwitcher.svelte.d.ts +12 -0
- package/dist/components/molecules/SectionNav/SectionNav.stories.d.ts +12 -0
- package/dist/components/molecules/SectionNav/SectionNav.stories.js +9 -0
- package/dist/components/molecules/SectionNav/SectionNav.svelte +139 -0
- package/dist/components/molecules/SectionNav/SectionNav.svelte.d.ts +41 -0
- package/dist/components/molecules/SectionNav/SectionNavStory.svelte +48 -0
- package/dist/components/molecules/SectionNav/SectionNavStory.svelte.d.ts +3 -0
- package/dist/components/molecules/StatCard/StatCard.svelte +51 -15
- package/dist/components/molecules/StatCard/StatCard.svelte.d.ts +13 -2
- package/dist/components/organisms/BottomNav/BottomNav.svelte +93 -53
- package/dist/components/organisms/BottomNav/BottomNav.svelte.d.ts +17 -2
- package/dist/components/organisms/NavRail/NavRail.svelte +106 -34
- package/dist/components/organisms/NavRail/NavRail.svelte.d.ts +12 -0
- package/dist/components/organisms/ProfilePicker/ProfilePicker.stories.d.ts +12 -0
- package/dist/components/organisms/ProfilePicker/ProfilePicker.stories.js +9 -0
- package/dist/components/organisms/ProfilePicker/ProfilePicker.svelte +183 -0
- package/dist/components/organisms/ProfilePicker/ProfilePicker.svelte.d.ts +37 -0
- package/dist/components/organisms/ProfilePicker/ProfilePickerStory.svelte +18 -0
- package/dist/components/organisms/ProfilePicker/ProfilePickerStory.svelte.d.ts +3 -0
- package/dist/components/organisms/WorkspaceShell/WorkspaceShell.stories.d.ts +12 -0
- package/dist/components/organisms/WorkspaceShell/WorkspaceShell.stories.js +9 -0
- package/dist/components/organisms/WorkspaceShell/WorkspaceShell.svelte +75 -0
- package/dist/components/organisms/WorkspaceShell/WorkspaceShell.svelte.d.ts +30 -0
- package/dist/components/organisms/WorkspaceShell/WorkspaceShellStory.svelte +71 -0
- package/dist/components/organisms/WorkspaceShell/WorkspaceShellStory.svelte.d.ts +3 -0
- package/dist/index.d.ts +11 -2
- package/dist/index.js +5 -0
- package/package.json +2 -1
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
+
import type { Component } from 'svelte';
|
|
3
|
+
|
|
4
|
+
export type BottomNavIconComponent = Component<{
|
|
5
|
+
class?: string;
|
|
6
|
+
size?: number | string;
|
|
7
|
+
strokeWidth?: number | string;
|
|
8
|
+
}>;
|
|
9
|
+
|
|
2
10
|
export type BottomNavIcon =
|
|
3
11
|
| 'home'
|
|
4
12
|
| 'search'
|
|
@@ -19,6 +27,10 @@
|
|
|
19
27
|
id: string;
|
|
20
28
|
label: string;
|
|
21
29
|
icon?: BottomNavIcon;
|
|
30
|
+
/** Any icon component (e.g. Lucide). Wins over `icon`. */
|
|
31
|
+
iconComponent?: BottomNavIconComponent;
|
|
32
|
+
/** Render as a link (SvelteKit navigation) instead of a button. */
|
|
33
|
+
href?: string;
|
|
22
34
|
badge?: string | number;
|
|
23
35
|
disabled?: boolean;
|
|
24
36
|
/** Center FAB (Flutter CircularNotchedRectangle) */
|
|
@@ -34,8 +46,13 @@
|
|
|
34
46
|
* floating — inset rounded card (Flutter demos)
|
|
35
47
|
* pill — capsule
|
|
36
48
|
* notch — floating + explicit SVG CircularNotchedRectangle
|
|
49
|
+
* docked — full-width bar with a top border; the FAB pokes out of it (workspace apps)
|
|
37
50
|
*/
|
|
38
|
-
variant?: 'default' | 'floating' | 'pill' | 'notch';
|
|
51
|
+
variant?: 'default' | 'floating' | 'pill' | 'notch' | 'docked';
|
|
52
|
+
/** FAB shape: round, or a rounded square (workspace look). */
|
|
53
|
+
fabShape?: 'circle' | 'square';
|
|
54
|
+
/** Active item: soft pill behind the icon, or just the brand colour. */
|
|
55
|
+
activeStyle?: 'pill' | 'color';
|
|
39
56
|
showLabels?: boolean;
|
|
40
57
|
blur?: boolean;
|
|
41
58
|
/** Colored FAB background (CSS color or token class handled via style) */
|
|
@@ -51,6 +68,8 @@
|
|
|
51
68
|
value = $bindable(''),
|
|
52
69
|
size = 'md',
|
|
53
70
|
variant = 'notch',
|
|
71
|
+
fabShape = 'circle',
|
|
72
|
+
activeStyle = 'pill',
|
|
54
73
|
showLabels = true,
|
|
55
74
|
blur = false,
|
|
56
75
|
fabClass = 'bg-brand-500 hover:bg-brand-600',
|
|
@@ -65,7 +84,8 @@
|
|
|
65
84
|
plus: 'M12 5v14M5 12h14',
|
|
66
85
|
inbox: 'M4 6h16v12H4V6zm0 4l8 5 8-5',
|
|
67
86
|
user: 'M20 21v-2a4 4 0 00-4-4H8a4 4 0 00-4 4v2M12 11a4 4 0 100-8 4 4 0 000 8z',
|
|
68
|
-
heart:
|
|
87
|
+
heart:
|
|
88
|
+
'M20.8 5.6a5 5 0 00-7.1 0L12 7.3l-1.7-1.7a5 5 0 00-7.1 7.1l1.7 1.7L12 21.5l7.1-7.1 1.7-1.7a5 5 0 000-7.1z',
|
|
69
89
|
grid: 'M4 4h7v7H4V4zm9 0h7v7h-7V4zM4 13h7v7H4v-7zm9 0h7v7h-7v-7z',
|
|
70
90
|
bell: 'M15 17h5l-1.4-1.4A2 2 0 0118 14v-3a6 6 0 10-12 0v3c0 .5-.2 1-.6 1.4L4 17h5m6 0a3 3 0 11-6 0',
|
|
71
91
|
bookmark: 'M7 4h10a1 1 0 011 1v16l-6-3-6 3V5a1 1 0 011-1z',
|
|
@@ -130,41 +150,50 @@
|
|
|
130
150
|
|
|
131
151
|
{#snippet navItem(item: BottomNavItem)}
|
|
132
152
|
{@const active = value === item.id}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
153
|
+
<!-- svelte-ignore a11y_no_static_element_interactions (a or button, both interactive) -->
|
|
154
|
+
<svelte:element
|
|
155
|
+
this={item.href && !item.disabled ? 'a' : 'button'}
|
|
156
|
+
href={item.href && !item.disabled ? item.href : undefined}
|
|
157
|
+
type={item.href && !item.disabled ? undefined : 'button'}
|
|
158
|
+
disabled={item.href ? undefined : item.disabled}
|
|
136
159
|
onclick={() => select(item.id, item.disabled)}
|
|
137
160
|
aria-current={active ? 'page' : undefined}
|
|
138
161
|
class={[
|
|
139
|
-
'group
|
|
162
|
+
'group min-w-0 gap-0.5 px-1 relative flex flex-1 flex-col items-center justify-center',
|
|
140
163
|
'rounded-xl transition-colors duration-200',
|
|
141
|
-
'focus-visible:
|
|
164
|
+
'focus-visible:ring-brand-500/30 focus-visible:ring-2 focus-visible:outline-none',
|
|
142
165
|
active ? 'text-brand-600 dark:text-brand-400' : 'text-muted hover:text-primary',
|
|
143
166
|
item.disabled && 'cursor-not-allowed opacity-40'
|
|
144
167
|
]}
|
|
145
168
|
>
|
|
146
169
|
<span
|
|
147
170
|
class={[
|
|
148
|
-
'relative inline-flex items-center justify-center
|
|
171
|
+
'rounded-2xl relative inline-flex items-center justify-center transition-[transform,background-color,box-shadow] duration-200',
|
|
149
172
|
sizes.iconWrap,
|
|
150
|
-
active
|
|
151
|
-
? '
|
|
152
|
-
:
|
|
173
|
+
active && activeStyle === 'color'
|
|
174
|
+
? 'text-brand-700 dark:text-brand-300'
|
|
175
|
+
: active
|
|
176
|
+
? 'bg-brand-500/12 text-brand-600 dark:text-brand-400 shadow-[inset_0_0_0_1px_color-mix(in_oklab,var(--color-brand-500)_22%,transparent)]'
|
|
177
|
+
: 'group-hover:bg-surface-overlay/80 bg-transparent'
|
|
153
178
|
]}
|
|
154
179
|
>
|
|
155
|
-
|
|
156
|
-
class={sizes.icon}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
180
|
+
{#if item.iconComponent}
|
|
181
|
+
<item.iconComponent class={sizes.icon} strokeWidth={active ? 2.25 : 1.85} />
|
|
182
|
+
{:else}
|
|
183
|
+
<svg
|
|
184
|
+
class={sizes.icon}
|
|
185
|
+
viewBox="0 0 24 24"
|
|
186
|
+
fill="none"
|
|
187
|
+
stroke="currentColor"
|
|
188
|
+
stroke-width={active ? '2.25' : '1.85'}
|
|
189
|
+
aria-hidden="true"
|
|
190
|
+
>
|
|
191
|
+
<path stroke-linecap="round" stroke-linejoin="round" d={iconPaths[item.icon ?? 'home']} />
|
|
192
|
+
</svg>
|
|
193
|
+
{/if}
|
|
165
194
|
{#if item.badge !== undefined && item.badge !== ''}
|
|
166
195
|
<span
|
|
167
|
-
class="
|
|
196
|
+
class="-right-1.5 -top-1 h-4 min-w-4 bg-red-500 ring-surface-elevated ring-2 px-1 font-semibold text-white shadow-sm absolute flex items-center justify-center rounded-full text-[9px]"
|
|
168
197
|
>
|
|
169
198
|
{item.badge}
|
|
170
199
|
</span>
|
|
@@ -173,21 +202,23 @@
|
|
|
173
202
|
{#if showLabels}
|
|
174
203
|
<span
|
|
175
204
|
class={[
|
|
176
|
-
'
|
|
205
|
+
'font-medium truncate leading-none transition-colors',
|
|
177
206
|
sizes.label,
|
|
178
|
-
active && 'text-brand-
|
|
207
|
+
active && 'font-semibold text-brand-700 dark:text-brand-300'
|
|
179
208
|
]}
|
|
180
209
|
>
|
|
181
210
|
{item.label}
|
|
182
211
|
</span>
|
|
183
212
|
{/if}
|
|
184
|
-
</
|
|
213
|
+
</svelte:element>
|
|
185
214
|
{/snippet}
|
|
186
215
|
|
|
187
216
|
<nav
|
|
188
217
|
class={[
|
|
189
218
|
'relative w-full',
|
|
190
|
-
fabItem && sizes.pad,
|
|
219
|
+
fabItem && variant !== 'docked' && sizes.pad,
|
|
220
|
+
variant === 'docked' &&
|
|
221
|
+
'border-border bg-surface-elevated pb-[max(0.25rem,env(safe-area-inset-bottom))] border-t',
|
|
191
222
|
(variant === 'floating' || variant === 'notch' || variant === 'pill') &&
|
|
192
223
|
'px-3 pb-[max(0.5rem,env(safe-area-inset-bottom))]',
|
|
193
224
|
variant === 'default' && 'pb-[max(0.25rem,env(safe-area-inset-bottom))]',
|
|
@@ -198,64 +229,73 @@
|
|
|
198
229
|
style="--notch-r: {sizes.notch}px; --fab-gap: {sizes.gap}px;"
|
|
199
230
|
>
|
|
200
231
|
{#if fabItem}
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
232
|
+
<!-- svelte-ignore a11y_no_static_element_interactions (a or button, both interactive) -->
|
|
233
|
+
<svelte:element
|
|
234
|
+
this={fabItem.href && !fabItem.disabled ? 'a' : 'button'}
|
|
235
|
+
href={fabItem.href && !fabItem.disabled ? fabItem.href : undefined}
|
|
236
|
+
type={fabItem.href && !fabItem.disabled ? undefined : 'button'}
|
|
237
|
+
disabled={fabItem.href ? undefined : fabItem.disabled}
|
|
204
238
|
onclick={() => select(fabItem.id, fabItem.disabled)}
|
|
205
239
|
aria-label={fabItem.label}
|
|
206
240
|
class={[
|
|
207
|
-
'absolute left-1/2
|
|
208
|
-
'
|
|
209
|
-
'
|
|
241
|
+
'text-white absolute left-1/2 z-20 flex -translate-x-1/2 items-center justify-center',
|
|
242
|
+
fabShape === 'square' ? 'rounded-[1.15rem]' : 'rounded-full',
|
|
243
|
+
variant === 'docked' ? '-top-5 shadow-[0_10px_24px_-6px_color-mix(in_oklab,var(--color-brand-700)_55%,transparent)]' : 'top-0 shadow-[0_10px_28px_rgba(0,0,0,0.28)]',
|
|
244
|
+
'transition-all duration-200 active:scale-95',
|
|
245
|
+
'focus-visible:ring-brand-500/40 focus-visible:ring-offset-surface focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none',
|
|
210
246
|
sizes.fab,
|
|
211
247
|
fabClass,
|
|
212
248
|
fabItem.disabled && 'cursor-not-allowed opacity-40',
|
|
213
|
-
value === fabItem.id && 'ring-
|
|
249
|
+
value === fabItem.id && 'ring-brand-300/60 ring-offset-surface ring-2 ring-offset-2'
|
|
214
250
|
]}
|
|
215
251
|
>
|
|
216
|
-
|
|
217
|
-
class={sizes.fabIcon}
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
252
|
+
{#if fabItem.iconComponent}
|
|
253
|
+
<fabItem.iconComponent class={sizes.fabIcon} strokeWidth={2.5} />
|
|
254
|
+
{:else}
|
|
255
|
+
<svg
|
|
256
|
+
class={sizes.fabIcon}
|
|
257
|
+
viewBox="0 0 24 24"
|
|
258
|
+
fill="none"
|
|
259
|
+
stroke="currentColor"
|
|
260
|
+
stroke-width="2.5"
|
|
261
|
+
aria-hidden="true"
|
|
262
|
+
>
|
|
263
|
+
<path
|
|
264
|
+
stroke-linecap="round"
|
|
265
|
+
stroke-linejoin="round"
|
|
266
|
+
d={iconPaths[fabItem.icon ?? 'plus']}
|
|
267
|
+
/>
|
|
268
|
+
</svg>
|
|
269
|
+
{/if}
|
|
270
|
+
</svelte:element>
|
|
231
271
|
{/if}
|
|
232
272
|
|
|
233
273
|
<div
|
|
234
274
|
class={[
|
|
235
275
|
'relative flex w-full items-center',
|
|
236
276
|
sizes.bar,
|
|
237
|
-
variant === 'default' && 'bg-transparent',
|
|
277
|
+
(variant === 'default' || variant === 'docked') && 'bg-transparent',
|
|
238
278
|
(variant === 'floating' || variant === 'notch') && 'rounded-2xl bg-surface-elevated',
|
|
239
|
-
variant === 'pill' && '
|
|
279
|
+
variant === 'pill' && 'bg-surface-elevated rounded-full',
|
|
240
280
|
elevated && variant !== 'default' && 'shadow-lg',
|
|
241
281
|
blur && variant !== 'default' && 'bg-surface-elevated/95 backdrop-blur-md',
|
|
242
282
|
useNotch && 'notched-bar'
|
|
243
283
|
]}
|
|
244
284
|
>
|
|
245
285
|
{#if fabItem}
|
|
246
|
-
<div class="
|
|
286
|
+
<div class="min-w-0 px-1 flex flex-1 items-center self-stretch">
|
|
247
287
|
{#each leftItems as item (item.id)}
|
|
248
288
|
{@render navItem(item)}
|
|
249
289
|
{/each}
|
|
250
290
|
</div>
|
|
251
291
|
<div class="w-[var(--fab-gap)] shrink-0 self-stretch" aria-hidden="true"></div>
|
|
252
|
-
<div class="
|
|
292
|
+
<div class="min-w-0 px-1 flex flex-1 items-center self-stretch">
|
|
253
293
|
{#each rightItems as item (item.id)}
|
|
254
294
|
{@render navItem(item)}
|
|
255
295
|
{/each}
|
|
256
296
|
</div>
|
|
257
297
|
{:else}
|
|
258
|
-
<div class="flex w-full items-center self-stretch
|
|
298
|
+
<div class="px-1 flex w-full items-center self-stretch">
|
|
259
299
|
{#each items as item (item.id)}
|
|
260
300
|
{@render navItem(item)}
|
|
261
301
|
{/each}
|
|
@@ -1,8 +1,18 @@
|
|
|
1
|
+
import type { Component } from 'svelte';
|
|
2
|
+
export type BottomNavIconComponent = Component<{
|
|
3
|
+
class?: string;
|
|
4
|
+
size?: number | string;
|
|
5
|
+
strokeWidth?: number | string;
|
|
6
|
+
}>;
|
|
1
7
|
export type BottomNavIcon = 'home' | 'search' | 'plus' | 'inbox' | 'user' | 'heart' | 'grid' | 'bell' | 'bookmark' | 'compass' | 'chat' | 'settings' | 'music' | 'mail';
|
|
2
8
|
export interface BottomNavItem {
|
|
3
9
|
id: string;
|
|
4
10
|
label: string;
|
|
5
11
|
icon?: BottomNavIcon;
|
|
12
|
+
/** Any icon component (e.g. Lucide). Wins over `icon`. */
|
|
13
|
+
iconComponent?: BottomNavIconComponent;
|
|
14
|
+
/** Render as a link (SvelteKit navigation) instead of a button. */
|
|
15
|
+
href?: string;
|
|
6
16
|
badge?: string | number;
|
|
7
17
|
disabled?: boolean;
|
|
8
18
|
/** Center FAB (Flutter CircularNotchedRectangle) */
|
|
@@ -17,8 +27,13 @@ interface BottomNavProps {
|
|
|
17
27
|
* floating — inset rounded card (Flutter demos)
|
|
18
28
|
* pill — capsule
|
|
19
29
|
* notch — floating + explicit SVG CircularNotchedRectangle
|
|
30
|
+
* docked — full-width bar with a top border; the FAB pokes out of it (workspace apps)
|
|
20
31
|
*/
|
|
21
|
-
variant?: 'default' | 'floating' | 'pill' | 'notch';
|
|
32
|
+
variant?: 'default' | 'floating' | 'pill' | 'notch' | 'docked';
|
|
33
|
+
/** FAB shape: round, or a rounded square (workspace look). */
|
|
34
|
+
fabShape?: 'circle' | 'square';
|
|
35
|
+
/** Active item: soft pill behind the icon, or just the brand colour. */
|
|
36
|
+
activeStyle?: 'pill' | 'color';
|
|
22
37
|
showLabels?: boolean;
|
|
23
38
|
blur?: boolean;
|
|
24
39
|
/** Colored FAB background (CSS color or token class handled via style) */
|
|
@@ -28,6 +43,6 @@ interface BottomNavProps {
|
|
|
28
43
|
class?: string;
|
|
29
44
|
onchange?: (id: string) => void;
|
|
30
45
|
}
|
|
31
|
-
declare const BottomNav:
|
|
46
|
+
declare const BottomNav: Component<BottomNavProps, {}, "value">;
|
|
32
47
|
type BottomNav = ReturnType<typeof BottomNav>;
|
|
33
48
|
export default BottomNav;
|
|
@@ -16,14 +16,27 @@
|
|
|
16
16
|
href?: string;
|
|
17
17
|
icon?: NavRailIcon;
|
|
18
18
|
disabled?: boolean;
|
|
19
|
+
/** Small counter on the icon (pending items). Hidden when 0 or empty. */
|
|
20
|
+
badge?: string | number;
|
|
19
21
|
}
|
|
20
22
|
|
|
23
|
+
export type NavRailVariant = 'default' | 'solid';
|
|
24
|
+
|
|
21
25
|
interface NavRailProps {
|
|
22
26
|
items?: NavRailItem[];
|
|
23
27
|
footerItems?: NavRailItem[];
|
|
24
28
|
value?: string;
|
|
29
|
+
/**
|
|
30
|
+
* default — neutral surface, icon-only with tooltips.
|
|
31
|
+
* solid — brand-coloured bar (workspace apps), works best with `showLabels`.
|
|
32
|
+
*/
|
|
33
|
+
variant?: NavRailVariant;
|
|
34
|
+
/** Show the label under each icon (wider rail, no tooltip). */
|
|
35
|
+
showLabels?: boolean;
|
|
25
36
|
class?: string;
|
|
26
37
|
brand?: Snippet;
|
|
38
|
+
/** Rendered at the very bottom (avatar, account menu…). */
|
|
39
|
+
footer?: Snippet;
|
|
27
40
|
onchange?: (id: string) => void;
|
|
28
41
|
}
|
|
29
42
|
|
|
@@ -31,75 +44,130 @@
|
|
|
31
44
|
items = [],
|
|
32
45
|
footerItems = [],
|
|
33
46
|
value = $bindable(''),
|
|
47
|
+
variant = 'default',
|
|
48
|
+
showLabels = false,
|
|
34
49
|
class: className = '',
|
|
35
50
|
brand,
|
|
51
|
+
footer,
|
|
36
52
|
onchange
|
|
37
53
|
}: NavRailProps = $props();
|
|
38
54
|
|
|
55
|
+
const solid = $derived(variant === 'solid');
|
|
56
|
+
|
|
39
57
|
function select(id: string, disabled?: boolean) {
|
|
40
58
|
if (disabled) return;
|
|
41
59
|
value = id;
|
|
42
60
|
onchange?.(id);
|
|
43
61
|
}
|
|
44
62
|
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
63
|
+
const hasBadge = (item: NavRailItem) =>
|
|
64
|
+
item.badge !== undefined && item.badge !== '' && item.badge !== 0;
|
|
65
|
+
|
|
66
|
+
const itemClass = (item: NavRailItem) => {
|
|
67
|
+
const active = value === item.id;
|
|
68
|
+
return [
|
|
69
|
+
'group relative flex items-center justify-center rounded-xl transition-colors',
|
|
70
|
+
'focus-visible:outline-none focus-visible:ring-2',
|
|
71
|
+
showLabels ? 'w-[4.25rem] flex-col gap-1 px-0.5 pb-1.5 pt-2' : 'h-10 w-10',
|
|
72
|
+
solid
|
|
73
|
+
? [
|
|
74
|
+
'focus-visible:ring-white/40',
|
|
75
|
+
active ? 'bg-white/15 text-white' : 'text-white/70 hover:bg-white/10 hover:text-white'
|
|
76
|
+
]
|
|
77
|
+
: [
|
|
78
|
+
'focus-visible:ring-brand-500/30',
|
|
79
|
+
active
|
|
80
|
+
? 'bg-brand-500/15 text-brand-500'
|
|
81
|
+
: 'text-secondary hover:bg-surface-overlay hover:text-primary'
|
|
82
|
+
],
|
|
83
|
+
item.disabled && 'pointer-events-none cursor-not-allowed opacity-40'
|
|
84
|
+
];
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
const glyphClass = (item: NavRailItem) =>
|
|
88
|
+
[
|
|
89
|
+
'h-5 w-5',
|
|
90
|
+
solid
|
|
91
|
+
? 'text-current'
|
|
92
|
+
: value === item.id
|
|
93
|
+
? 'text-brand-500'
|
|
94
|
+
: 'text-secondary group-hover:text-primary'
|
|
95
|
+
].join(' ');
|
|
58
96
|
</script>
|
|
59
97
|
|
|
98
|
+
{#snippet inner(item: NavRailItem)}
|
|
99
|
+
<span class="relative inline-flex">
|
|
100
|
+
{#if item.icon}
|
|
101
|
+
<item.icon class={glyphClass(item)} strokeWidth={1.75} />
|
|
102
|
+
{:else}
|
|
103
|
+
<span class={['text-xs font-semibold', !solid && value === item.id && 'text-brand-500']}>
|
|
104
|
+
{item.label.slice(0, 1)}
|
|
105
|
+
</span>
|
|
106
|
+
{/if}
|
|
107
|
+
{#if hasBadge(item)}
|
|
108
|
+
<span
|
|
109
|
+
class={[
|
|
110
|
+
'-right-2.5 -top-1.5 h-4 min-w-4 px-1 font-bold absolute flex items-center justify-center rounded-full text-[9.5px] leading-none',
|
|
111
|
+
solid ? 'bg-amber-400 text-amber-950' : 'bg-red-500 text-white'
|
|
112
|
+
]}
|
|
113
|
+
>
|
|
114
|
+
{item.badge}
|
|
115
|
+
</span>
|
|
116
|
+
{/if}
|
|
117
|
+
</span>
|
|
118
|
+
{#if showLabels}
|
|
119
|
+
<span class="font-semibold leading-tight max-w-full truncate text-[10.5px]">{item.label}</span>
|
|
120
|
+
{/if}
|
|
121
|
+
{/snippet}
|
|
122
|
+
|
|
60
123
|
{#snippet railButton(item: NavRailItem)}
|
|
61
|
-
|
|
62
|
-
|
|
124
|
+
{#snippet control()}
|
|
125
|
+
{#if showLabels && solid && value === item.id}
|
|
126
|
+
<span
|
|
127
|
+
class="-left-2 bottom-3 top-3 w-1 bg-brand-200 absolute rounded-r-full"
|
|
128
|
+
aria-hidden="true"
|
|
129
|
+
></span>
|
|
130
|
+
{/if}
|
|
63
131
|
{#if item.href && !item.disabled}
|
|
64
132
|
<a
|
|
65
133
|
href={item.href}
|
|
66
|
-
aria-label={item.label}
|
|
134
|
+
aria-label={showLabels ? undefined : item.label}
|
|
67
135
|
aria-current={value === item.id ? 'page' : undefined}
|
|
68
136
|
class={itemClass(item)}
|
|
69
137
|
onclick={() => select(item.id, item.disabled)}
|
|
70
138
|
>
|
|
71
|
-
{
|
|
72
|
-
<item.icon class={glyphClass(item)} strokeWidth={1.75} />
|
|
73
|
-
{:else}
|
|
74
|
-
<span class={['text-xs font-semibold', value === item.id && 'text-brand-500']}>
|
|
75
|
-
{item.label.slice(0, 1)}
|
|
76
|
-
</span>
|
|
77
|
-
{/if}
|
|
139
|
+
{@render inner(item)}
|
|
78
140
|
</a>
|
|
79
141
|
{:else}
|
|
80
142
|
<button
|
|
81
143
|
type="button"
|
|
82
|
-
aria-label={item.label}
|
|
144
|
+
aria-label={showLabels ? undefined : item.label}
|
|
83
145
|
aria-current={value === item.id ? 'page' : undefined}
|
|
84
146
|
disabled={item.disabled}
|
|
85
147
|
class={itemClass(item)}
|
|
86
148
|
onclick={() => select(item.id, item.disabled)}
|
|
87
149
|
>
|
|
88
|
-
{
|
|
89
|
-
<item.icon class={glyphClass(item)} strokeWidth={1.75} />
|
|
90
|
-
{:else}
|
|
91
|
-
<span class={['text-xs font-semibold', value === item.id && 'text-brand-500']}>
|
|
92
|
-
{item.label.slice(0, 1)}
|
|
93
|
-
</span>
|
|
94
|
-
{/if}
|
|
150
|
+
{@render inner(item)}
|
|
95
151
|
</button>
|
|
96
152
|
{/if}
|
|
97
|
-
|
|
153
|
+
{/snippet}
|
|
154
|
+
{#if showLabels}
|
|
155
|
+
<div class="relative flex w-full justify-center">{@render control()}</div>
|
|
156
|
+
{:else}
|
|
157
|
+
<Tooltip content={item.label} side="right" class="relative w-full justify-center">
|
|
158
|
+
{#if !solid}<RailMark active={value === item.id} length="full" class="z-10" />{/if}
|
|
159
|
+
{@render control()}
|
|
160
|
+
</Tooltip>
|
|
161
|
+
{/if}
|
|
98
162
|
{/snippet}
|
|
99
163
|
|
|
100
164
|
<aside
|
|
101
165
|
class={[
|
|
102
|
-
'
|
|
166
|
+
'py-3 flex h-full shrink-0 flex-col items-center',
|
|
167
|
+
showLabels ? 'w-[5rem]' : 'w-14',
|
|
168
|
+
solid
|
|
169
|
+
? 'from-brand-700 to-brand-800 text-white bg-gradient-to-b'
|
|
170
|
+
: 'border-border bg-surface-elevated border-r',
|
|
103
171
|
className
|
|
104
172
|
]}
|
|
105
173
|
>
|
|
@@ -116,11 +184,15 @@
|
|
|
116
184
|
</nav>
|
|
117
185
|
|
|
118
186
|
{#if footerItems.length > 0}
|
|
119
|
-
<div class="w-8 py-2"><Divider /></div>
|
|
187
|
+
{#if !solid}<div class="w-8 py-2"><Divider /></div>{/if}
|
|
120
188
|
<nav class="gap-1 flex w-full flex-col items-center" aria-label="Rail footer">
|
|
121
189
|
{#each footerItems as item (item.id)}
|
|
122
190
|
{@render railButton(item)}
|
|
123
191
|
{/each}
|
|
124
192
|
</nav>
|
|
125
193
|
{/if}
|
|
194
|
+
|
|
195
|
+
{#if footer}
|
|
196
|
+
<div class="mt-2 flex items-center justify-center">{@render footer()}</div>
|
|
197
|
+
{/if}
|
|
126
198
|
</aside>
|
|
@@ -10,13 +10,25 @@ export interface NavRailItem {
|
|
|
10
10
|
href?: string;
|
|
11
11
|
icon?: NavRailIcon;
|
|
12
12
|
disabled?: boolean;
|
|
13
|
+
/** Small counter on the icon (pending items). Hidden when 0 or empty. */
|
|
14
|
+
badge?: string | number;
|
|
13
15
|
}
|
|
16
|
+
export type NavRailVariant = 'default' | 'solid';
|
|
14
17
|
interface NavRailProps {
|
|
15
18
|
items?: NavRailItem[];
|
|
16
19
|
footerItems?: NavRailItem[];
|
|
17
20
|
value?: string;
|
|
21
|
+
/**
|
|
22
|
+
* default — neutral surface, icon-only with tooltips.
|
|
23
|
+
* solid — brand-coloured bar (workspace apps), works best with `showLabels`.
|
|
24
|
+
*/
|
|
25
|
+
variant?: NavRailVariant;
|
|
26
|
+
/** Show the label under each icon (wider rail, no tooltip). */
|
|
27
|
+
showLabels?: boolean;
|
|
18
28
|
class?: string;
|
|
19
29
|
brand?: Snippet;
|
|
30
|
+
/** Rendered at the very bottom (avatar, account menu…). */
|
|
31
|
+
footer?: Snippet;
|
|
20
32
|
onchange?: (id: string) => void;
|
|
21
33
|
}
|
|
22
34
|
declare const NavRail: Component<NavRailProps, {}, "value">;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { StoryObj } from '@storybook/svelte';
|
|
2
|
+
declare const meta: {
|
|
3
|
+
title: string;
|
|
4
|
+
component: import("svelte").Component<Record<string, never>, {}, "">;
|
|
5
|
+
tags: string[];
|
|
6
|
+
parameters: {
|
|
7
|
+
layout: string;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
export default meta;
|
|
11
|
+
type Story = StoryObj<typeof meta>;
|
|
12
|
+
export declare const Default: Story;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import ProfilePickerStory from './ProfilePickerStory.svelte';
|
|
2
|
+
const meta = {
|
|
3
|
+
title: 'Organisms/ProfilePicker',
|
|
4
|
+
component: ProfilePickerStory,
|
|
5
|
+
tags: ['autodocs'],
|
|
6
|
+
parameters: { layout: 'fullscreen' }
|
|
7
|
+
};
|
|
8
|
+
export default meta;
|
|
9
|
+
export const Default = {};
|