@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.
Files changed (43) 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/EntityHero/EntityHero.stories.js +9 -0
  11. package/dist/components/molecules/EntityHero/EntityHero.svelte +162 -0
  12. package/dist/components/molecules/EntityHero/EntityHero.svelte.d.ts +37 -0
  13. package/dist/components/molecules/EntityHero/EntityHeroStory.svelte +28 -0
  14. package/dist/components/molecules/EntityHero/EntityHeroStory.svelte.d.ts +18 -0
  15. package/dist/components/molecules/OrgSwitcher/OrgSwitcher.svelte +68 -23
  16. package/dist/components/molecules/OrgSwitcher/OrgSwitcher.svelte.d.ts +12 -0
  17. package/dist/components/molecules/SectionNav/SectionNav.stories.d.ts +12 -0
  18. package/dist/components/molecules/SectionNav/SectionNav.stories.js +9 -0
  19. package/dist/components/molecules/SectionNav/SectionNav.svelte +139 -0
  20. package/dist/components/molecules/SectionNav/SectionNav.svelte.d.ts +41 -0
  21. package/dist/components/molecules/SectionNav/SectionNavStory.svelte +48 -0
  22. package/dist/components/molecules/SectionNav/SectionNavStory.svelte.d.ts +3 -0
  23. package/dist/components/molecules/StatCard/StatCard.svelte +51 -15
  24. package/dist/components/molecules/StatCard/StatCard.svelte.d.ts +13 -2
  25. package/dist/components/organisms/BottomNav/BottomNav.svelte +93 -53
  26. package/dist/components/organisms/BottomNav/BottomNav.svelte.d.ts +17 -2
  27. package/dist/components/organisms/NavRail/NavRail.svelte +106 -34
  28. package/dist/components/organisms/NavRail/NavRail.svelte.d.ts +12 -0
  29. package/dist/components/organisms/ProfilePicker/ProfilePicker.stories.d.ts +12 -0
  30. package/dist/components/organisms/ProfilePicker/ProfilePicker.stories.js +9 -0
  31. package/dist/components/organisms/ProfilePicker/ProfilePicker.svelte +183 -0
  32. package/dist/components/organisms/ProfilePicker/ProfilePicker.svelte.d.ts +37 -0
  33. package/dist/components/organisms/ProfilePicker/ProfilePickerStory.svelte +18 -0
  34. package/dist/components/organisms/ProfilePicker/ProfilePickerStory.svelte.d.ts +3 -0
  35. package/dist/components/organisms/WorkspaceShell/WorkspaceShell.stories.d.ts +12 -0
  36. package/dist/components/organisms/WorkspaceShell/WorkspaceShell.stories.js +9 -0
  37. package/dist/components/organisms/WorkspaceShell/WorkspaceShell.svelte +75 -0
  38. package/dist/components/organisms/WorkspaceShell/WorkspaceShell.svelte.d.ts +30 -0
  39. package/dist/components/organisms/WorkspaceShell/WorkspaceShellStory.svelte +71 -0
  40. package/dist/components/organisms/WorkspaceShell/WorkspaceShellStory.svelte.d.ts +3 -0
  41. package/dist/index.d.ts +11 -2
  42. package/dist/index.js +5 -0
  43. package/package.json +2 -1
