@r2digisolutions/components 0.25.19 → 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.
Files changed (49) hide show
  1. package/README.md +4 -0
  2. package/WORKSPACE.md +48 -0
  3. package/dist/components/molecules/ActionRow/ActionRow.stories.js +9 -0
  4. package/dist/components/molecules/ActionRow/ActionRow.svelte +84 -0
  5. package/dist/components/molecules/ActionRow/ActionRow.svelte.d.ts +31 -0
  6. package/dist/components/molecules/ActionRow/ActionRowStory.svelte +36 -0
  7. package/dist/components/molecules/ActionRow/ActionRowStory.svelte.d.ts +18 -0
  8. package/dist/components/molecules/Card/Card.svelte +4 -0
  9. package/dist/components/molecules/Card/Card.svelte.d.ts +2 -0
  10. package/dist/components/molecules/EmptyState/EmptyState.stories.d.ts +43 -0
  11. package/dist/components/molecules/EmptyState/EmptyState.stories.js +28 -1
  12. package/dist/components/molecules/EmptyState/EmptyState.svelte +72 -5
  13. package/dist/components/molecules/EmptyState/EmptyState.svelte.d.ts +14 -0
  14. package/dist/components/molecules/EmptyState/EmptyStateStory.svelte +29 -2
  15. package/dist/components/molecules/EmptyState/EmptyStateStory.svelte.d.ts +8 -0
  16. package/dist/components/molecules/EntityHero/EntityHero.stories.js +9 -0
  17. package/dist/components/molecules/EntityHero/EntityHero.svelte +162 -0
  18. package/dist/components/molecules/EntityHero/EntityHero.svelte.d.ts +37 -0
  19. package/dist/components/molecules/EntityHero/EntityHeroStory.svelte +28 -0
  20. package/dist/components/molecules/EntityHero/EntityHeroStory.svelte.d.ts +18 -0
  21. package/dist/components/molecules/OrgSwitcher/OrgSwitcher.svelte +68 -23
  22. package/dist/components/molecules/OrgSwitcher/OrgSwitcher.svelte.d.ts +12 -0
  23. package/dist/components/molecules/SectionNav/SectionNav.stories.d.ts +12 -0
  24. package/dist/components/molecules/SectionNav/SectionNav.stories.js +9 -0
  25. package/dist/components/molecules/SectionNav/SectionNav.svelte +139 -0
  26. package/dist/components/molecules/SectionNav/SectionNav.svelte.d.ts +41 -0
  27. package/dist/components/molecules/SectionNav/SectionNavStory.svelte +48 -0
  28. package/dist/components/molecules/SectionNav/SectionNavStory.svelte.d.ts +3 -0
  29. package/dist/components/molecules/StatCard/StatCard.svelte +51 -15
  30. package/dist/components/molecules/StatCard/StatCard.svelte.d.ts +13 -2
  31. package/dist/components/organisms/BottomNav/BottomNav.svelte +93 -53
  32. package/dist/components/organisms/BottomNav/BottomNav.svelte.d.ts +17 -2
  33. package/dist/components/organisms/NavRail/NavRail.svelte +106 -34
  34. package/dist/components/organisms/NavRail/NavRail.svelte.d.ts +12 -0
  35. package/dist/components/organisms/ProfilePicker/ProfilePicker.stories.d.ts +12 -0
  36. package/dist/components/organisms/ProfilePicker/ProfilePicker.stories.js +9 -0
  37. package/dist/components/organisms/ProfilePicker/ProfilePicker.svelte +183 -0
  38. package/dist/components/organisms/ProfilePicker/ProfilePicker.svelte.d.ts +37 -0
  39. package/dist/components/organisms/ProfilePicker/ProfilePickerStory.svelte +18 -0
  40. package/dist/components/organisms/ProfilePicker/ProfilePickerStory.svelte.d.ts +3 -0
  41. package/dist/components/organisms/WorkspaceShell/WorkspaceShell.stories.d.ts +12 -0
  42. package/dist/components/organisms/WorkspaceShell/WorkspaceShell.stories.js +9 -0
  43. package/dist/components/organisms/WorkspaceShell/WorkspaceShell.svelte +75 -0
  44. package/dist/components/organisms/WorkspaceShell/WorkspaceShell.svelte.d.ts +30 -0
  45. package/dist/components/organisms/WorkspaceShell/WorkspaceShellStory.svelte +71 -0
  46. package/dist/components/organisms/WorkspaceShell/WorkspaceShellStory.svelte.d.ts +3 -0
  47. package/dist/index.d.ts +11 -2
  48. package/dist/index.js +5 -0
  49. package/package.json +2 -1
