@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.
- 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/EmptyState/EmptyState.stories.d.ts +43 -0
- package/dist/components/molecules/EmptyState/EmptyState.stories.js +28 -1
- package/dist/components/molecules/EmptyState/EmptyState.svelte +72 -5
- package/dist/components/molecules/EmptyState/EmptyState.svelte.d.ts +14 -0
- package/dist/components/molecules/EmptyState/EmptyStateStory.svelte +29 -2
- package/dist/components/molecules/EmptyState/EmptyStateStory.svelte.d.ts +8 -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
|
@@ -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>
|
|
@@ -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
|
|
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
|
-
<
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
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
|
-
|
|
77
|
-
|
|
78
|
-
|
|
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:
|
|
32
|
+
declare const StatCard: Component<StatCardProps, {}, "">;
|
|
22
33
|
type StatCard = ReturnType<typeof StatCard>;
|
|
23
34
|
export default StatCard;
|
|
@@ -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;
|