@@ -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;
@@ -0,0 +1,48 @@
1
+ <script lang="ts">
2
+ import SectionNav, { type SectionNavGroup } from './SectionNav.svelte';
3
+ import OrgSwitcher from '../OrgSwitcher/OrgSwitcher.svelte';
4
+ import { FileText, Images, Wrench, QrCode, Tag, ExternalLink } from '@lucide/svelte';
5
+
6
+ const groups: SectionNavGroup[] = [
7
+ {
8
+ id: 'main',
9
+ items: [
10
+ {
11
+ id: 'ficha',
12
+ label: 'Mi ficha',
13
+ icon: FileText,
14
+ badge: '80%',
15
+ badgeTone: 'neutral',
16
+ href: '#'
17
+ },
18
+ { id: 'galeria', label: 'Galería', icon: Images, href: '#' },
19
+ { id: 'servicios', label: 'Servicios', icon: Wrench, href: '#' },
20
+ { id: 'precios', label: 'Precios y QR', icon: QrCode, href: '#' },
21
+ { id: 'ofertas', label: 'Ofertas', icon: Tag, badge: 1, badgeTone: 'neutral', href: '#' }
22
+ ]
23
+ }
24
+ ];
25
+ let value = $state('galeria');
26
+ </script>
27
+
28
+ <div class="rounded-xl border-border h-[34rem] overflow-hidden border">
29
+ <SectionNav title="Escaparate" description="Lo que ven tus clientes" {groups} bind:value>
30
+ {#snippet header()}
31
+ <OrgSwitcher
32
+ orgs={[
33
+ { id: 'bl', name: 'Bar La Plaza', subtitle: '3 empresas', tone: 'brand' },
34
+ { id: 'rp', name: 'Reformas Plaza', subtitle: 'Propietario', tone: 'amber', badge: 2 }
35
+ ]}
36
+ value="bl"
37
+ title="Tus empresas"
38
+ createLabel="Crear o vincular empresa"
39
+ oncreate={() => {}}
40
+ />
41
+ {/snippet}
42
+ {#snippet footer()}
43
+ <a href="#top" class="gap-2 px-3 py-2 text-sm font-medium text-brand-700 flex items-center"
44
+ ><ExternalLink size={16} />Ver ficha pública</a
45
+ >
46
+ {/snippet}
47
+ </SectionNav>
48
+ </div>
@@ -0,0 +1,3 @@
1
+ declare const SectionNavStory: import("svelte").Component<Record<string, never>, {}, "">;
2
+ type SectionNavStory = ReturnType<typeof SectionNavStory>;
3
+ export default SectionNavStory;
@@ -1,8 +1,9 @@
1
1
  <script lang="ts">
2
- import type { Snippet } from 'svelte';
2
+ import type { Component, Snippet } from 'svelte';
3
3
  import Card from '../Card/Card.svelte';
4
4
  import type { CardVariant } from '../Card/Card.svelte';
5
5
  import Badge from '../../atoms/Badge/Badge.svelte';
6
+ import Sparkline from '../../atoms/Sparkline/Sparkline.svelte';
6
7
 
7
8
  export type StatCardTrend = 'up' | 'down' | 'neutral';
8
9
  export type StatCardSize = 'sm' | 'md';
@@ -19,8 +20,15 @@
19
20
  size?: StatCardSize;
20
21
  /** Brand tint (default) or gray icon well */
21
22
  iconTone?: 'brand' | 'neutral';
23
+ /** Mini trend line at the bottom-right (e.g. last 8 weeks). */
24
+ sparkline?: number[];
25
+ sparklineTone?: 'brand' | 'success' | 'warning' | 'error' | 'neutral';
22
26
  class?: string;
23
27
  icon?: Snippet;
28
+ /** Small icon before the label (workspace look); does not hide the sparkline. */
29
+ labelIcon?: Component<{ class?: string; size?: number | string; strokeWidth?: number | string }>;
30
+ /** `pill` puts the delta in a small tinted chip (+12%). */
31
+ deltaStyle?: 'text' | 'pill';
24
32
  onclick?: (e: MouseEvent) => void;
25
33
  }
26
34
 
@@ -35,8 +43,12 @@
35
43
  variant = 'default',
36
44
  size = 'md',
37
45
  iconTone = 'brand',
46
+ sparkline,
47
+ sparklineTone = 'brand',
38
48
  class: className = '',
39
49
  icon,
50
+ labelIcon: LabelIcon,
51
+ deltaStyle = 'text',
40
52
  onclick
41
53
  }: StatCardProps = $props();
42
54
 
@@ -52,33 +64,57 @@
52
64
  chrome={false}
53
65
  >
54
66
  <div class="gap-3 flex items-start justify-between">
55
- <div class="min-w-0 space-y-1">
67
+ <div class="min-w-0 space-y-1 flex-1">
56
68
  <div class="gap-2 flex flex-wrap items-center">