@@ -0,0 +1,162 @@
1
+ <script lang="ts">
2
+ import type { Snippet } from 'svelte';
3
+
4
+ export interface EntityHeroStat {
5
+ label: string;
6
+ value: string | number;
7
+ }
8
+
9
+ interface EntityHeroProps {
10
+ /** Name of the business, project, profile… */
11
+ title: string;
12
+ /** One line under the title (category · address…). */
13
+ subtitle?: string;
14
+ /** Cover image URL. Without it a soft brand gradient is drawn. */
15
+ cover?: string;
16
+ /** Avatar/logo image URL. */
17
+ avatar?: string;
18
+ /** Fallback text inside the avatar tile (defaults to the title initials). */
19
+ initials?: string;
20
+ /** Key numbers on the right (desktop) / under the title (mobile). */
21
+ stats?: EntityHeroStat[];
22
+ /** Hide the cover band (compact header). */
23
+ compact?: boolean;
24
+ /** Height of the cover band. */
25
+ coverSize?: 'sm' | 'md' | 'lg';
26
+ /** Extra CSS for the cover <img> (framing: object-position, scale…). */
27
+ coverStyle?: string;
28
+ /** Buttons over the cover, shown on hover/focus (always on touch): «Cambiar portada», «Ajustar»… */
29
+ coverActions?: Snippet;
30
+ class?: string;
31
+ /** Status badges next to the title. */
32
+ badges?: Snippet;
33
+ /** Extra content in the subtitle line (e.g. «Abierto ahora»). */
34
+ meta?: Snippet;
35
+ /** Buttons on the right (Share, QR, Edit…). */
36
+ actions?: Snippet;
37
+ }
38
+
39
+ const {
40
+ title,
41
+ subtitle,
42
+ cover,
43
+ avatar,
44
+ initials,
45
+ stats = [],
46
+ compact = false,
47
+ coverSize = 'sm',
48
+ coverStyle,
49
+ coverActions,
50
+ class: className = '',
51
+ badges,
52
+ meta,
53
+ actions
54
+ }: EntityHeroProps = $props();
55
+
56
+ const fallback = $derived(
57
+ initials ??
58
+ title
59
+ .split(/\s+/)
60
+ .filter(Boolean)
61
+ .slice(0, 2)
62
+ .map((w) => w[0]?.toUpperCase() ?? '')
63
+ .join('')
64
+ );
65
+ </script>
66
+
67
+ <section
68
+ class={[
69
+ 'rounded-2xl border-border bg-surface-elevated shadow-sm overflow-hidden border',
70
+ className
71
+ ]}
72
+ >
73
+ {#if !compact}
74
+ <div
75
+ class={[
76
+ 'entity-hero-cover group/cover relative overflow-hidden',
77
+ { sm: 'h-16 sm:h-20', md: 'h-28 sm:h-36', lg: 'h-36 sm:h-48' }[coverSize]
78
+ ]}
79
+ >
80
+ {#if cover}<img
81
+ src={cover}
82
+ alt=""
83
+ class="inset-0 absolute h-full w-full object-cover"
84
+ style={coverStyle}
85
+ />{/if}
86
+ {#if coverActions}
87
+ <div
88
+ class="right-3 top-3 gap-2 absolute flex opacity-100 transition-opacity duration-200 [@media(hover:hover)]:opacity-0 [@media(hover:hover)]:group-hover/cover:opacity-100 [@media(hover:hover)]:group-focus-within/cover:opacity-100"
89
+ >
90
+ {@render coverActions()}
91
+ </div>
92
+ {/if}
93
+ </div>
94
+ {/if}
95
+ <div
96
+ class={['gap-4 px-4 pb-4 sm:px-5 lg:flex-row lg:items-end flex flex-col', compact && 'pt-4']}
97
+ >
98
+ <div class="min-w-0 gap-4 flex flex-1 items-start">
99
+ <span
100
+ class={[
101
+ 'rounded-2xl bg-brand-600 font-bold text-white flex shrink-0 items-center justify-center overflow-hidden',
102
+ compact
103
+ ? 'h-12 w-12 text-base'
104
+ : 'relative z-10 -mt-8 border-surface-elevated text-xl shadow-md h-[4.25rem] w-[4.25rem] border-4'
105
+ ]}
106
+ >
107
+ {#if avatar}<img
108
+ src={avatar}
109
+ alt=""
110
+ class="h-full w-full object-cover"
111
+ />{:else}{fallback}{/if}
112
+ </span>
113
+ <div class={['min-w-0', !compact && 'pt-2.5']}>
114
+ <div class="gap-2 flex flex-wrap items-center">
115
+ <h1 class="text-xl font-bold tracking-tight text-primary truncate">{title}</h1>
116
+ {#if badges}{@render badges()}{/if}
117
+ </div>
118
+ {#if subtitle || meta}
119
+ <p class="mt-0.5 text-sm text-muted truncate">
120
+ {subtitle}{#if subtitle && meta}<span aria-hidden="true">
121
+ ·
122
+ </span>{/if}{#if meta}{@render meta()}{/if}
123
+ </p>
124
+ {/if}
125
+ </div>
126
+ </div>
127
+ {#if stats.length}
128
+ <div class="lg:pb-1 flex shrink-0 overflow-x-auto">
129
+ {#each stats as stat, i (stat.label)}
130
+ <div
131
+ class={[
132
+ 'px-4',
133
+ i === 0 ? 'pl-0 lg:border-l lg:border-border lg:pl-4' : 'border-border border-l'
134
+ ]}
135
+ >
136
+ <p class="text-lg font-bold leading-tight tracking-tight text-primary">{stat.value}</p>
137
+ <p class="text-xs text-muted whitespace-nowrap">{stat.label}</p>
138
+ </div>
139
+ {/each}
140
+ </div>
141
+ {/if}
142
+ {#if actions}<div class="gap-2 lg:pb-1 flex shrink-0 flex-wrap">{@render actions()}</div>{/if}
143
+ </div>
144
+ </section>
145
+
146
+ <style>
147
+ .entity-hero-cover {
148
+ background-color: var(--color-brand-200);
149
+ background-image:
150
+ radial-gradient(
151
+ circle at 18% 30%,
152
+ color-mix(in oklab, #f0c98f 70%, transparent) 0,
153
+ transparent 42%
154
+ ),
155
+ radial-gradient(
156
+ circle at 72% 60%,
157
+ color-mix(in oklab, var(--color-brand-300) 80%, transparent) 0,
158
+ transparent 48%
159
+ ),
160
+ linear-gradient(120deg, #c9a77c, var(--color-brand-400) 58%, var(--color-brand-600));
161
+ }
162
+ </style>
@@ -0,0 +1,37 @@
1
+ import type { Snippet } from 'svelte';
2
+ export interface EntityHeroStat {
3
+ label: string;
4
+ value: string | number;
5
+ }
6
+ interface EntityHeroProps {
7
+ /** Name of the business, project, profile… */
8
+ title: string;
9
+ /** One line under the title (category · address…). */
10
+ subtitle?: string;
11
+ /** Cover image URL. Without it a soft brand gradient is drawn. */
12
+ cover?: string;
13
+ /** Avatar/logo image URL. */
14
+ avatar?: string;
15
+ /** Fallback text inside the avatar tile (defaults to the title initials). */
16
+ initials?: string;
17
+ /** Key numbers on the right (desktop) / under the title (mobile). */
18
+ stats?: EntityHeroStat[];
19
+ /** Hide the cover band (compact header). */
20
+ compact?: boolean;
21
+ /** Height of the cover band. */
22
+ coverSize?: 'sm' | 'md' | 'lg';
23
+ /** Extra CSS for the cover <img> (framing: object-position, scale…). */
24
+ coverStyle?: string;
25
+ /** Buttons over the cover, shown on hover/focus (always on touch): «Cambiar portada», «Ajustar»… */
26
+ coverActions?: Snippet;
27
+ class?: string;
28
+ /** Status badges next to the title. */
29
+ badges?: Snippet;
30
+ /** Extra content in the subtitle line (e.g. «Abierto ahora»). */
31
+ meta?: Snippet;
32
+ /** Buttons on the right (Share, QR, Edit…). */
33
+ actions?: Snippet;
34
+ }
35
+ declare const EntityHero: import("svelte").Component<EntityHeroProps, {}, "">;
36
+ type EntityHero = ReturnType<typeof EntityHero>;
37
+ export default EntityHero;
@@ -0,0 +1,28 @@
1
+ <script lang="ts">
2
+ import EntityHero from './EntityHero.svelte';
3
+ import Badge from '../../atoms/Badge/Badge.svelte';
4
+ import Button from '../../atoms/Button/Button.svelte';
5
+ </script>
6
+
7
+ <div class="max-w-5xl p-6">
8
+ <EntityHero
9
+ title="Bar La Plaza"
10
+ coverSize="md"
11
+ subtitle="Tapas, raciones y terraza · Calle Mayor 12, Madrid"
12
+ stats={[
13
+ { label: 'Visitas', value: '1.284' },
14
+ { label: 'Solicitudes', value: 6 },
15
+ { label: 'Reservas', value: 14 },
16
+ { label: 'Valoración', value: '4,8 ★' }
17
+ ]}
18
+ >
19
+ {#snippet coverActions()}<Button size="sm" variant="secondary">Cambiar portada</Button><Button
20
+ size="sm"
21
+ variant="secondary">Ajustar encuadre</Button
22
+ >{/snippet}
23
+ {#snippet badges()}<Badge variant="success" dot>Publicada</Badge><Badge variant="warning"
24
+ >Verificación pendiente</Badge
25
+ >{/snippet}
26
+ {#snippet actions()}<Button variant="outline" size="sm">Mi QR</Button>{/snippet}
27
+ </EntityHero>
28
+ </div>
@@ -0,0 +1,18 @@
1
+ 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> {
2
+ new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
3
+ $$bindings?: Bindings;
4
+ } & Exports;
5
+ (internal: unknown, props: {
6
+ $$events?: Events;
7
+ $$slots?: Slots;
8
+ }): Exports & {
9
+ $set?: any;
10
+ $on?: any;
11
+ };
12
+ z_$$bindings?: Bindings;
13
+ }
14
+ declare const EntityHeroStory: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
15
+ [evt: string]: CustomEvent<any>;
16
+ }, {}, {}, string>;
17
+ type EntityHeroStory = InstanceType<typeof EntityHeroStory>;
18
+ export default EntityHeroStory;
@@ -12,6 +12,12 @@
12
12
  initials?: string;
13
13
  /** Soft accent for the avatar tile */
14
14
  tone?: 'brand' | 'sky' | 'emerald' | 'amber' | 'rose';
15
+ /** Logo/avatar image; falls back to initials. */
16
+ src?: string;
17
+ /** Second line (role, category…). Replaces the «plan» line when set. */
18
+ subtitle?: string;
19
+ /** Pending count shown at the end of the row. Hidden when 0. */
20
+ badge?: string | number;
15
21
  }
16
22
 
17
23
  interface OrgSwitcherProps {
@@ -19,6 +25,12 @@
19
25
  value?: string;
20
26
  /** Compact trigger for sidebars */
21
27
  compact?: boolean;
28
+ /** Small heading above the list. */
29
+ title?: string;
30
+ /** Label of the create row (shown when `oncreate` is set). */
31
+ createLabel?: string;
32
+ /** Small note under the create row (e.g. «Linked to your account»). */
33
+ footerNote?: string;
22
34
  class?: string;
23
35
  onchange?: (id: string) => void;
24
36
  oncreate?: () => void;
@@ -40,6 +52,9 @@
40
52
  ],
41
53
  value = $bindable('acme'),
42
54
  compact = false,
55
+ title,
56
+ createLabel = 'Create organization',
57
+ footerNote,
43
58
  class: className = '',
44
59
  onchange,
45
60
  oncreate
@@ -71,40 +86,51 @@
71
86
  aria-expanded={open}
72
87
  onclick={() => (open = !open)}
73
88
  class={[
74
- 'flex w-full items-center gap-2 rounded-xl border border-border bg-surface-elevated text-left transition-colors',
75
- 'hover:border-border-strong focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-brand-500/30',
89
+ 'gap-2 rounded-xl border-border bg-surface-elevated flex w-full items-center border text-left transition-colors',
90
+ 'hover:border-border-strong focus-visible:ring-brand-500/30 focus-visible:ring-2 focus-visible:outline-none',
76
91
  compact ? 'px-2 py-1.5' : 'px-3 py-2'
77
92
  ]}
78
93
  >
79
94
  <span
80
95
  class={[
81
- 'flex shrink-0 items-center justify-center rounded-lg text-xs font-bold',
96
+ 'rounded-lg text-xs font-bold flex shrink-0 items-center justify-center',
82
97
  compact ? 'h-7 w-7' : 'h-8 w-8',
83
98
  TONE[current?.tone ?? 'brand']
84
99
  ]}
85
100
  >
86
- {current?.initials ?? (current?.name ?? '?').slice(0, 2).toUpperCase()}
101
+ {#if current?.src}<img
102
+ src={current.src}
103
+ alt=""
104
+ class="rounded-lg h-full w-full object-cover"
105
+ />{:else}{current?.initials ?? (current?.name ?? '?').slice(0, 2).toUpperCase()}{/if}
87
106
  </span>
88
107
  {#if !compact}
89
108
  <span class="min-w-0 flex-1">
90
- <span class="block truncate text-sm font-semibold text-primary">{current?.name}</span>
91
- {#if current?.plan}
92
- <span class="block truncate text-[11px] text-muted">{current.plan} plan</span>
109
+ <span class="text-sm font-semibold text-primary block truncate">{current?.name}</span>
110
+ {#if current?.subtitle}
111
+ <span class="text-muted block truncate text-[11px]">{current.subtitle}</span>
112
+ {:else if current?.plan}
113
+ <span class="text-muted block truncate text-[11px]">{current.plan} plan</span>
93
114
  {/if}
94
115
  </span>
95
116
  {:else}
96
- <span class="min-w-0 flex-1 truncate text-sm font-medium text-primary">{current?.name}</span>
117
+ <span class="min-w-0 text-sm font-medium text-primary flex-1 truncate">{current?.name}</span>
97
118
  {/if}
98
- <ChevronsUpDown class="h-4 w-4 shrink-0 text-muted" strokeWidth={2} />
119
+ <ChevronsUpDown class="h-4 w-4 text-muted shrink-0" strokeWidth={2} />
99
120
  </button>
100
121
 
101
122
  {#if open}
102
123
  <div
103
124
  role="listbox"
104
125
  aria-label="Organizations"
105
- class="absolute left-0 right-0 z-50 mt-1.5 overflow-hidden rounded-xl border border-border bg-surface-elevated shadow-lg"
126
+ class="left-0 right-0 mt-1.5 rounded-xl border-border bg-surface-elevated shadow-lg absolute z-50 overflow-hidden border"
106
127
  >
107
- <ul class="max-h-64 overflow-y-auto p-1">
128
+ {#if title}
129
+ <p class="px-3 pb-1 pt-2.5 font-semibold tracking-wider text-muted text-[11px] uppercase">
130
+ {title}
131
+ </p>
132
+ {/if}
133
+ <ul class="max-h-64 p-1 overflow-y-auto">
108
134
  {#each orgs as org (org.id)}
109
135
  <li>
110
136
  <button
@@ -113,54 +139,73 @@
113
139
  aria-selected={org.id === value}
114
140
  onclick={() => select(org.id)}
115
141
  class={[
116
- 'flex w-full items-center gap-2 rounded-lg px-2 py-2 text-left transition-colors',
142
+ 'gap-2 rounded-lg px-2 py-2 flex w-full items-center text-left transition-colors',
117
143
  org.id === value ? 'bg-brand-500/10' : 'hover:bg-surface-overlay'
118
144
  ]}
119
145
  >
120
146
  <span
121
147
  class={[
122
- 'flex h-8 w-8 shrink-0 items-center justify-center rounded-lg text-xs font-bold',
148
+ 'h-8 w-8 rounded-lg text-xs font-bold flex shrink-0 items-center justify-center',
123
149
  TONE[org.tone ?? 'brand']
124
150
  ]}
125
151
  >
126
- {org.initials ?? org.name.slice(0, 2).toUpperCase()}
152
+ {#if org.src}<img
153
+ src={org.src}
154
+ alt=""
155
+ class="rounded-lg h-full w-full object-cover"
156
+ />{:else}{org.initials ?? org.name.slice(0, 2).toUpperCase()}{/if}
127
157
  </span>
128
158
  <span class="min-w-0 flex-1">
129
- <span class="flex items-center gap-2">
130
- <span class="truncate text-sm font-medium text-primary">{org.name}</span>
159
+ <span class="gap-2 flex items-center">
160
+ <span class="text-sm font-medium text-primary truncate">{org.name}</span>
131
161
  {#if org.plan}
132
162
  <Badge size="sm" variant="secondary">{org.plan}</Badge>
133
163
  {/if}
134
164
  </span>
165
+ {#if org.subtitle}
166
+ <span class="text-muted block truncate text-[11px]">{org.subtitle}</span>
167
+ {/if}
135
168
  </span>
169
+ {#if org.badge !== undefined && org.badge !== '' && org.badge !== 0 && org.id !== value}
170
+ <span
171
+ class="h-5 min-w-5 bg-brand-600 px-1.5 font-bold text-white flex shrink-0 items-center justify-center rounded-full text-[11px]"
172
+ >{org.badge}</span
173
+ >
174
+ {/if}
136
175
  {#if org.id === value}
137
- <Check class="h-4 w-4 shrink-0 text-brand-600 dark:text-brand-400" strokeWidth={2.5} />
176
+ <Check
177
+ class="h-4 w-4 text-brand-600 dark:text-brand-400 shrink-0"
178
+ strokeWidth={2.5}
179
+ />
138
180
  {/if}
139
181
  </button>
140
182
  </li>
141
183
  {/each}
142
184
  </ul>
143
185
  {#if oncreate}
144
- <div class="border-t border-border p-1">
186
+ <div class="border-border p-1 border-t">
145
187
  <button
146
188
  type="button"
147
189
  onclick={() => {
148
190
  open = false;
149
191
  oncreate?.();
150
192
  }}
151
- class="flex w-full items-center gap-2 rounded-lg px-2 py-2 text-sm font-medium text-secondary transition-colors hover:bg-surface-overlay"
193
+ class="gap-2 rounded-lg px-2 py-2 text-sm font-medium text-secondary hover:bg-surface-overlay flex w-full items-center transition-colors"
152
194
  >
153
195
  <span
154
- class="flex h-8 w-8 items-center justify-center rounded-lg border border-dashed border-border text-muted"
196
+ class="h-8 w-8 rounded-lg border-border text-muted flex items-center justify-center border border-dashed"
155
197
  >
156
198
  <Plus class="h-4 w-4" strokeWidth={2} />
157
199
  </span>
158
- Create organization
200
+ {createLabel}
159
201
  </button>
202
+ {#if footerNote}
203
+ <p class="px-2 pb-1.5 pt-1 text-muted text-[11px]">{footerNote}</p>
204
+ {/if}
160
205
  </div>
161
206
  {:else}
162
- <div class="border-t border-border px-3 py-2">
163
- <p class="inline-flex items-center gap-1.5 text-[11px] text-muted">
207
+ <div class="border-border px-3 py-2 border-t">
208
+ <p class="gap-1.5 text-muted inline-flex items-center text-[11px]">
164
209
  <Building2 class="h-3 w-3" strokeWidth={2} />
165
210
  {orgs.length} workspaces
166
211
  </p>
@@ -5,12 +5,24 @@ export interface OrgItem {
5
5
  initials?: string;
6
6
  /** Soft accent for the avatar tile */
7
7
  tone?: 'brand' | 'sky' | 'emerald' | 'amber' | 'rose';
8
+ /** Logo/avatar image; falls back to initials. */
9
+ src?: string;
10
+ /** Second line (role, category…). Replaces the «plan» line when set. */
11
+ subtitle?: string;
12
+ /** Pending count shown at the end of the row. Hidden when 0. */
13
+ badge?: string | number;
8
14
  }
9
15
  interface OrgSwitcherProps {
10
16
  orgs?: OrgItem[];
11
17
  value?: string;
12
18
  /** Compact trigger for sidebars */
13
19
  compact?: boolean;
20
+ /** Small heading above the list. */
21
+ title?: string;
22
+ /** Label of the create row (shown when `oncreate` is set). */
23
+ createLabel?: string;
24
+ /** Small note under the create row (e.g. «Linked to your account»). */
25
+ footerNote?: string;
14
26
  class?: string;
15
27
  onchange?: (id: string) => void;
16
28
  oncreate?: () => void;
@@ -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 SectionNavStory from './SectionNavStory.svelte';
2
+ const meta = {
3
+ title: 'Molecules/SectionNav',
4
+ component: SectionNavStory,
5
+ tags: ['autodocs'],
6
+ parameters: { layout: 'padded' }
7
+ };
8
+ export default meta;
9
+ export const Default = {};
@@ -0,0 +1,139 @@
1
+ <script lang="ts">
2
+ import type { Component, Snippet } from 'svelte';
3
+
4
+ export type SectionNavIcon = Component<{
5
+ class?: string;
6
+ size?: number | string;
7
+ strokeWidth?: number | string;
8
+ }>;
9
+
10
+ export interface SectionNavItem {
11
+ id: string;
12
+ label: string;
13
+ href?: string;
14
+ icon?: SectionNavIcon;
15
+ /** Counter at the end of the row. Hidden when 0 or empty. */
16
+ badge?: string | number;
17
+ /** `brand` = needs attention (filled), `neutral` = informative (grey). */
18
+ badgeTone?: 'brand' | 'neutral';
19
+ disabled?: boolean;
20
+ /** Open in a new tab (e.g. public page). */
21
+ external?: boolean;
22
+ }
23
+
24
+ export interface SectionNavGroup {
25
+ id: string;
26
+ label?: string;
27
+ items: SectionNavItem[];
28
+ }
29
+
30
+ interface SectionNavProps {
31
+ /** Section name, shown big at the top (e.g. «Escaparate»). */
32
+ title?: string;
33
+ /** One line under the title. */
34
+ description?: string;
35
+ groups?: SectionNavGroup[];
36
+ value?: string;
37
+ class?: string;
38
+ /** Above the title (workspace/org switcher). */
39
+ header?: Snippet;
40
+ /** Pinned to the bottom (progress card, public link…). */
41
+ footer?: Snippet;
42
+ onchange?: (id: string) => void;
43
+ }
44
+
45
+ let {
46
+ title,
47
+ description,
48
+ groups = [],
49
+ value = $bindable(''),
50
+ class: className = '',
51
+ header,
52
+ footer,
53
+ onchange
54
+ }: SectionNavProps = $props();
55
+
56
+ function select(item: SectionNavItem) {
57
+ if (item.disabled) return;
58
+ if (!item.external) value = item.id;
59
+ onchange?.(item.id);
60
+ }
61
+
62
+ const showBadge = (item: SectionNavItem) =>
63
+ item.badge !== undefined && item.badge !== '' && item.badge !== 0;
64
+ </script>
65
+
66
+ {#snippet row(item: SectionNavItem)}
67
+ {@const active = value === item.id}
68
+ {@const cls = [
69
+ 'flex w-full items-center gap-2.5 rounded-xl px-3 py-2 text-left text-sm transition-colors',
70
+ 'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-brand-500/30',
71
+ active
72
+ ? 'bg-brand-500/12 font-semibold text-brand-700 dark:text-brand-300'
73
+ : 'font-medium text-secondary hover:bg-surface-overlay hover:text-primary',
74
+ item.external && 'text-brand-700 dark:text-brand-300',
75
+ item.disabled && 'pointer-events-none opacity-40'
76
+ ]}
77
+ {#snippet content()}
78
+ {#if item.icon}<item.icon class="h-[18px] w-[18px] shrink-0" strokeWidth={1.85} />{/if}
79
+ <span class="min-w-0 flex-1 truncate">{item.label}</span>
80
+ {#if showBadge(item)}
81
+ <span
82
+ class={[
83
+ 'h-5 min-w-5 px-1.5 font-bold flex shrink-0 items-center justify-center rounded-full text-[11px]',
84
+ (item.badgeTone ?? 'brand') === 'brand'
85
+ ? 'bg-brand-600 text-white'
86
+ : 'bg-surface-overlay text-muted'
87
+ ]}>{item.badge}</span
88
+ >
89
+ {/if}
90
+ {/snippet}
91
+ {#if item.href && !item.disabled}
92
+ <a
93
+ href={item.href}
94
+ class={cls}
95
+ aria-current={active ? 'page' : undefined}
96
+ target={item.external ? '_blank' : undefined}
97
+ rel={item.external ? 'noopener' : undefined}
98
+ onclick={() => select(item)}>{@render content()}</a
99
+ >
100
+ {:else}
101
+ <button
102
+ type="button"
103
+ class={cls}
104
+ disabled={item.disabled}
105
+ aria-current={active ? 'page' : undefined}
106
+ onclick={() => select(item)}>{@render content()}</button
107
+ >
108
+ {/if}
109
+ {/snippet}
110
+
111
+ <aside
112
+ class={[
113
+ 'w-60 border-border bg-surface-elevated px-3 py-3.5 flex h-full shrink-0 flex-col border-r',
114
+ className
115
+ ]}
116
+ >
117
+ {#if header}<div class="mb-4">{@render header()}</div>{/if}
118
+ {#if title}
119
+ <div class="mb-3 px-2">
120
+ <p class="text-base font-bold tracking-tight text-primary">{title}</p>
121
+ {#if description}<p class="mt-0.5 text-xs text-muted">{description}</p>{/if}
122
+ </div>
123
+ {/if}
124
+ <nav class="min-h-0 gap-3 flex flex-1 flex-col overflow-y-auto" aria-label={title ?? 'Section'}>
125
+ {#each groups as group (group.id)}
126
+ <div class="gap-0.5 flex flex-col">
127
+ {#if group.label}
128
+ <p class="px-3 pb-1 pt-2 font-semibold tracking-wider text-muted text-[11px] uppercase">
129
+ {group.label}
130
+ </p>
131
+ {/if}
132
+ {#each group.items as item (item.id)}
133
+ {@render row(item)}
134
+ {/each}
135
+ </div>
136
+ {/each}
137
+ </nav>
138
+ {#if footer}<div class="mt-3 gap-2 flex flex-col">{@render footer()}</div>{/if}
139
+ </aside>
@@ -0,0 +1,41 @@
1
+ import type { Component, Snippet } from 'svelte';
2
+ export type SectionNavIcon = Component<{
3
+ class?: string;
4
+ size?: number | string;
5
+ strokeWidth?: number | string;
6
+ }>;
7
+ export interface SectionNavItem {
8
+ id: string;
9
+ label: string;
10
+ href?: string;
11
+ icon?: SectionNavIcon;
12
+ /** Counter at the end of the row. Hidden when 0 or empty. */
13
+ badge?: string | number;
14
+ /** `brand` = needs attention (filled), `neutral` = informative (grey). */
15
+ badgeTone?: 'brand' | 'neutral';
16
+ disabled?: boolean;
17
+ /** Open in a new tab (e.g. public page). */
18
+ external?: boolean;
19
+ }
20
+ export interface SectionNavGroup {
21
+ id: string;
22
+ label?: string;
23
+ items: SectionNavItem[];
24
+ }
25
+ interface SectionNavProps {
26
+ /** Section name, shown big at the top (e.g. «Escaparate»). */
27
+ title?: string;
28
+ /** One line under the title. */
29
+ description?: string;
30
+ groups?: SectionNavGroup[];
31
+ value?: string;
32
+ class?: string;
33
+ /** Above the title (workspace/org switcher). */
34
+ header?: Snippet;
35
+ /** Pinned to the bottom (progress card, public link…). */
36
+ footer?: Snippet;
37
+ onchange?: (id: string) => void;
38
+ }
39
+ declare const SectionNav: Component<SectionNavProps, {}, "value">;
40
+ type SectionNav = ReturnType<typeof SectionNav>;
41
+ export default SectionNav;