@nanahoshi/mona-ui 0.26.3 → 0.27.1
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/docs/circular-progress-bar.md +38 -0
- package/docs/sidebar-menus.md +548 -0
- package/docs/sidebar-state.md +519 -0
- package/docs/sidebar.md +17 -661
- package/fesm2022/nanahoshi-mona-ui-circular-progress-bar.mjs +38 -10
- package/llms.txt +2 -0
- package/package.json +1 -1
- package/types/nanahoshi-mona-ui-circular-progress-bar.d.ts +17 -3
|
@@ -71,6 +71,33 @@ export class CircularProgressBarSizesExampleComponent {
|
|
|
71
71
|
</div>
|
|
72
72
|
```
|
|
73
73
|
|
|
74
|
+
### Round and flat ends
|
|
75
|
+
|
|
76
|
+
The arc's ends are round by default. `lineCap="flat"` cuts them straight instead. Both cover the same part of the ring, so 72% reads the same either way.
|
|
77
|
+
|
|
78
|
+
`line-cap-example.component.ts`
|
|
79
|
+
|
|
80
|
+
```typescript
|
|
81
|
+
import { Component } from "@angular/core";
|
|
82
|
+
import { CircularProgressBarComponent } from "@nanahoshi/mona-ui/circular-progress-bar";
|
|
83
|
+
|
|
84
|
+
@Component({
|
|
85
|
+
selector: "app-circular-progress-bar-line-cap-example",
|
|
86
|
+
imports: [CircularProgressBarComponent],
|
|
87
|
+
templateUrl: "./line-cap-example.component.html"
|
|
88
|
+
})
|
|
89
|
+
export class CircularProgressBarLineCapExampleComponent {}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
`line-cap-example.component.html`
|
|
93
|
+
|
|
94
|
+
```html
|
|
95
|
+
<div class="flex flex-wrap items-center gap-6">
|
|
96
|
+
<mona-circular-progress-bar aria-label="Quiz score" [size]="120" [thickness]="12" [value]="72"></mona-circular-progress-bar>
|
|
97
|
+
<mona-circular-progress-bar aria-label="Course progress" lineCap="flat" [size]="120" [thickness]="12" [value]="72"></mona-circular-progress-bar>
|
|
98
|
+
</div>
|
|
99
|
+
```
|
|
100
|
+
|
|
74
101
|
### Indeterminate
|
|
75
102
|
|
|
76
103
|
Use it when the completion percentage is unknown. Set `aria-valuetext` so screen readers announce a state.
|
|
@@ -161,6 +188,10 @@ The `size` input controls the outer dimension of the SVG in pixels. Both width a
|
|
|
161
188
|
|
|
162
189
|
`thickness` controls the stroke width of both the track and the progress arc in pixels. The stroke fits inside `size`, so increasing it reduces the effective radius. The default of `6` suits most sizes; reduce it for small sizes or increase it for bold indicators.
|
|
163
190
|
|
|
191
|
+
### Line cap
|
|
192
|
+
|
|
193
|
+
`lineCap` sets the shape of the arc's ends: `"round"` (the default) rounds them, `"flat"` cuts them straight. A round end reaches half the `thickness` past where the arc ends, so the component shortens the arc by that much at each end to keep it within the value. An empty ring draws nothing either way, and a sliver of progress draws a dot as wide as the stroke.
|
|
194
|
+
|
|
164
195
|
### Color
|
|
165
196
|
|
|
166
197
|
When `color` is empty the arc color falls back to `var(--color-primary)`. The track (the full circle behind the arc) always uses the `var(--color-surface-muted)` design token.
|
|
@@ -243,6 +274,7 @@ Everything below is imported from `@nanahoshi/mona-ui/circular-progress-bar`.
|
|
|
243
274
|
| `disabled` | `boolean` | `false` | Renders the component with reduced visual emphasis and removes pointer interaction. |
|
|
244
275
|
| `indeterminate` | `boolean` | `false` | Activates indeterminate mode when the completion value is unknown. ARIA value attributes are removed. |
|
|
245
276
|
| `labelVisible` | `boolean` | `true` | Controls label visibility in determinate mode. Has no effect in indeterminate mode, where the label is always hidden. |
|
|
277
|
+
| `lineCap` | `CircularProgressBarLineCap` | `"round"` | Shape of the arc's two ends. `"round"` draws rounded ends that stay within the value's span, so the arc covers the same part of the ring as `"flat"`, which cuts them straight. An empty ring draws nothing either way. |
|
|
246
278
|
| `max` | `number` | `100` | Upper bound of the value range. Must be greater than `min`; otherwise the bar reports no values and a warning is logged in development. |
|
|
247
279
|
| `min` | `number` | `0` | Lower bound of the value range. |
|
|
248
280
|
| `size` | `number` | `100` | Diameter of the indicator in pixels. Controls both width and height of the host element. |
|
|
@@ -276,6 +308,12 @@ when `indeterminate` is `true`.
|
|
|
276
308
|
| `min` | `number` |
|
|
277
309
|
| `percent` | `number` |
|
|
278
310
|
|
|
311
|
+
#### `CircularProgressBarLineCap`
|
|
312
|
+
|
|
313
|
+
```typescript
|
|
314
|
+
type CircularProgressBarLineCap = "flat" | "round";
|
|
315
|
+
```
|
|
316
|
+
|
|
279
317
|
#### `Action`
|
|
280
318
|
|
|
281
319
|
From `@nanahoshi/mona-ui/common`.
|
|
@@ -0,0 +1,548 @@
|
|
|
1
|
+
# Sidebar Menus
|
|
2
|
+
|
|
3
|
+
> Groups, menus, rows, submenus, badges, actions and loading rows inside a sidebar.
|
|
4
|
+
|
|
5
|
+
Entry point: `@nanahoshi/mona-ui/sidebar`
|
|
6
|
+
|
|
7
|
+
**Selectors:** `[monaSidebarGroup]`, `ul[monaSidebarMenu]`, `li[monaSidebarMenuItem]`, `a[monaSidebarMenuButton]`, `button[monaSidebarMenuButton]`, `mona-sidebar-menu-skeleton`, and the parts below
|
|
8
|
+
|
|
9
|
+
What goes inside a [sidebar](sidebar.md): titled groups, lists of rows, and what a row can carry — a badge, a trailing action, a submenu. Every part is a directive on your own element, and each one knows what to do on the icon rail, where only the row's icon is left.
|
|
10
|
+
|
|
11
|
+
## Overview
|
|
12
|
+
|
|
13
|
+
A sidebar's content is groups of rows. Every part below is a directive on your own element, apart from the skeleton, and none of them are required.
|
|
14
|
+
|
|
15
|
+
| Part | Host | Purpose |
|
|
16
|
+
| --- | --- | --- |
|
|
17
|
+
| `[monaSidebarGroup]` | any | A titled section; stack as many as you need |
|
|
18
|
+
| `[monaSidebarGroupHeader]` | any | The row holding a group's label and action; collapses away on the rail |
|
|
19
|
+
| `[monaSidebarGroupLabel]` | any | The group's name, which the group is labelled by; fades out on the rail |
|
|
20
|
+
| `[monaSidebarGroupAction]` | `button` | A control in the group header's corner; needs an `aria-label` |
|
|
21
|
+
| `[monaSidebarGroupContent]` | any | The group's body, wrapping its menu |
|
|
22
|
+
| `[monaSidebarMenu]` | `ul` | A list of rows |
|
|
23
|
+
| `[monaSidebarMenuItem]` | `li` | One row; owns the highlight and `active` |
|
|
24
|
+
| `[monaSidebarMenuButton]` | `a` / `button` | The row's control; takes `tooltip`, `size`, `disabled`, `closeOnSelect` |
|
|
25
|
+
| `[monaSidebarMenuAction]` | `button` | A trailing control inside the row; needs an `aria-label` |
|
|
26
|
+
| `[monaSidebarMenuBadge]` | any | A trailing count or status; stands down on the rail |
|
|
27
|
+
| `[monaSidebarMenuSub]` | `ul` | An indented submenu inside a collapsible item |
|
|
28
|
+
| `[monaSidebarInput]` | `input` | A text input sized for the sidebar; stands down on the rail |
|
|
29
|
+
| `mona-sidebar-menu-skeleton` | element | A loading placeholder row |
|
|
30
|
+
|
|
31
|
+
The panel around them, its regions and its look are on the [Sidebar](sidebar.md) page.
|
|
32
|
+
|
|
33
|
+
## Import & Quick Start
|
|
34
|
+
|
|
35
|
+
```typescript
|
|
36
|
+
import {
|
|
37
|
+
SidebarGroupContentDirective,
|
|
38
|
+
SidebarGroupDirective,
|
|
39
|
+
SidebarGroupHeaderDirective,
|
|
40
|
+
SidebarGroupLabelDirective,
|
|
41
|
+
SidebarMenuBadgeDirective,
|
|
42
|
+
SidebarMenuButtonDirective,
|
|
43
|
+
SidebarMenuDirective,
|
|
44
|
+
SidebarMenuItemDirective
|
|
45
|
+
} from "@nanahoshi/mona-ui/sidebar";
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
A row is an item plus a control, and optionally something trailing:
|
|
49
|
+
|
|
50
|
+
```html
|
|
51
|
+
<div monaSidebarGroup>
|
|
52
|
+
<div monaSidebarGroupHeader>
|
|
53
|
+
<span monaSidebarGroupLabel>Mail</span>
|
|
54
|
+
</div>
|
|
55
|
+
<div monaSidebarGroupContent>
|
|
56
|
+
<ul monaSidebarMenu>
|
|
57
|
+
<li monaSidebarMenuItem [active]="isCurrent()">
|
|
58
|
+
<a monaSidebarMenuButton routerLink="/inbox" tooltip="Inbox">
|
|
59
|
+
<svg lucideInbox [size]="16"></svg>
|
|
60
|
+
<span>Inbox</span>
|
|
61
|
+
</a>
|
|
62
|
+
<span monaSidebarMenuBadge>12</span>
|
|
63
|
+
</li>
|
|
64
|
+
</ul>
|
|
65
|
+
</div>
|
|
66
|
+
</div>
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## Examples
|
|
70
|
+
|
|
71
|
+
### Badges, actions and loading rows
|
|
72
|
+
|
|
73
|
+
A group action in the header, a badge and an overflow action on a row, a disabled row, and a group still loading.
|
|
74
|
+
|
|
75
|
+
`rows-example.component.ts`
|
|
76
|
+
|
|
77
|
+
```typescript
|
|
78
|
+
import { Component, signal } from "@angular/core";
|
|
79
|
+
import {
|
|
80
|
+
LucideArchive,
|
|
81
|
+
LucideCirclePlus,
|
|
82
|
+
LucideEllipsis,
|
|
83
|
+
LucideInbox,
|
|
84
|
+
LucidePanelLeft,
|
|
85
|
+
LucideSend,
|
|
86
|
+
LucideTrash2
|
|
87
|
+
} from "@lucide/angular";
|
|
88
|
+
import { ButtonDirective } from "@nanahoshi/mona-ui/button";
|
|
89
|
+
import { PopupMenuComponent, PopupMenuItemComponent } from "@nanahoshi/mona-ui/popup-menu";
|
|
90
|
+
import {
|
|
91
|
+
SidebarComponent,
|
|
92
|
+
SidebarContentDirective,
|
|
93
|
+
SidebarGroupActionDirective,
|
|
94
|
+
SidebarGroupContentDirective,
|
|
95
|
+
SidebarGroupDirective,
|
|
96
|
+
SidebarGroupHeaderDirective,
|
|
97
|
+
SidebarGroupLabelDirective,
|
|
98
|
+
SidebarInsetDirective,
|
|
99
|
+
SidebarLayoutComponent,
|
|
100
|
+
SidebarMenuActionDirective,
|
|
101
|
+
SidebarMenuBadgeDirective,
|
|
102
|
+
SidebarMenuButtonDirective,
|
|
103
|
+
SidebarMenuDirective,
|
|
104
|
+
SidebarMenuItemDirective,
|
|
105
|
+
SidebarMenuSkeletonComponent,
|
|
106
|
+
SidebarTriggerDirective
|
|
107
|
+
} from "@nanahoshi/mona-ui/sidebar";
|
|
108
|
+
|
|
109
|
+
@Component({
|
|
110
|
+
selector: "app-sidebar-menus-rows-example",
|
|
111
|
+
imports: [
|
|
112
|
+
ButtonDirective,
|
|
113
|
+
LucideArchive,
|
|
114
|
+
LucideCirclePlus,
|
|
115
|
+
LucideEllipsis,
|
|
116
|
+
LucideInbox,
|
|
117
|
+
LucidePanelLeft,
|
|
118
|
+
LucideSend,
|
|
119
|
+
LucideTrash2,
|
|
120
|
+
PopupMenuComponent,
|
|
121
|
+
PopupMenuItemComponent,
|
|
122
|
+
SidebarComponent,
|
|
123
|
+
SidebarContentDirective,
|
|
124
|
+
SidebarGroupActionDirective,
|
|
125
|
+
SidebarGroupContentDirective,
|
|
126
|
+
SidebarGroupDirective,
|
|
127
|
+
SidebarGroupHeaderDirective,
|
|
128
|
+
SidebarGroupLabelDirective,
|
|
129
|
+
SidebarInsetDirective,
|
|
130
|
+
SidebarLayoutComponent,
|
|
131
|
+
SidebarMenuActionDirective,
|
|
132
|
+
SidebarMenuBadgeDirective,
|
|
133
|
+
SidebarMenuButtonDirective,
|
|
134
|
+
SidebarMenuDirective,
|
|
135
|
+
SidebarMenuItemDirective,
|
|
136
|
+
SidebarMenuSkeletonComponent,
|
|
137
|
+
SidebarTriggerDirective
|
|
138
|
+
],
|
|
139
|
+
templateUrl: "./rows-example.component.html"
|
|
140
|
+
})
|
|
141
|
+
export class SidebarMenusRowsExampleComponent {
|
|
142
|
+
protected readonly current = signal("Inbox");
|
|
143
|
+
protected readonly labelWidths = ["70%", "45%", "60%"];
|
|
144
|
+
|
|
145
|
+
/** Stands in for the router, so the example stays on this page. */
|
|
146
|
+
protected open(event: Event, label: string): void {
|
|
147
|
+
event.preventDefault();
|
|
148
|
+
this.current.set(label);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
`rows-example.component.html`
|
|
154
|
+
|
|
155
|
+
```html
|
|
156
|
+
<mona-sidebar-layout class="h-96 border border-border" modalScope="layout">
|
|
157
|
+
<mona-sidebar collapsible="icon">
|
|
158
|
+
<nav monaSidebarContent aria-label="Mail">
|
|
159
|
+
<div monaSidebarGroup>
|
|
160
|
+
<div monaSidebarGroupHeader>
|
|
161
|
+
<div monaSidebarGroupLabel>Mail</div>
|
|
162
|
+
<button monaSidebarGroupAction aria-label="New folder" type="button">
|
|
163
|
+
<svg lucideCirclePlus aria-hidden="true" [size]="14"></svg>
|
|
164
|
+
</button>
|
|
165
|
+
</div>
|
|
166
|
+
<div monaSidebarGroupContent>
|
|
167
|
+
<ul monaSidebarMenu>
|
|
168
|
+
<li monaSidebarMenuItem [active]="current() === 'Inbox'">
|
|
169
|
+
<a monaSidebarMenuButton href="/mail/inbox" tooltip="Inbox" (click)="open($event, 'Inbox')">
|
|
170
|
+
<svg lucideInbox aria-hidden="true" [size]="16"></svg>
|
|
171
|
+
<span>Inbox</span>
|
|
172
|
+
</a>
|
|
173
|
+
<span monaSidebarMenuBadge>12</span>
|
|
174
|
+
<button #inboxActions monaSidebarMenuAction aria-label="Inbox actions" type="button">
|
|
175
|
+
<svg lucideEllipsis aria-hidden="true" [size]="14"></svg>
|
|
176
|
+
</button>
|
|
177
|
+
<mona-popup-menu [target]="inboxActions">
|
|
178
|
+
<mona-popup-menu-item label="Mark all as read"></mona-popup-menu-item>
|
|
179
|
+
<mona-popup-menu-item label="Rename"></mona-popup-menu-item>
|
|
180
|
+
</mona-popup-menu>
|
|
181
|
+
</li>
|
|
182
|
+
<li monaSidebarMenuItem [active]="current() === 'Sent'">
|
|
183
|
+
<a monaSidebarMenuButton href="/mail/sent" tooltip="Sent" (click)="open($event, 'Sent')">
|
|
184
|
+
<svg lucideSend aria-hidden="true" [size]="16"></svg>
|
|
185
|
+
<span>Sent</span>
|
|
186
|
+
</a>
|
|
187
|
+
</li>
|
|
188
|
+
<li monaSidebarMenuItem>
|
|
189
|
+
<a monaSidebarMenuButton href="/mail/archive" tooltip="Archive" [disabled]="true">
|
|
190
|
+
<svg lucideArchive aria-hidden="true" [size]="16"></svg>
|
|
191
|
+
<span>Archive</span>
|
|
192
|
+
</a>
|
|
193
|
+
</li>
|
|
194
|
+
<li monaSidebarMenuItem [active]="current() === 'Trash'">
|
|
195
|
+
<a monaSidebarMenuButton href="/mail/trash" tooltip="Trash" (click)="open($event, 'Trash')">
|
|
196
|
+
<svg lucideTrash2 aria-hidden="true" [size]="16"></svg>
|
|
197
|
+
<span>Trash</span>
|
|
198
|
+
</a>
|
|
199
|
+
</li>
|
|
200
|
+
</ul>
|
|
201
|
+
</div>
|
|
202
|
+
</div>
|
|
203
|
+
<div monaSidebarGroup>
|
|
204
|
+
<div monaSidebarGroupHeader>
|
|
205
|
+
<div monaSidebarGroupLabel>Labels</div>
|
|
206
|
+
</div>
|
|
207
|
+
<div monaSidebarGroupContent aria-busy="true">
|
|
208
|
+
<ul monaSidebarMenu>
|
|
209
|
+
@for (width of labelWidths; track $index) {
|
|
210
|
+
<li monaSidebarMenuItem>
|
|
211
|
+
<mona-sidebar-menu-skeleton [labelWidth]="width"></mona-sidebar-menu-skeleton>
|
|
212
|
+
</li>
|
|
213
|
+
}
|
|
214
|
+
</ul>
|
|
215
|
+
</div>
|
|
216
|
+
</div>
|
|
217
|
+
</nav>
|
|
218
|
+
</mona-sidebar>
|
|
219
|
+
|
|
220
|
+
<div class="gap-2 p-4" monaSidebarInset>
|
|
221
|
+
<button monaButton monaSidebarTrigger aria-label="Toggle sidebar" look="ghost" type="button" [iconOnly]="true">
|
|
222
|
+
<svg lucidePanelLeft aria-hidden="true" [size]="16"></svg>
|
|
223
|
+
</button>
|
|
224
|
+
<p class="text-sm">Showing {{ current() }}</p>
|
|
225
|
+
</div>
|
|
226
|
+
</mona-sidebar-layout>
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
### With a submenu
|
|
230
|
+
|
|
231
|
+
A submenu is a `monaCollapsible` item whose content is a `monaSidebarMenuSub` list.
|
|
232
|
+
|
|
233
|
+
`submenus-example.component.ts`
|
|
234
|
+
|
|
235
|
+
```typescript
|
|
236
|
+
import { Component } from "@angular/core";
|
|
237
|
+
import { LucideBookOpen, LucideChevronRight, LucideFolder, LucidePanelLeft } from "@lucide/angular";
|
|
238
|
+
import { ButtonDirective } from "@nanahoshi/mona-ui/button";
|
|
239
|
+
import {
|
|
240
|
+
CollapsibleContentDirective,
|
|
241
|
+
CollapsibleDirective,
|
|
242
|
+
CollapsibleTriggerDirective
|
|
243
|
+
} from "@nanahoshi/mona-ui/collapsible";
|
|
244
|
+
import {
|
|
245
|
+
SidebarComponent,
|
|
246
|
+
SidebarContentDirective,
|
|
247
|
+
SidebarInsetDirective,
|
|
248
|
+
SidebarLayoutComponent,
|
|
249
|
+
SidebarMenuButtonDirective,
|
|
250
|
+
SidebarMenuDirective,
|
|
251
|
+
SidebarMenuItemDirective,
|
|
252
|
+
SidebarMenuSubDirective,
|
|
253
|
+
SidebarTriggerDirective
|
|
254
|
+
} from "@nanahoshi/mona-ui/sidebar";
|
|
255
|
+
|
|
256
|
+
@Component({
|
|
257
|
+
selector: "app-sidebar-menus-submenus-example",
|
|
258
|
+
imports: [
|
|
259
|
+
ButtonDirective,
|
|
260
|
+
CollapsibleContentDirective,
|
|
261
|
+
CollapsibleDirective,
|
|
262
|
+
CollapsibleTriggerDirective,
|
|
263
|
+
LucideBookOpen,
|
|
264
|
+
LucideChevronRight,
|
|
265
|
+
LucideFolder,
|
|
266
|
+
LucidePanelLeft,
|
|
267
|
+
SidebarComponent,
|
|
268
|
+
SidebarContentDirective,
|
|
269
|
+
SidebarInsetDirective,
|
|
270
|
+
SidebarLayoutComponent,
|
|
271
|
+
SidebarMenuButtonDirective,
|
|
272
|
+
SidebarMenuDirective,
|
|
273
|
+
SidebarMenuItemDirective,
|
|
274
|
+
SidebarMenuSubDirective,
|
|
275
|
+
SidebarTriggerDirective
|
|
276
|
+
],
|
|
277
|
+
templateUrl: "./submenus-example.component.html"
|
|
278
|
+
})
|
|
279
|
+
export class SidebarMenusSubmenusExampleComponent {
|
|
280
|
+
protected readonly pages = ["Button", "Card", "Tabs"];
|
|
281
|
+
}
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
`submenus-example.component.html`
|
|
285
|
+
|
|
286
|
+
```html
|
|
287
|
+
<mona-sidebar-layout class="h-80 border border-border" modalScope="layout">
|
|
288
|
+
<mona-sidebar collapsible="icon">
|
|
289
|
+
<nav monaSidebarContent aria-label="Documentation">
|
|
290
|
+
<ul monaSidebarMenu>
|
|
291
|
+
<li monaSidebarMenuItem>
|
|
292
|
+
<a monaSidebarMenuButton href="/docs" tooltip="Introduction" (click)="$event.preventDefault()">
|
|
293
|
+
<svg lucideBookOpen aria-hidden="true" [size]="16"></svg>
|
|
294
|
+
<span>Introduction</span>
|
|
295
|
+
</a>
|
|
296
|
+
</li>
|
|
297
|
+
<li #components="monaCollapsible" monaCollapsible monaSidebarMenuItem [expanded]="true">
|
|
298
|
+
<button monaCollapsibleTrigger monaSidebarMenuButton tooltip="Components" type="button">
|
|
299
|
+
<svg lucideFolder aria-hidden="true" [size]="16"></svg>
|
|
300
|
+
<span>Components</span>
|
|
301
|
+
<svg
|
|
302
|
+
class="ms-auto transition-transform"
|
|
303
|
+
lucideChevronRight
|
|
304
|
+
aria-hidden="true"
|
|
305
|
+
[size]="16"
|
|
306
|
+
[style.rotate]="components.expanded() ? '90deg' : '0deg'"></svg>
|
|
307
|
+
</button>
|
|
308
|
+
<ul monaCollapsibleContent monaSidebarMenuSub>
|
|
309
|
+
@for (page of pages; track page) {
|
|
310
|
+
<li monaSidebarMenuItem>
|
|
311
|
+
<a monaSidebarMenuButton href="/docs" (click)="$event.preventDefault()">{{ page }}</a>
|
|
312
|
+
</li>
|
|
313
|
+
}
|
|
314
|
+
</ul>
|
|
315
|
+
</li>
|
|
316
|
+
</ul>
|
|
317
|
+
</nav>
|
|
318
|
+
</mona-sidebar>
|
|
319
|
+
|
|
320
|
+
<div class="p-4" monaSidebarInset>
|
|
321
|
+
<button monaButton monaSidebarTrigger aria-label="Toggle sidebar" look="ghost" type="button" [iconOnly]="true">
|
|
322
|
+
<svg lucidePanelLeft aria-hidden="true" [size]="16"></svg>
|
|
323
|
+
</button>
|
|
324
|
+
</div>
|
|
325
|
+
</mona-sidebar-layout>
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
## Behavior
|
|
329
|
+
|
|
330
|
+
### Rows
|
|
331
|
+
|
|
332
|
+
`active` goes on the **item**, which owns the row's highlight, so a badge or a trailing action stays inside one continuous highlight. The row's control picks up `aria-current="page"` from it.
|
|
333
|
+
|
|
334
|
+
`size="large"` is for a row that opens with something avatar sized, such as a profile row in the footer. The icon rail lets it fill the square edge to edge instead of insetting and clipping it, and the row is taller while the sidebar is expanded.
|
|
335
|
+
|
|
336
|
+
`disabled` suppresses the row's activation, including a `routerLink` and any `click` handler on it. A disabled `button` gets the native `disabled` attribute. A disabled anchor gives up its `href`, and keeps a tab stop and `aria-disabled` so it is still announced.
|
|
337
|
+
|
|
338
|
+
### Closing the drawer
|
|
339
|
+
|
|
340
|
+
On a compact viewport the sidebar is a drawer that covers the page, so activating a row closes it: the destination is underneath. Opt out with `[closeOnSelect]="false"` on a row that doesn't navigate. A row that opens a submenu leaves the drawer open without that binding.
|
|
341
|
+
|
|
342
|
+
### Submenus
|
|
343
|
+
|
|
344
|
+
A submenu is an ordinary `monaCollapsible` on an ordinary item — the sidebar adds no disclosure of its own. Apply `monaCollapsible` to the item, `monaCollapsibleTrigger` to its control, and `monaCollapsibleContent` to a `monaSidebarMenuSub` list, as in the [With a submenu](#with-a-submenu) example.
|
|
345
|
+
|
|
346
|
+
Nesting is not limited to one level: a `monaSidebarMenuSub` can hold another collapsible item, as deep as the navigation needs. Each level is a disclosure in its own right, with its own trigger and its own open state.
|
|
347
|
+
|
|
348
|
+
### On the icon rail
|
|
349
|
+
|
|
350
|
+
With `collapsible="icon"` a collapsed sidebar keeps only each row's leading visual, in a square:
|
|
351
|
+
|
|
352
|
+
- Labels are clipped, and each row's `tooltip` names it instead.
|
|
353
|
+
- Group headers collapse away, and group labels fade out.
|
|
354
|
+
- Badges, trailing actions, group actions and `monaSidebarInput` stand down.
|
|
355
|
+
- A skeleton row clips its label bar, as the real labels are.
|
|
356
|
+
|
|
357
|
+
A submenu cannot render in a rail one icon wide, and there's no flyout. While on the rail every item keeps its disclosure closed, at every depth, so each trigger's `aria-expanded` stays truthful and the content stays `inert`. Activating a submenu's row on the rail expands the sidebar and opens that submenu, so its pages can always be reached. A row with no submenu leaves the rail as it is. Whatever was open before collapsing is restored when the sidebar expands again — level by level, so a submenu that was closed stays closed.
|
|
358
|
+
|
|
359
|
+
### Loading rows
|
|
360
|
+
|
|
361
|
+
`mona-sidebar-menu-skeleton` goes in an item in place of the row's control, laid out exactly like a real row, so the two animate as one. Vary `labelWidth` across a list so the placeholder doesn't look like a rigid grid, and set `[showIcon]="false"` for rows that have no icon.
|
|
362
|
+
|
|
363
|
+
The skeleton is hidden from assistive technology. Mark what's loading on its container instead, with `aria-busy="true"`, and remove it when the rows arrive.
|
|
364
|
+
|
|
365
|
+
## Accessibility
|
|
366
|
+
|
|
367
|
+
### Use anchors for destinations
|
|
368
|
+
|
|
369
|
+
`monaSidebarMenuButton` applies to both `a` and `button`. Use an anchor for anything that navigates:
|
|
370
|
+
|
|
371
|
+
```html
|
|
372
|
+
<a monaSidebarMenuButton routerLink="/billing" tooltip="Billing">…</a>
|
|
373
|
+
```
|
|
374
|
+
|
|
375
|
+
A button cannot be opened in a new tab, middle-clicked, previewed in the status bar, or followed when JavaScript fails. Reserve `button` for actions — a disclosure trigger, a sign-out.
|
|
376
|
+
|
|
377
|
+
### Label the icon rail
|
|
378
|
+
|
|
379
|
+
While collapsed to icons the labels are clipped away. Set `tooltip` on every row, and the row shows it as a tooltip on hover and on keyboard focus, on the rail only. Keep a label inside the row as well: that's its accessible name, in both states.
|
|
380
|
+
|
|
381
|
+
`mona-sidebar` shows these itself, and they open toward the content. There's nothing to import, and it isn't a `title`: the browser adds no tooltip of its own, and a `monaTooltip` in `content` mode around the sidebar doesn't pick the row up. A `title` you put on a row yourself stays there, so use one or the other.
|
|
382
|
+
|
|
383
|
+
### Name the icon-only controls
|
|
384
|
+
|
|
385
|
+
`monaSidebarGroupAction` and `monaSidebarMenuAction` hold only an icon, so each needs an `aria-label` that says what it acts on, such as "Inbox actions" rather than "More".
|
|
386
|
+
|
|
387
|
+
## API
|
|
388
|
+
|
|
389
|
+
Everything below is imported from `@nanahoshi/mona-ui/sidebar`.
|
|
390
|
+
|
|
391
|
+
### `SidebarMenuSkeletonComponent`
|
|
392
|
+
|
|
393
|
+
A loading placeholder shaped like a menu item. Its label bar is clipped on the icon rail, where the
|
|
394
|
+
real labels are not visible either.
|
|
395
|
+
|
|
396
|
+
**Selector:** `mona-sidebar-menu-skeleton`
|
|
397
|
+
|
|
398
|
+
#### Inputs
|
|
399
|
+
|
|
400
|
+
| Name | Type | Default | Description |
|
|
401
|
+
| --- | --- | --- | --- |
|
|
402
|
+
| `labelWidth` | `string \| number` | `"60%"` | Width of the label bar. Varying it across a list keeps the placeholder from looking like a rigid grid. Numbers are treated as pixels. |
|
|
403
|
+
| `showIcon` | `boolean` | `true` | Renders a square standing in for the item's icon. |
|
|
404
|
+
|
|
405
|
+
### `SidebarMenuButtonDirective`
|
|
406
|
+
|
|
407
|
+
A row in a sidebar menu. Applies to a `button` for an action and to an `a` for a destination —
|
|
408
|
+
an anchor keeps `href`, `routerLink`, middle-click, open-in-new-tab and the browser's own status
|
|
409
|
+
bar preview, none of which a button can offer.
|
|
410
|
+
|
|
411
|
+
On a compact viewport, following a link closes the drawer, since the destination it navigates to is
|
|
412
|
+
underneath it. A row that opens a submenu leaves the drawer open, and on the icon rail it expands the
|
|
413
|
+
sidebar, since that's the only place the submenu can open.
|
|
414
|
+
|
|
415
|
+
**Selector:** `a[monaSidebarMenuButton], button[monaSidebarMenuButton]`
|
|
416
|
+
**Exported as:** `monaSidebarMenuButton`
|
|
417
|
+
|
|
418
|
+
#### Inputs
|
|
419
|
+
|
|
420
|
+
| Name | Type | Default | Description |
|
|
421
|
+
| --- | --- | --- | --- |
|
|
422
|
+
| `class` | `ClassInputType` | `""` | Additional CSS classes merged onto the host element via `tailwind-merge`. |
|
|
423
|
+
| `closeOnSelect` | `boolean \| undefined` | `undefined` | Closes the overlay drawer after this row is activated. Only applies on compact viewports, where the drawer covers the destination being navigated to. Set to `false` for rows that do not navigate. Leave it unset on a `monaCollapsibleTrigger`, which keeps the drawer open. |
|
|
424
|
+
| `disabled` | `boolean` | `false` | Renders the row as unavailable and suppresses activation, including a `routerLink` and any `click` handler on it. A disabled anchor gives up its `href`. |
|
|
425
|
+
| `size` | `SidebarMenuButtonSize` | `"medium"` | How much room this row's leading visual needs. Use `"large"` when it opens with something avatar sized, so the icon rail lets it fill the square instead of insetting and clipping it. |
|
|
426
|
+
| `tooltip` | `string` | `""` | Text identifying this item while the sidebar is collapsed to its icon rail, where the label is clipped away. Shown as a tooltip on hover and on keyboard focus, on the rail only. |
|
|
427
|
+
|
|
428
|
+
### `SidebarMenuItemDirective`
|
|
429
|
+
|
|
430
|
+
**Selector:** `li[monaSidebarMenuItem]`
|
|
431
|
+
|
|
432
|
+
#### Inputs
|
|
433
|
+
|
|
434
|
+
| Name | Type | Default | Description |
|
|
435
|
+
| --- | --- | --- | --- |
|
|
436
|
+
| `active` | `boolean` | `false` | Marks this row as the current sidebar destination. The row owns the selected surface so trailing badges and actions remain inside one continuous highlight. |
|
|
437
|
+
| `class` | `ClassInputType` | `""` | Additional CSS classes merged onto the host element via `tailwind-merge`. |
|
|
438
|
+
|
|
439
|
+
### `SidebarMenuBadgeDirective`
|
|
440
|
+
|
|
441
|
+
A trailing count or status badge on a menu item. Stands down on the icon rail, where it would
|
|
442
|
+
crowd out the icon it belongs to.
|
|
443
|
+
|
|
444
|
+
**Selector:** `[monaSidebarMenuBadge]`
|
|
445
|
+
|
|
446
|
+
#### Inputs
|
|
447
|
+
|
|
448
|
+
| Name | Type | Default | Description |
|
|
449
|
+
| --- | --- | --- | --- |
|
|
450
|
+
| `class` | `ClassInputType` | `""` | Additional CSS classes merged onto the host element via `tailwind-merge`. |
|
|
451
|
+
|
|
452
|
+
### `SidebarMenuDirective`
|
|
453
|
+
|
|
454
|
+
**Selector:** `ul[monaSidebarMenu]`
|
|
455
|
+
|
|
456
|
+
#### Inputs
|
|
457
|
+
|
|
458
|
+
| Name | Type | Default | Description |
|
|
459
|
+
| --- | --- | --- | --- |
|
|
460
|
+
| `class` | `ClassInputType` | `""` | Additional CSS classes merged onto the host element via `tailwind-merge`. |
|
|
461
|
+
|
|
462
|
+
### `SidebarMenuSubDirective`
|
|
463
|
+
|
|
464
|
+
An indented submenu inside a `monaSidebarMenuItem` that is also a `monaCollapsible`.
|
|
465
|
+
|
|
466
|
+
It carries no hiding of its own on the icon rail. `SidebarMenuItemDirective` closes the disclosure
|
|
467
|
+
there instead, which leaves the trigger's `aria-expanded` truthful and lets the collapsible content
|
|
468
|
+
directive apply its own `inert`. Hiding it here as well used to produce the opposite: a submenu the
|
|
469
|
+
trigger still described as expanded, with focusable items, that nobody could see.
|
|
470
|
+
|
|
471
|
+
**Selector:** `ul[monaSidebarMenuSub]`
|
|
472
|
+
|
|
473
|
+
#### Inputs
|
|
474
|
+
|
|
475
|
+
| Name | Type | Default | Description |
|
|
476
|
+
| --- | --- | --- | --- |
|
|
477
|
+
| `class` | `ClassInputType` | `""` | Additional CSS classes merged onto the host element via `tailwind-merge`. |
|
|
478
|
+
|
|
479
|
+
### `SidebarGroupActionDirective`
|
|
480
|
+
|
|
481
|
+
A control in the corner of a group header — an add or overflow button. Stands down on the icon
|
|
482
|
+
rail, where there is no header row left to sit in. Give it an `aria-label`: it is icon-only.
|
|
483
|
+
|
|
484
|
+
**Selector:** `button[monaSidebarGroupAction]`
|
|
485
|
+
|
|
486
|
+
### `SidebarGroupContentDirective`
|
|
487
|
+
|
|
488
|
+
The body of a `monaSidebarGroup`, below its header. Wraps the menu itself.
|
|
489
|
+
|
|
490
|
+
**Selector:** `[monaSidebarGroupContent]`
|
|
491
|
+
|
|
492
|
+
### `SidebarGroupDirective`
|
|
493
|
+
|
|
494
|
+
A titled section of the sidebar, grouping a label and its menu. Stack as many as the sidebar
|
|
495
|
+
needs; each is an ordinary block, so a `monaSidebarSeparator` between them is optional. A
|
|
496
|
+
`monaSidebarGroupLabel` inside it names the group.
|
|
497
|
+
|
|
498
|
+
**Selector:** `[monaSidebarGroup]`
|
|
499
|
+
|
|
500
|
+
### `SidebarGroupHeaderDirective`
|
|
501
|
+
|
|
502
|
+
The row above a group's content, holding its label and any group action. Collapses to nothing on
|
|
503
|
+
the icon rail rather than leaving an empty gap where the label used to be.
|
|
504
|
+
|
|
505
|
+
**Selector:** `[monaSidebarGroupHeader]`
|
|
506
|
+
|
|
507
|
+
### `SidebarGroupLabelDirective`
|
|
508
|
+
|
|
509
|
+
The name of a group, which the enclosing `monaSidebarGroup` is labelled by. Fades out on the icon
|
|
510
|
+
rail, where there is no width to read it in.
|
|
511
|
+
|
|
512
|
+
**Selector:** `[monaSidebarGroupLabel]`
|
|
513
|
+
|
|
514
|
+
### `SidebarInputDirective`
|
|
515
|
+
|
|
516
|
+
A text input sized for the sidebar, composing `monaTextBox`. Stands down on the icon rail,
|
|
517
|
+
where there is no room to type.
|
|
518
|
+
|
|
519
|
+
**Selector:** `input[monaSidebarInput]`
|
|
520
|
+
|
|
521
|
+
### `SidebarMenuActionDirective`
|
|
522
|
+
|
|
523
|
+
A trailing control on a menu item — an overflow menu, a pin. Sits inside the row's highlight and
|
|
524
|
+
stands down on the icon rail. Give it an `aria-label`: it is icon-only.
|
|
525
|
+
|
|
526
|
+
**Selector:** `button[monaSidebarMenuAction]`
|
|
527
|
+
|
|
528
|
+
### Types
|
|
529
|
+
|
|
530
|
+
#### `SidebarMenuButtonSize`
|
|
531
|
+
|
|
532
|
+
How much room the button's leading visual needs.
|
|
533
|
+
|
|
534
|
+
- `medium` — sized for an icon, which the icon rail insets so it sits centred in the square.
|
|
535
|
+
- `large` — sized for a full-height visual such as an avatar, which fills the rail square edge to
|
|
536
|
+
edge, and which is given a taller row while the sidebar is expanded.
|
|
537
|
+
|
|
538
|
+
```typescript
|
|
539
|
+
type SidebarMenuButtonSize = "medium" | "large";
|
|
540
|
+
```
|
|
541
|
+
|
|
542
|
+
#### `ClassInputType`
|
|
543
|
+
|
|
544
|
+
From `@nanahoshi/mona-ui/common`.
|
|
545
|
+
|
|
546
|
+
```typescript
|
|
547
|
+
type ClassInputType = string | string[] | Record<string, unknown> | null | undefined;
|
|
548
|
+
```
|