57
- <p class={['font-medium text-secondary', compact ? 'text-xs' : 'text-sm']}>{label}</p>
69
+ <p
70
+ class={[
71
+ 'gap-1.5 font-medium text-secondary inline-flex items-center',
72
+ compact ? 'text-xs' : 'text-sm'
73
+ ]}
74
+ >
75
+ {#if LabelIcon}<LabelIcon class="h-3.5 w-3.5 text-muted" strokeWidth={2} />{/if}{label}
76
+ </p>
58
77
  {#if badge}
59
78
  <Badge variant={badgeVariant} size="sm">{badge}</Badge>
60
79
  {/if}
61
80
  </div>
62
- <p
63
- class={[
64
- 'min-w-0 font-semibold tracking-tight text-primary',
65
- compact ? 'text-lg leading-snug' : 'text-2xl'
66
- ]}
67
- >
68
- {value}
69
- </p>
81
+ <div class="gap-3 flex items-end justify-between">
82
+ <p
83
+ class={[
84
+ 'min-w-0 font-semibold tracking-tight text-primary',
85
+ compact ? 'text-lg leading-snug' : 'text-2xl'
86
+ ]}
87
+ >
88
+ {value}
89
+ </p>
90
+ {#if sparkline && sparkline.length > 1 && !icon}
91
+ <Sparkline
92
+ data={sparkline}
93
+ tone={sparklineTone}
94
+ width={compact ? 72 : 96}
95
+ height={compact ? 26 : 34}
96
+ class="shrink-0"
97
+ />
98
+ {/if}
99
+ </div>
70
100
  {#if delta || description}
71
101
  <div class="gap-2 text-xs flex flex-wrap items-center">
72
102
  {#if delta}
73
103
  <span
74
104
  class={[
75
105
  'gap-0.5 font-medium inline-flex items-center',
76
- trend === 'up' && 'text-green-600 dark:text-green-400',
77
- trend === 'down' && 'text-red-600 dark:text-red-400',
78
- trend === 'neutral' && 'text-muted'
106
+ deltaStyle === 'pill' && 'px-1.5 py-0.5 font-semibold rounded-md',
107
+ deltaStyle === 'pill' && trend === 'down'
108
+ ? 'bg-red-500/10 text-red-700 dark:text-red-300'
109
+ : deltaStyle === 'pill'
110
+ ? 'bg-brand-500/12 text-brand-700 dark:text-brand-300'
111
+ : '',
112
+ deltaStyle === 'text' && trend === 'up' && 'text-green-600 dark:text-green-400',
113
+ deltaStyle === 'text' && trend === 'down' && 'text-red-600 dark:text-red-400',
114
+ deltaStyle === 'text' && trend === 'neutral' && 'text-muted'
79
115
  ]}
80
116
  >
81
- {#if trend === 'up'}
117
+ {#if deltaStyle === 'pill'}{:else if trend === 'up'}
82
118
  <svg
83
119
  class="h-3.5 w-3.5"
84
120
  viewBox="0 0 24 24"
@@ -1,4 +1,4 @@
1
- import type { Snippet } from 'svelte';
1
+ import type { Component, Snippet } from 'svelte';
2
2
  import type { CardVariant } from '../Card/Card.svelte';
3
3
  export type StatCardTrend = 'up' | 'down' | 'neutral';
4
4
  export type StatCardSize = 'sm' | 'md';
@@ -14,10 +14,21 @@ interface StatCardProps {
14
14
  size?: StatCardSize;
15
15
  /** Brand tint (default) or gray icon well */
16
16
  iconTone?: 'brand' | 'neutral';
17
+ /** Mini trend line at the bottom-right (e.g. last 8 weeks). */
18
+ sparkline?: number[];
19
+ sparklineTone?: 'brand' | 'success' | 'warning' | 'error' | 'neutral';
17
20
  class?: string;
18
21
  icon?: Snippet;
22
+ /** Small icon before the label (workspace look); does not hide the sparkline. */
23
+ labelIcon?: Component<{
24
+ class?: string;
25
+ size?: number | string;
26
+ strokeWidth?: number | string;
27
+ }>;
28
+ /** `pill` puts the delta in a small tinted chip (+12%). */
29
+ deltaStyle?: 'text' | 'pill';
19
30
  onclick?: (e: MouseEvent) => void;
20
31
  }
21
- declare const StatCard: import("svelte").Component<StatCardProps, {}, "">;
32
+ declare const StatCard: Component<StatCardProps, {}, "">;
22
33
  type StatCard = ReturnType<typeof StatCard>;
23
34
  export default StatCard;