@aiaiai-pt/design-system 0.58.0 → 0.59.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.
|
@@ -22,6 +22,11 @@
|
|
|
22
22
|
{#snippet icon()}<svg>...</svg>{/snippet}
|
|
23
23
|
INBOX
|
|
24
24
|
</SidebarItem>
|
|
25
|
+
|
|
26
|
+
@example Collapsed with abbreviation (no icon)
|
|
27
|
+
<SidebarItem href="/cases" abbr="C" label="Cases">
|
|
28
|
+
Cases
|
|
29
|
+
</SidebarItem>
|
|
25
30
|
-->
|
|
26
31
|
<script>
|
|
27
32
|
import { getContext } from 'svelte';
|
|
@@ -41,11 +46,24 @@
|
|
|
41
46
|
icon = undefined,
|
|
42
47
|
/** @type {import('svelte').Snippet | undefined} */
|
|
43
48
|
children = undefined,
|
|
49
|
+
/** Short text shown when collapsed and no icon is given (e.g. the
|
|
50
|
+
* first letter of the entry). The component cannot read text out of
|
|
51
|
+
* the `children` snippet, so the consumer supplies it. If absent and
|
|
52
|
+
* there is no icon, nothing is rendered when collapsed. */
|
|
53
|
+
abbr = undefined,
|
|
54
|
+
/** Full accessible name used as `aria-label` and `title` when
|
|
55
|
+
* collapsed. When expanded, the visible children serve as the name
|
|
56
|
+
* and no `aria-label` is added. A consumer passing `abbr` should
|
|
57
|
+
* pass `label` so the collapsed abbreviation has a full name. */
|
|
58
|
+
label = undefined,
|
|
44
59
|
...rest
|
|
45
60
|
} = $props();
|
|
46
61
|
|
|
47
62
|
const sidebar = getContext('aiaiai-sidebar');
|
|
48
63
|
const isCollapsed = $derived(sidebar?.collapsed ?? false);
|
|
64
|
+
|
|
65
|
+
/** Whether to show the abbreviation: collapsed, no icon, abbr provided. */
|
|
66
|
+
const showAbbr = $derived(isCollapsed && !icon && !!abbr);
|
|
49
67
|
</script>
|
|
50
68
|
|
|
51
69
|
{#if href && !disabled}
|
|
@@ -54,9 +72,12 @@
|
|
|
54
72
|
class="nav-item {className}"
|
|
55
73
|
class:nav-item-active={active}
|
|
56
74
|
aria-current={active ? 'page' : undefined}
|
|
75
|
+
aria-label={isCollapsed && label ? label : undefined}
|
|
76
|
+
title={isCollapsed && label ? label : undefined}
|
|
57
77
|
{...rest}
|
|
58
78
|
>
|
|
59
79
|
{#if icon}<span class="nav-icon-wrap">{@render icon()}</span>{/if}
|
|
80
|
+
{#if showAbbr}<span class="nav-abbr" aria-hidden="true">{abbr}</span>{/if}
|
|
60
81
|
{#if !isCollapsed}
|
|
61
82
|
{#if children}<span class="nav-item-label">{@render children()}</span>{/if}
|
|
62
83
|
{#if badge != null}<span class="nav-badge">{badge}</span>{/if}
|
|
@@ -69,9 +90,12 @@
|
|
|
69
90
|
class:nav-item-disabled={disabled}
|
|
70
91
|
{disabled}
|
|
71
92
|
aria-current={active ? 'page' : undefined}
|
|
93
|
+
aria-label={isCollapsed && label ? label : undefined}
|
|
94
|
+
title={isCollapsed && label ? label : undefined}
|
|
72
95
|
{...rest}
|
|
73
96
|
>
|
|
74
97
|
{#if icon}<span class="nav-icon-wrap">{@render icon()}</span>{/if}
|
|
98
|
+
{#if showAbbr}<span class="nav-abbr" aria-hidden="true">{abbr}</span>{/if}
|
|
75
99
|
{#if !isCollapsed}
|
|
76
100
|
{#if children}<span class="nav-item-label">{@render children()}</span>{/if}
|
|
77
101
|
{#if badge != null}<span class="nav-badge">{badge}</span>{/if}
|
|
@@ -131,6 +155,21 @@
|
|
|
131
155
|
height: 100%;
|
|
132
156
|
}
|
|
133
157
|
|
|
158
|
+
/* The abbreviation box matches the icon-wrap size so a column of
|
|
159
|
+
letters aligns with a column of icons. */
|
|
160
|
+
.nav-abbr {
|
|
161
|
+
display: flex;
|
|
162
|
+
flex-shrink: 0;
|
|
163
|
+
align-items: center;
|
|
164
|
+
justify-content: center;
|
|
165
|
+
width: var(--icon-size-sm);
|
|
166
|
+
height: var(--icon-size-sm);
|
|
167
|
+
font-family: var(--nav-item-font);
|
|
168
|
+
font-size: var(--nav-item-font-size);
|
|
169
|
+
font-weight: var(--raw-font-weight-semibold);
|
|
170
|
+
line-height: 1;
|
|
171
|
+
}
|
|
172
|
+
|
|
134
173
|
.nav-item-label {
|
|
135
174
|
white-space: nowrap;
|
|
136
175
|
overflow: hidden;
|
|
@@ -27,6 +27,11 @@ type SidebarItem = {
|
|
|
27
27
|
* {#snippet icon()}<svg>...</svg>{/snippet}
|
|
28
28
|
* INBOX
|
|
29
29
|
* </SidebarItem>
|
|
30
|
+
*
|
|
31
|
+
* @example Collapsed with abbreviation (no icon)
|
|
32
|
+
* <SidebarItem href="/cases" abbr="C" label="Cases">
|
|
33
|
+
* Cases
|
|
34
|
+
* </SidebarItem>
|
|
30
35
|
*/
|
|
31
36
|
declare const SidebarItem: import("svelte").Component<{
|
|
32
37
|
active?: boolean;
|
|
@@ -36,6 +41,8 @@ declare const SidebarItem: import("svelte").Component<{
|
|
|
36
41
|
class?: string;
|
|
37
42
|
icon?: any;
|
|
38
43
|
children?: any;
|
|
44
|
+
abbr?: any;
|
|
45
|
+
label?: any;
|
|
39
46
|
} & Record<string, any>, {}, "">;
|
|
40
47
|
type $$ComponentProps = {
|
|
41
48
|
active?: boolean;
|
|
@@ -45,4 +52,6 @@ type $$ComponentProps = {
|
|
|
45
52
|
class?: string;
|
|
46
53
|
icon?: any;
|
|
47
54
|
children?: any;
|
|
55
|
+
abbr?: any;
|
|
56
|
+
label?: any;
|
|
48
57
|
} & Record<string, any>;
|