@r2digisolutions/components 0.21.11 → 0.21.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/organisms/Sidebar/Sidebar.stories.d.ts +2 -0
- package/dist/components/organisms/Sidebar/Sidebar.stories.js +1 -0
- package/dist/components/organisms/Sidebar/Sidebar.svelte +40 -6
- package/dist/components/organisms/Sidebar/Sidebar.svelte.d.ts +4 -0
- package/dist/components/organisms/Sidebar/SidebarStory.svelte +26 -2
- package/dist/components/organisms/Sidebar/SidebarStory.svelte.d.ts +1 -0
- package/package.json +1 -1
|
@@ -3,6 +3,7 @@ declare const meta: {
|
|
|
3
3
|
title: string;
|
|
4
4
|
component: import("svelte").Component<{
|
|
5
5
|
collapsed?: boolean;
|
|
6
|
+
wizard?: boolean;
|
|
6
7
|
}, {}, "">;
|
|
7
8
|
tags: string[];
|
|
8
9
|
argTypes: {
|
|
@@ -18,3 +19,4 @@ export default meta;
|
|
|
18
19
|
type Story = StoryObj<typeof meta>;
|
|
19
20
|
export declare const Default: Story;
|
|
20
21
|
export declare const Collapsed: Story;
|
|
22
|
+
export declare const WizardStepper: Story;
|
|
@@ -15,6 +15,10 @@
|
|
|
15
15
|
href?: string;
|
|
16
16
|
icon?: SidebarIcon;
|
|
17
17
|
disabled?: boolean;
|
|
18
|
+
/** Completed step (wizard / stepper). Shows a check when not active. */
|
|
19
|
+
done?: boolean;
|
|
20
|
+
/** Optional short hint (e.g. warning). */
|
|
21
|
+
hint?: string;
|
|
18
22
|
}
|
|
19
23
|
|
|
20
24
|
export interface SidebarGroup {
|
|
@@ -55,24 +59,47 @@
|
|
|
55
59
|
}
|
|
56
60
|
|
|
57
61
|
function itemClass(item: SidebarItem) {
|
|
62
|
+
const active = value === item.id;
|
|
58
63
|
return [
|
|
59
64
|
'relative flex w-full items-center gap-2 rounded-lg px-2.5 py-2 text-sm transition-colors',
|
|
60
65
|
'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-brand-500/30',
|
|
61
|
-
|
|
66
|
+
active
|
|
62
67
|
? 'bg-surface-overlay font-medium text-primary'
|
|
63
|
-
:
|
|
68
|
+
: item.done
|
|
69
|
+
? 'text-secondary hover:bg-surface-overlay hover:text-primary'
|
|
70
|
+
: 'text-secondary hover:bg-surface-overlay hover:text-primary',
|
|
64
71
|
item.disabled && 'pointer-events-none cursor-not-allowed opacity-40',
|
|
65
72
|
collapsed && 'justify-center'
|
|
66
73
|
];
|
|
67
74
|
}
|
|
68
75
|
</script>
|
|
69
76
|
|
|
77
|
+
{#snippet checkIcon()}
|
|
78
|
+
<svg
|
|
79
|
+
class="text-brand-600 dark:text-brand-400 h-4 w-4 shrink-0"
|
|
80
|
+
viewBox="0 0 24 24"
|
|
81
|
+
fill="none"
|
|
82
|
+
stroke="currentColor"
|
|
83
|
+
stroke-width="2.25"
|
|
84
|
+
aria-hidden="true"
|
|
85
|
+
>
|
|
86
|
+
<path stroke-linecap="round" stroke-linejoin="round" d="M5 13l4 4L19 7" />
|
|
87
|
+
</svg>
|
|
88
|
+
{/snippet}
|
|
89
|
+
|
|
70
90
|
{#snippet itemGlyph(item: SidebarItem)}
|
|
71
|
-
{#if item.
|
|
91
|
+
{#if item.done && value !== item.id}
|
|
92
|
+
{@render checkIcon()}
|
|
93
|
+
{:else if item.icon}
|
|
72
94
|
<item.icon class="h-4 w-4 shrink-0" strokeWidth={1.75} />
|
|
73
95
|
{:else}
|
|
74
96
|
<span
|
|
75
|
-
class=
|
|
97
|
+
class={[
|
|
98
|
+
'h-6 w-6 rounded-md font-semibold flex shrink-0 items-center justify-center text-[11px]',
|
|
99
|
+
item.done
|
|
100
|
+
? 'bg-brand-500/15 text-brand-700 dark:text-brand-300'
|
|
101
|
+
: 'bg-surface-overlay'
|
|
102
|
+
]}
|
|
76
103
|
>
|
|
77
104
|
{item.label.slice(0, 1)}
|
|
78
105
|
</span>
|
|
@@ -91,7 +118,10 @@
|
|
|
91
118
|
<RailMark active={value === item.id} side="right" length="short" inset="sm" />
|
|
92
119
|
{@render itemGlyph(item)}
|
|
93
120
|
{#if !collapsed}
|
|
94
|
-
<span class="truncate">{item.label}</span>
|
|
121
|
+
<span class="min-w-0 flex-1 truncate">{item.label}</span>
|
|
122
|
+
{#if item.hint}
|
|
123
|
+
<span class="text-amber-600 dark:text-amber-400 shrink-0 text-[10px]">{item.hint}</span>
|
|
124
|
+
{/if}
|
|
95
125
|
{/if}
|
|
96
126
|
</a>
|
|
97
127
|
{:else}
|
|
@@ -100,13 +130,17 @@
|
|
|
100
130
|
disabled={item.disabled}
|
|
101
131
|
title={collapsed ? item.label : undefined}
|
|
102
132
|
aria-current={value === item.id ? 'page' : undefined}
|
|
133
|
+
aria-checked={item.done ? 'true' : undefined}
|
|
103
134
|
class={itemClass(item)}
|
|
104
135
|
onclick={() => select(item.id, item.disabled)}
|
|
105
136
|
>
|
|
106
137
|
<RailMark active={value === item.id} side="right" length="short" inset="sm" />
|
|
107
138
|
{@render itemGlyph(item)}
|
|
108
139
|
{#if !collapsed}
|
|
109
|
-
<span class="truncate">{item.label}</span>
|
|
140
|
+
<span class="min-w-0 flex-1 truncate">{item.label}</span>
|
|
141
|
+
{#if item.hint}
|
|
142
|
+
<span class="text-amber-600 dark:text-amber-400 shrink-0 text-[10px]">{item.hint}</span>
|
|
143
|
+
{/if}
|
|
110
144
|
{/if}
|
|
111
145
|
</button>
|
|
112
146
|
{/if}
|
|
@@ -10,6 +10,10 @@ export interface SidebarItem {
|
|
|
10
10
|
href?: string;
|
|
11
11
|
icon?: SidebarIcon;
|
|
12
12
|
disabled?: boolean;
|
|
13
|
+
/** Completed step (wizard / stepper). Shows a check when not active. */
|
|
14
|
+
done?: boolean;
|
|
15
|
+
/** Optional short hint (e.g. warning). */
|
|
16
|
+
hint?: string;
|
|
13
17
|
}
|
|
14
18
|
export interface SidebarGroup {
|
|
15
19
|
id: string;
|
|
@@ -4,9 +4,10 @@
|
|
|
4
4
|
|
|
5
5
|
let props = $props<{
|
|
6
6
|
collapsed?: boolean;
|
|
7
|
+
wizard?: boolean;
|
|
7
8
|
}>();
|
|
8
9
|
|
|
9
|
-
const
|
|
10
|
+
const defaultGroups: SidebarGroup[] = [
|
|
10
11
|
{
|
|
11
12
|
id: 'main',
|
|
12
13
|
label: 'Workspace',
|
|
@@ -26,7 +27,30 @@
|
|
|
26
27
|
}
|
|
27
28
|
];
|
|
28
29
|
|
|
29
|
-
|
|
30
|
+
const wizardGroups: SidebarGroup[] = [
|
|
31
|
+
{
|
|
32
|
+
id: 'business',
|
|
33
|
+
label: 'Onboarding',
|
|
34
|
+
items: [{ id: 'business', label: 'Empresa', done: true }]
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
id: 'campaign',
|
|
38
|
+
label: 'Crea tu campaña',
|
|
39
|
+
items: [
|
|
40
|
+
{ id: 'themes', label: 'Temas de búsqueda', done: true },
|
|
41
|
+
{ id: 'ads', label: 'Crear anuncios' },
|
|
42
|
+
{ id: 'bidding', label: 'Estrategia de puja' },
|
|
43
|
+
{ id: 'budget', label: 'Presupuesto' }
|
|
44
|
+
]
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
id: 'payment',
|
|
48
|
+
items: [{ id: 'payment', label: 'Detalles del pago' }]
|
|
49
|
+
}
|
|
50
|
+
];
|
|
51
|
+
|
|
52
|
+
const groups = $derived(props.wizard ? wizardGroups : defaultGroups);
|
|
53
|
+
let value = $state(props.wizard ? 'ads' : 'projects');
|
|
30
54
|
let collapsed = $state(props.collapsed ?? false);
|
|
31
55
|
</script>
|
|
32
56
|
|