@nanahoshi/mona-ui 0.27.0 → 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/sidebar-menus.md +548 -0
- package/docs/sidebar-state.md +519 -0
- package/docs/sidebar.md +17 -661
- package/llms.txt +2 -0
- package/package.json +1 -1
package/docs/sidebar.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
Entry point: `@nanahoshi/mona-ui/sidebar`
|
|
6
6
|
|
|
7
|
-
**Selectors:** `mona-sidebar-layout`, `mona-sidebar`, `[monaSidebarInset]`, `[monaSidebarTrigger]`, and the
|
|
7
|
+
**Selectors:** `mona-sidebar-layout`, `mona-sidebar`, `[monaSidebarInset]`, `[monaSidebarTrigger]`, and the parts below
|
|
8
8
|
|
|
9
9
|
Sidebar is a composable application shell. `mona-sidebar-layout` lays out one or more `mona-sidebar` panels beside a `[monaSidebarInset]` main region, and owns what they share — the breakpoint, the backdrop. Each panel keeps its own state. Everything else — headers, groups, menus, rows, footers — is a directive you apply to your own markup, so the structure stays yours.
|
|
10
10
|
|
|
@@ -21,42 +21,26 @@ The sidebar is split into a small number of structural pieces and a set of conte
|
|
|
21
21
|
|
|
22
22
|
Content is projected in author order, so a header, content region and footer appear exactly where you write them. None of the directives add wrapper elements.
|
|
23
23
|
|
|
24
|
+
| Topic | Page |
|
|
25
|
+
| :--- | :--- |
|
|
26
|
+
| The panel's regions, its look, its width and its side | This page |
|
|
27
|
+
| Groups, rows, submenus, badges, actions, loading rows and the icon rail's tooltips | [Sidebar Menus](sidebar-menus.md) |
|
|
28
|
+
| Collapsing, `[(expanded)]`, `persistKey`, `injectSidebar()`, the drawer and server rendering | [Sidebar State & Behavior](sidebar-state.md) |
|
|
29
|
+
|
|
24
30
|
### The parts
|
|
25
31
|
|
|
26
|
-
Apart from the skeleton, everything below is a directive applied to your own element. None of them are required, and none add markup of their own.
|
|
32
|
+
Apart from the skeleton, everything below is a directive applied to your own element. None of them are required, and none add markup of their own.
|
|
27
33
|
|
|
28
34
|
| Part | Host | Purpose |
|
|
29
35
|
| --- | --- | --- |
|
|
30
36
|
| `[monaSidebarHeader]` | any | Pinned region at the top, above the scrolling content |
|
|
31
37
|
| `[monaSidebarContent]` | any | The scrolling region between header and footer |
|
|
32
38
|
| `[monaSidebarFooter]` | any | Pinned region at the bottom |
|
|
33
|
-
| `[monaSidebarGroup]` | any | A titled section; stack as many as you need |
|
|
34
|
-
| `[monaSidebarGroupHeader]` | any | The row holding a group's label and action; collapses away on the rail |
|
|
35
|
-
| `[monaSidebarGroupLabel]` | any | The group's name, which the group is labelled by; fades out on the rail |
|
|
36
|
-
| `[monaSidebarGroupAction]` | `button` | A control in the group header's corner; needs an `aria-label` |
|
|
37
|
-
| `[monaSidebarGroupContent]` | any | The group's body, wrapping its menu |
|
|
38
|
-
| `[monaSidebarMenu]` | `ul` | A list of rows |
|
|
39
|
-
| `[monaSidebarMenuItem]` | `li` | One row; owns the highlight and `active` |
|
|
40
|
-
| `[monaSidebarMenuButton]` | `a` / `button` | The row's control; takes `tooltip`, `size`, `disabled`, `closeOnSelect` |
|
|
41
|
-
| `[monaSidebarMenuAction]` | `button` | A trailing control inside the row; needs an `aria-label` |
|
|
42
|
-
| `[monaSidebarMenuBadge]` | any | A trailing count or status; stands down on the rail |
|
|
43
|
-
| `[monaSidebarMenuSub]` | `ul` | An indented submenu inside a collapsible item |
|
|
44
|
-
| `[monaSidebarInput]` | `input` | A text input sized for the sidebar; stands down on the rail |
|
|
45
39
|
| `[monaSidebarSeparator]` | any | A rule between regions |
|
|
46
40
|
| `[monaSidebarRail]` | `button` | A pointer shortcut along the panel's edge; not a keyboard control — see below |
|
|
47
|
-
| `
|
|
48
|
-
|
|
49
|
-
A
|
|
50
|
-
|
|
51
|
-
```html
|
|
52
|
-
<li monaSidebarMenuItem [active]="isCurrent()">
|
|
53
|
-
<a monaSidebarMenuButton routerLink="/inbox" tooltip="Inbox">
|
|
54
|
-
<svg lucideInbox [size]="16"></svg>
|
|
55
|
-
<span>Inbox</span>
|
|
56
|
-
</a>
|
|
57
|
-
<span monaSidebarMenuBadge>12</span>
|
|
58
|
-
</li>
|
|
59
|
-
```
|
|
41
|
+
| `[monaSidebarGroup]` and its parts | any | A titled section of rows, described on [Sidebar Menus](sidebar-menus.md) |
|
|
42
|
+
| `[monaSidebarMenu]` and its parts | `ul` | A list of rows, described on [Sidebar Menus](sidebar-menus.md) |
|
|
43
|
+
| `[monaSidebarInput]` | `input` | A text input sized for the sidebar; stands down on the rail |
|
|
60
44
|
|
|
61
45
|
## Import & Quick Start
|
|
62
46
|
|
|
@@ -202,181 +186,6 @@ export class SidebarIconRailExampleComponent {
|
|
|
202
186
|
</mona-sidebar-layout>
|
|
203
187
|
```
|
|
204
188
|
|
|
205
|
-
### With a submenu
|
|
206
|
-
|
|
207
|
-
A submenu is a `monaCollapsible` item whose content is a `monaSidebarMenuSub` list.
|
|
208
|
-
|
|
209
|
-
`submenus-example.component.ts`
|
|
210
|
-
|
|
211
|
-
```typescript
|
|
212
|
-
import { Component } from "@angular/core";
|
|
213
|
-
import { LucideBookOpen, LucideChevronRight, LucideFolder, LucidePanelLeft } from "@lucide/angular";
|
|
214
|
-
import { ButtonDirective } from "@nanahoshi/mona-ui/button";
|
|
215
|
-
import {
|
|
216
|
-
CollapsibleContentDirective,
|
|
217
|
-
CollapsibleDirective,
|
|
218
|
-
CollapsibleTriggerDirective
|
|
219
|
-
} from "@nanahoshi/mona-ui/collapsible";
|
|
220
|
-
import {
|
|
221
|
-
SidebarComponent,
|
|
222
|
-
SidebarContentDirective,
|
|
223
|
-
SidebarInsetDirective,
|
|
224
|
-
SidebarLayoutComponent,
|
|
225
|
-
SidebarMenuButtonDirective,
|
|
226
|
-
SidebarMenuDirective,
|
|
227
|
-
SidebarMenuItemDirective,
|
|
228
|
-
SidebarMenuSubDirective,
|
|
229
|
-
SidebarTriggerDirective
|
|
230
|
-
} from "@nanahoshi/mona-ui/sidebar";
|
|
231
|
-
|
|
232
|
-
@Component({
|
|
233
|
-
selector: "app-sidebar-submenus-example",
|
|
234
|
-
imports: [
|
|
235
|
-
ButtonDirective,
|
|
236
|
-
CollapsibleContentDirective,
|
|
237
|
-
CollapsibleDirective,
|
|
238
|
-
CollapsibleTriggerDirective,
|
|
239
|
-
LucideBookOpen,
|
|
240
|
-
LucideChevronRight,
|
|
241
|
-
LucideFolder,
|
|
242
|
-
LucidePanelLeft,
|
|
243
|
-
SidebarComponent,
|
|
244
|
-
SidebarContentDirective,
|
|
245
|
-
SidebarInsetDirective,
|
|
246
|
-
SidebarLayoutComponent,
|
|
247
|
-
SidebarMenuButtonDirective,
|
|
248
|
-
SidebarMenuDirective,
|
|
249
|
-
SidebarMenuItemDirective,
|
|
250
|
-
SidebarMenuSubDirective,
|
|
251
|
-
SidebarTriggerDirective
|
|
252
|
-
],
|
|
253
|
-
templateUrl: "./submenus-example.component.html"
|
|
254
|
-
})
|
|
255
|
-
export class SidebarSubmenusExampleComponent {
|
|
256
|
-
protected readonly pages = ["Button", "Card", "Tabs"];
|
|
257
|
-
}
|
|
258
|
-
```
|
|
259
|
-
|
|
260
|
-
`submenus-example.component.html`
|
|
261
|
-
|
|
262
|
-
```html
|
|
263
|
-
<mona-sidebar-layout class="h-80 border border-border" modalScope="layout">
|
|
264
|
-
<mona-sidebar collapsible="icon">
|
|
265
|
-
<nav monaSidebarContent aria-label="Documentation">
|
|
266
|
-
<ul monaSidebarMenu>
|
|
267
|
-
<li monaSidebarMenuItem>
|
|
268
|
-
<a monaSidebarMenuButton href="/docs" tooltip="Introduction" (click)="$event.preventDefault()">
|
|
269
|
-
<svg lucideBookOpen aria-hidden="true" [size]="16"></svg>
|
|
270
|
-
<span>Introduction</span>
|
|
271
|
-
</a>
|
|
272
|
-
</li>
|
|
273
|
-
<li #components="monaCollapsible" monaCollapsible monaSidebarMenuItem [expanded]="true">
|
|
274
|
-
<button monaCollapsibleTrigger monaSidebarMenuButton tooltip="Components" type="button">
|
|
275
|
-
<svg lucideFolder aria-hidden="true" [size]="16"></svg>
|
|
276
|
-
<span>Components</span>
|
|
277
|
-
<svg
|
|
278
|
-
class="ms-auto transition-transform"
|
|
279
|
-
lucideChevronRight
|
|
280
|
-
aria-hidden="true"
|
|
281
|
-
[size]="16"
|
|
282
|
-
[style.rotate]="components.expanded() ? '90deg' : '0deg'"></svg>
|
|
283
|
-
</button>
|
|
284
|
-
<ul monaCollapsibleContent monaSidebarMenuSub>
|
|
285
|
-
@for (page of pages; track page) {
|
|
286
|
-
<li monaSidebarMenuItem>
|
|
287
|
-
<a monaSidebarMenuButton href="/docs" (click)="$event.preventDefault()">{{ page }}</a>
|
|
288
|
-
</li>
|
|
289
|
-
}
|
|
290
|
-
</ul>
|
|
291
|
-
</li>
|
|
292
|
-
</ul>
|
|
293
|
-
</nav>
|
|
294
|
-
</mona-sidebar>
|
|
295
|
-
|
|
296
|
-
<div class="p-4" monaSidebarInset>
|
|
297
|
-
<button monaButton monaSidebarTrigger aria-label="Toggle sidebar" look="ghost" type="button" [iconOnly]="true">
|
|
298
|
-
<svg lucidePanelLeft aria-hidden="true" [size]="16"></svg>
|
|
299
|
-
</button>
|
|
300
|
-
</div>
|
|
301
|
-
</mona-sidebar-layout>
|
|
302
|
-
```
|
|
303
|
-
|
|
304
|
-
### Two sidebars
|
|
305
|
-
|
|
306
|
-
Each sidebar has an `id`, and each trigger names the one it toggles with `for`.
|
|
307
|
-
|
|
308
|
-
`two-sidebars-example.component.ts`
|
|
309
|
-
|
|
310
|
-
```typescript
|
|
311
|
-
import { Component, signal } from "@angular/core";
|
|
312
|
-
import { ButtonDirective } from "@nanahoshi/mona-ui/button";
|
|
313
|
-
import {
|
|
314
|
-
SidebarComponent,
|
|
315
|
-
SidebarContentDirective,
|
|
316
|
-
SidebarInsetDirective,
|
|
317
|
-
SidebarLayoutComponent,
|
|
318
|
-
SidebarMenuButtonDirective,
|
|
319
|
-
SidebarMenuDirective,
|
|
320
|
-
SidebarMenuItemDirective,
|
|
321
|
-
SidebarTriggerDirective
|
|
322
|
-
} from "@nanahoshi/mona-ui/sidebar";
|
|
323
|
-
|
|
324
|
-
@Component({
|
|
325
|
-
selector: "app-sidebar-two-sidebars-example",
|
|
326
|
-
imports: [
|
|
327
|
-
ButtonDirective,
|
|
328
|
-
SidebarComponent,
|
|
329
|
-
SidebarContentDirective,
|
|
330
|
-
SidebarInsetDirective,
|
|
331
|
-
SidebarLayoutComponent,
|
|
332
|
-
SidebarMenuButtonDirective,
|
|
333
|
-
SidebarMenuDirective,
|
|
334
|
-
SidebarMenuItemDirective,
|
|
335
|
-
SidebarTriggerDirective
|
|
336
|
-
],
|
|
337
|
-
templateUrl: "./two-sidebars-example.component.html"
|
|
338
|
-
})
|
|
339
|
-
export class SidebarTwoSidebarsExampleComponent {
|
|
340
|
-
protected readonly detailsOpen = signal(false);
|
|
341
|
-
protected readonly navOpen = signal(true);
|
|
342
|
-
protected readonly projects = ["Website redesign", "Mobile app", "Billing"];
|
|
343
|
-
}
|
|
344
|
-
```
|
|
345
|
-
|
|
346
|
-
`two-sidebars-example.component.html`
|
|
347
|
-
|
|
348
|
-
```html
|
|
349
|
-
<mona-sidebar-layout class="h-72 border border-border" modalScope="layout">
|
|
350
|
-
<mona-sidebar id="example-nav" side="start" width="12rem" [(expanded)]="navOpen">
|
|
351
|
-
<nav monaSidebarContent aria-label="Projects">
|
|
352
|
-
<ul monaSidebarMenu>
|
|
353
|
-
@for (project of projects; track project) {
|
|
354
|
-
<li monaSidebarMenuItem [active]="project === projects[0]">
|
|
355
|
-
<a monaSidebarMenuButton href="/projects" (click)="$event.preventDefault()">{{ project }}</a>
|
|
356
|
-
</li>
|
|
357
|
-
}
|
|
358
|
-
</ul>
|
|
359
|
-
</nav>
|
|
360
|
-
</mona-sidebar>
|
|
361
|
-
|
|
362
|
-
<div class="gap-2 p-4" monaSidebarInset>
|
|
363
|
-
<div class="flex gap-2">
|
|
364
|
-
<button monaButton monaSidebarTrigger for="example-nav" type="button">Projects</button>
|
|
365
|
-
<button monaButton monaSidebarTrigger for="example-details" type="button">Details</button>
|
|
366
|
-
</div>
|
|
367
|
-
<p class="text-sm">Projects open: {{ navOpen() }}, details open: {{ detailsOpen() }}</p>
|
|
368
|
-
</div>
|
|
369
|
-
|
|
370
|
-
<mona-sidebar id="example-details" aria-label="Details" side="end" width="12rem" [(expanded)]="detailsOpen">
|
|
371
|
-
<div class="space-y-1 p-3 text-sm" monaSidebarContent>
|
|
372
|
-
<p class="font-semibold">Website redesign</p>
|
|
373
|
-
<p>Owner: Grace Hopper</p>
|
|
374
|
-
<p>Due: 14 March</p>
|
|
375
|
-
</div>
|
|
376
|
-
</mona-sidebar>
|
|
377
|
-
</mona-sidebar-layout>
|
|
378
|
-
```
|
|
379
|
-
|
|
380
189
|
## Theming
|
|
381
190
|
|
|
382
191
|
The sidebar draws from its own colour roles, so it can sit apart from the page content without restyling every part: `--color-sidebar`, `--color-sidebar-foreground`, `--color-sidebar-primary`, `--color-sidebar-primary-foreground`, `--color-sidebar-accent`, `--color-sidebar-accent-foreground`, `--color-sidebar-border` and `--color-sidebar-ring`.
|
|
@@ -391,148 +200,11 @@ Every built-in theme defines them for each of its variants. A custom theme can b
|
|
|
391
200
|
| `floating` | Detached on its own rounded, shadowed surface |
|
|
392
201
|
| `inset` | Transparent; the raised surface moves onto the inset region instead |
|
|
393
202
|
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
## Behavior
|
|
397
|
-
|
|
398
|
-
### Controlled state
|
|
399
|
-
|
|
400
|
-
`expanded` is a two-way model on `mona-sidebar`. On a compact viewport it reflects the drawer, so one binding drives both presentations:
|
|
401
|
-
|
|
402
|
-
```html
|
|
403
|
-
<mona-sidebar-layout>
|
|
404
|
-
<mona-sidebar [(expanded)]="sidebarOpen">…</mona-sidebar>
|
|
405
|
-
</mona-sidebar-layout>
|
|
406
|
-
```
|
|
407
|
-
|
|
408
|
-
### More than one sidebar
|
|
409
|
-
|
|
410
|
-
A layout can hold more than one sidebar — a navigation column on one edge and an inspector on the other. Each keeps its own state on its own binding, and each needs an `id` so a trigger can name it, as in the [Two sidebars](#two-sidebars) example.
|
|
411
|
-
|
|
412
|
-
A trigger with no `for` drives the sidebar it is written inside, falling back to the first sidebar in the layout — which is all a layout with a single sidebar ever needs. A `for` naming no sidebar leaves the trigger inert rather than throwing.
|
|
413
|
-
|
|
414
|
-
On a compact viewport only one drawer is open at a time: opening one closes the other, and they share the single backdrop the layout paints behind them. When one drawer opens another, closing it sends focus back to whatever opened the first. The inset steps out of the way for whichever drawer is open, and takes its surface from the first sidebar in author order.
|
|
415
|
-
|
|
416
|
-
### Remembering the state across reloads
|
|
417
|
-
|
|
418
|
-
Set `persistKey` and the sidebar comes back the way it was left:
|
|
419
|
-
|
|
420
|
-
```html
|
|
421
|
-
<mona-sidebar persistKey="nav">…</mona-sidebar>
|
|
422
|
-
```
|
|
423
|
-
|
|
424
|
-
Nothing is stored without a key — the sidebar never writes to storage on its own. Give each sidebar in a layout its own key.
|
|
425
|
-
|
|
426
|
-
Only the docked state is kept. A drawer is never restored open, because on the viewport that makes one it would cover the page on load, and opening a drawer never overwrites the state the desktop comes back to. A stored value wins over `expanded` and is pushed back out through that binding, so do not set a key on a sidebar whose state is already restored elsewhere.
|
|
427
|
-
|
|
428
|
-
#### Where it is kept
|
|
429
|
-
|
|
430
|
-
The default is `localStorage`, under exactly the key given, with no prefix, so pick one nothing else in the application writes to. Storage that is unavailable — a server, private browsing, a full quota — is not an error: the sidebar just opens the way its `expanded` input says.
|
|
431
|
-
|
|
432
|
-
**A server-rendered application will flash.** `localStorage` cannot be read on the server, so the markup is rendered with the default state and corrected on hydration. To avoid it, supply storage the server can read too — a cookie, or state transferred from the request:
|
|
433
|
-
|
|
434
|
-
```typescript
|
|
435
|
-
import { provideSidebarStorage, type SidebarStorage } from "@nanahoshi/mona-ui/sidebar";
|
|
436
|
-
|
|
437
|
-
const cookieStorage: SidebarStorage = {
|
|
438
|
-
read: key => { … }, // null when nothing is stored
|
|
439
|
-
write: (key, expanded) => { … }
|
|
440
|
-
};
|
|
441
|
-
|
|
442
|
-
bootstrapApplication(AppComponent, {
|
|
443
|
-
providers: [provideSidebarStorage(cookieStorage)]
|
|
444
|
-
});
|
|
445
|
-
```
|
|
446
|
-
|
|
447
|
-
`read` returns `null` when it has nothing for that key, which leaves the sidebar on its input's state. A storage that throws is reported in development and otherwise treated the same way.
|
|
448
|
-
|
|
449
|
-
`provideSidebarStorage()` also takes a factory, which runs in an injection context, for storage that needs something from the current request:
|
|
450
|
-
|
|
451
|
-
```typescript
|
|
452
|
-
provideSidebarStorage(() => new CookieStorage(inject(REQUEST)))
|
|
453
|
-
```
|
|
454
|
-
|
|
455
|
-
A value the default storage doesn't recognize, such as another feature's entry under the same key, counts as nothing stored, and stays there until the sidebar's state changes. Nothing is written until then. Storage isn't watched, so tabs don't follow each other.
|
|
456
|
-
|
|
457
|
-
### Reading the sidebar from a descendant
|
|
458
|
-
|
|
459
|
-
`injectSidebar()` returns the sidebar's state and the commands that are safe to issue from anywhere:
|
|
460
|
-
|
|
461
|
-
```typescript
|
|
462
|
-
import { injectSidebar } from "@nanahoshi/mona-ui/sidebar";
|
|
463
|
-
|
|
464
|
-
@Component({ … })
|
|
465
|
-
export class WorkspaceSwitcherComponent {
|
|
466
|
-
protected readonly sidebar = injectSidebar();
|
|
467
|
-
|
|
468
|
-
protected onSelect(): void {
|
|
469
|
-
if (this.sidebar.compact()) {
|
|
470
|
-
this.sidebar.collapse();
|
|
471
|
-
}
|
|
472
|
-
}
|
|
473
|
-
}
|
|
474
|
-
```
|
|
475
|
-
|
|
476
|
-
The controller exposes `expanded`, `state`, `iconOnly`, `compact`, `mobileOpen`, `side`, `variant`, `collapsible` and `sidebarId` as signals, plus `expand()`, `collapse()` and `toggle()`. The [API](#api) section describes each one.
|
|
477
|
-
|
|
478
|
-
Structural facts are readable but not settable. `side`, `variant` and `collapsible` are authored as inputs on `mona-sidebar`; writing them from a descendant would leave the component and the shared state disagreeing until the next change detection pass. Bind the inputs instead.
|
|
479
|
-
|
|
480
|
-
Inside a `mona-sidebar` it reads that sidebar. Elsewhere in a `mona-sidebar-layout`, such as a toolbar in the inset, it reads the layout's first sidebar in author order, or the one you name with `injectSidebar({ for: "inspector" })`. A sidebar that hasn't rendered yet reads as closed, and commands to it do nothing.
|
|
481
|
-
|
|
482
|
-
Pass `{ optional: true }` for a component that may be used outside a layout.
|
|
483
|
-
|
|
484
|
-
### Collapsible modes
|
|
485
|
-
|
|
486
|
-
| Mode | Collapsed behaviour |
|
|
487
|
-
| --- | --- |
|
|
488
|
-
| `offcanvas` (default) | Panel shrinks to nothing and is made `inert`, so nothing inside stays focusable |
|
|
489
|
-
| `icon` | Panel narrows to `iconWidth`; labels, badges, trailing actions and submenus stand aside |
|
|
490
|
-
| `none` | Collapsing is disabled; the panel stays at full width. Below `mobileBreakpoint` it's still a drawer that opens and closes |
|
|
491
|
-
|
|
492
|
-
If focus is on something that collapsing takes away, it moves to a trigger for that sidebar, or to its rail when there's no trigger, rather than falling to the page.
|
|
493
|
-
|
|
494
|
-
### Submenus
|
|
495
|
-
|
|
496
|
-
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.
|
|
497
|
-
|
|
498
|
-
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.
|
|
499
|
-
|
|
500
|
-
#### On the icon rail
|
|
501
|
-
|
|
502
|
-
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.
|
|
503
|
-
|
|
504
|
-
### Responsive behaviour
|
|
203
|
+
### Width
|
|
505
204
|
|
|
506
|
-
|
|
205
|
+
`width`, `iconWidth` and `mobileWidth` are the width the sidebar's *contents* receive, and take a CSS length or a number of pixels. The variant's border is added on top, so a `3rem` icon rail always leaves exactly one `2rem` icon square whatever border the variant draws. The `sidebar` variant has no border as a drawer, so `mobileWidth` is its whole width.
|
|
507
206
|
|
|
508
|
-
|
|
509
|
-
- It's a `dialog` named by `aria-label` or `aria-labelledby`, with a localized default
|
|
510
|
-
- Focus is trapped inside it, on the panel itself if it has no controls. On close, however it closed, focus returns to whatever opened it, unless it has already moved somewhere else
|
|
511
|
-
- Escape and backdrop clicks close it, wherever focus is. A docked sidebar ignores Escape. A control that calls `preventDefault()` on the key keeps it, and so does a popup opened from the drawer. In nested layouts, it closes only the inner drawer
|
|
512
|
-
- Drawer state is separate from the desktop state and resets whenever the viewport crosses the breakpoint
|
|
513
|
-
- Activating a row closes the drawer, since the destination is underneath it — opt out with `[closeOnSelect]="false"`. A row that opens a submenu leaves it open without that binding
|
|
514
|
-
|
|
515
|
-
While the viewport is compact, `[(expanded)]` reports the drawer, so it reads `false` on a phone from the start. To remember the docked state, use `persistKey` rather than saving that value.
|
|
516
|
-
|
|
517
|
-
Set `mobileBreakpoint` to `0` to keep the docked presentation at every size.
|
|
518
|
-
|
|
519
|
-
```html
|
|
520
|
-
<mona-sidebar-layout [mobileBreakpoint]="1024">
|
|
521
|
-
<mona-sidebar mobileWidth="20rem">…</mona-sidebar>
|
|
522
|
-
</mona-sidebar-layout>
|
|
523
|
-
```
|
|
524
|
-
|
|
525
|
-
#### How far the drawer's modality reaches
|
|
526
|
-
|
|
527
|
-
By default an open drawer makes the whole page inert and locks its scroll, so an app header above the layout can't be reached behind it. Popups opened from the drawer, such as a menu or a tooltip, stay usable. The lock only acts when the page itself scrolls: in an app whose root doesn't, there's nothing for it to lock. The inset stops scrolling behind the drawer either way.
|
|
528
|
-
|
|
529
|
-
A sidebar embedded in part of a page can keep this to its layout, with `modalScope`. Anything beside the layout that has to stay usable while a drawer is open, such as a toolbar or a Close button, needs this too. What's around the layout stays usable and the page keeps scrolling, so the drawer isn't `aria-modal` then:
|
|
530
|
-
|
|
531
|
-
```html
|
|
532
|
-
<mona-sidebar-layout modalScope="layout">…</mona-sidebar-layout>
|
|
533
|
-
```
|
|
534
|
-
|
|
535
|
-
The backdrop covers the layout either way, and never more than that.
|
|
207
|
+
## Behavior
|
|
536
208
|
|
|
537
209
|
### Direction
|
|
538
210
|
|
|
@@ -540,23 +212,9 @@ Prefer `side="start"` and `side="end"`, which follow the document's writing dire
|
|
|
540
212
|
|
|
541
213
|
The panel's border, the drawer's edge and the rail don't use logical properties. Each resolves to a physical left or right from the direction, so they follow it too. To override that border through `class`, name the physical side, such as `border-r-0`. `tailwind-merge` treats `border-e-0` as a different class, so it doesn't replace the border.
|
|
542
214
|
|
|
543
|
-
### Server rendering
|
|
544
|
-
|
|
545
|
-
Supply a stable `id` on `mona-sidebar` so the client does not hydrate onto a different generated id:
|
|
546
|
-
|
|
547
|
-
```html
|
|
548
|
-
<mona-sidebar id="app-sidebar">…</mona-sidebar>
|
|
549
|
-
```
|
|
550
|
-
|
|
551
|
-
Where `matchMedia` is unavailable — a server render, a test environment — the sidebar keeps its docked presentation, which is the one that degrades gracefully.
|
|
552
|
-
|
|
553
|
-
`persistKey` needs storage the server can read, or the remembered state arrives a frame late. See [Where it is kept](#where-it-is-kept).
|
|
554
|
-
|
|
555
|
-
- Call it in an injection context. It throws when there's no sidebar or layout around the caller, unless `optional` is set.
|
|
556
|
-
|
|
557
215
|
## Accessibility
|
|
558
216
|
|
|
559
|
-
These are requirements, not suggestions. The component supplies what it can and relies on you for the rest.
|
|
217
|
+
These are requirements, not suggestions. The component supplies what it can and relies on you for the rest. Rows have rules of their own, on [Sidebar Menus](sidebar-menus.md#accessibility).
|
|
560
218
|
|
|
561
219
|
### Provide a landmark
|
|
562
220
|
|
|
@@ -596,28 +254,6 @@ A `button` host needs nothing further. On any other element, including an `a` wi
|
|
|
596
254
|
|
|
597
255
|
On a sidebar that can't collapse (`collapsible="none"`) a trigger has nothing to do on a wide viewport, so it reports `aria-disabled` there rather than an open disclosure. A `for` that finds no sidebar leaves the trigger inert and warns in development. `for` only reaches sidebars in the trigger's own layout.
|
|
598
256
|
|
|
599
|
-
### Use anchors for destinations
|
|
600
|
-
|
|
601
|
-
`monaSidebarMenuButton` applies to both `a` and `button`. Use an anchor for anything that navigates:
|
|
602
|
-
|
|
603
|
-
```html
|
|
604
|
-
<a monaSidebarMenuButton routerLink="/billing" tooltip="Billing">…</a>
|
|
605
|
-
```
|
|
606
|
-
|
|
607
|
-
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.
|
|
608
|
-
|
|
609
|
-
Mark the current destination on the **item**, which owns the row's highlight. The row's control picks up `aria-current="page"` from it:
|
|
610
|
-
|
|
611
|
-
```html
|
|
612
|
-
<li monaSidebarMenuItem [active]="isCurrent()">…</li>
|
|
613
|
-
```
|
|
614
|
-
|
|
615
|
-
### Label the icon rail
|
|
616
|
-
|
|
617
|
-
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.
|
|
618
|
-
|
|
619
|
-
`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.
|
|
620
|
-
|
|
621
257
|
## API
|
|
622
258
|
|
|
623
259
|
Everything below is imported from `@nanahoshi/mona-ui/sidebar`.
|
|
@@ -680,54 +316,6 @@ closes any other, and they share the single backdrop this layout paints behind t
|
|
|
680
316
|
| `mobileBreakpoint` | `number` | `768` | Viewport width, in pixels, below which the sidebar presents as an overlay drawer. Set to `0` to keep the docked presentation at every size. |
|
|
681
317
|
| `modalScope` | `SidebarModalScope` | `"page"` | How far an open drawer's modality reaches. `"page"` makes everything outside the drawer inert and locks the page's scroll. Use `"layout"` for a sidebar embedded in part of a page: what's around the layout stays usable, so the drawer isn't `aria-modal`. |
|
|
682
318
|
|
|
683
|
-
### `SidebarMenuSkeletonComponent`
|
|
684
|
-
|
|
685
|
-
A loading placeholder shaped like a menu item. Its label bar is clipped on the icon rail, where the
|
|
686
|
-
real labels are not visible either.
|
|
687
|
-
|
|
688
|
-
**Selector:** `mona-sidebar-menu-skeleton`
|
|
689
|
-
|
|
690
|
-
#### Inputs
|
|
691
|
-
|
|
692
|
-
| Name | Type | Default | Description |
|
|
693
|
-
| --- | --- | --- | --- |
|
|
694
|
-
| `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. |
|
|
695
|
-
| `showIcon` | `boolean` | `true` | Renders a square standing in for the item's icon. |
|
|
696
|
-
|
|
697
|
-
### `SidebarMenuButtonDirective`
|
|
698
|
-
|
|
699
|
-
A row in a sidebar menu. Applies to a `button` for an action and to an `a` for a destination —
|
|
700
|
-
an anchor keeps `href`, `routerLink`, middle-click, open-in-new-tab and the browser's own status
|
|
701
|
-
bar preview, none of which a button can offer.
|
|
702
|
-
|
|
703
|
-
On a compact viewport, following a link closes the drawer, since the destination it navigates to is
|
|
704
|
-
underneath it. A row that opens a submenu leaves the drawer open, and on the icon rail it expands the
|
|
705
|
-
sidebar, since that's the only place the submenu can open.
|
|
706
|
-
|
|
707
|
-
**Selector:** `a[monaSidebarMenuButton], button[monaSidebarMenuButton]`
|
|
708
|
-
**Exported as:** `monaSidebarMenuButton`
|
|
709
|
-
|
|
710
|
-
#### Inputs
|
|
711
|
-
|
|
712
|
-
| Name | Type | Default | Description |
|
|
713
|
-
| --- | --- | --- | --- |
|
|
714
|
-
| `class` | `ClassInputType` | `""` | Additional CSS classes merged onto the host element via `tailwind-merge`. |
|
|
715
|
-
| `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. |
|
|
716
|
-
| `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`. |
|
|
717
|
-
| `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. |
|
|
718
|
-
| `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. |
|
|
719
|
-
|
|
720
|
-
### `SidebarMenuItemDirective`
|
|
721
|
-
|
|
722
|
-
**Selector:** `li[monaSidebarMenuItem]`
|
|
723
|
-
|
|
724
|
-
#### Inputs
|
|
725
|
-
|
|
726
|
-
| Name | Type | Default | Description |
|
|
727
|
-
| --- | --- | --- | --- |
|
|
728
|
-
| `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. |
|
|
729
|
-
| `class` | `ClassInputType` | `""` | Additional CSS classes merged onto the host element via `tailwind-merge`. |
|
|
730
|
-
|
|
731
319
|
### `SidebarFooterDirective`
|
|
732
320
|
|
|
733
321
|
The region at the bottom of the sidebar, below its content. Holds what stays put while the content
|
|
@@ -771,46 +359,6 @@ its surface from the first one in author order.
|
|
|
771
359
|
| --- | --- | --- | --- |
|
|
772
360
|
| `class` | `ClassInputType` | `""` | Additional CSS classes merged onto the host element via `tailwind-merge`. |
|
|
773
361
|
|
|
774
|
-
### `SidebarMenuBadgeDirective`
|
|
775
|
-
|
|
776
|
-
A trailing count or status badge on a menu item. Stands down on the icon rail, where it would
|
|
777
|
-
crowd out the icon it belongs to.
|
|
778
|
-
|
|
779
|
-
**Selector:** `[monaSidebarMenuBadge]`
|
|
780
|
-
|
|
781
|
-
#### Inputs
|
|
782
|
-
|
|
783
|
-
| Name | Type | Default | Description |
|
|
784
|
-
| --- | --- | --- | --- |
|
|
785
|
-
| `class` | `ClassInputType` | `""` | Additional CSS classes merged onto the host element via `tailwind-merge`. |
|
|
786
|
-
|
|
787
|
-
### `SidebarMenuDirective`
|
|
788
|
-
|
|
789
|
-
**Selector:** `ul[monaSidebarMenu]`
|
|
790
|
-
|
|
791
|
-
#### Inputs
|
|
792
|
-
|
|
793
|
-
| Name | Type | Default | Description |
|
|
794
|
-
| --- | --- | --- | --- |
|
|
795
|
-
| `class` | `ClassInputType` | `""` | Additional CSS classes merged onto the host element via `tailwind-merge`. |
|
|
796
|
-
|
|
797
|
-
### `SidebarMenuSubDirective`
|
|
798
|
-
|
|
799
|
-
An indented submenu inside a `monaSidebarMenuItem` that is also a `monaCollapsible`.
|
|
800
|
-
|
|
801
|
-
It carries no hiding of its own on the icon rail. `SidebarMenuItemDirective` closes the disclosure
|
|
802
|
-
there instead, which leaves the trigger's `aria-expanded` truthful and lets the collapsible content
|
|
803
|
-
directive apply its own `inert`. Hiding it here as well used to produce the opposite: a submenu the
|
|
804
|
-
trigger still described as expanded, with focusable items, that nobody could see.
|
|
805
|
-
|
|
806
|
-
**Selector:** `ul[monaSidebarMenuSub]`
|
|
807
|
-
|
|
808
|
-
#### Inputs
|
|
809
|
-
|
|
810
|
-
| Name | Type | Default | Description |
|
|
811
|
-
| --- | --- | --- | --- |
|
|
812
|
-
| `class` | `ClassInputType` | `""` | Additional CSS classes merged onto the host element via `tailwind-merge`. |
|
|
813
|
-
|
|
814
362
|
### `SidebarRailDirective`
|
|
815
363
|
|
|
816
364
|
A thin strip along the sidebar's inner edge that toggles it. Place it inside `mona-sidebar`,
|
|
@@ -870,103 +418,6 @@ reports itself as disabled there rather than as an open disclosure.
|
|
|
870
418
|
|
|
871
419
|
**Selector:** `[monaSidebarContent]`
|
|
872
420
|
|
|
873
|
-
### `SidebarGroupActionDirective`
|
|
874
|
-
|
|
875
|
-
A control in the corner of a group header — an add or overflow button. Stands down on the icon
|
|
876
|
-
rail, where there is no header row left to sit in. Give it an `aria-label`: it is icon-only.
|
|
877
|
-
|
|
878
|
-
**Selector:** `button[monaSidebarGroupAction]`
|
|
879
|
-
|
|
880
|
-
### `SidebarGroupContentDirective`
|
|
881
|
-
|
|
882
|
-
The body of a `monaSidebarGroup`, below its header. Wraps the menu itself.
|
|
883
|
-
|
|
884
|
-
**Selector:** `[monaSidebarGroupContent]`
|
|
885
|
-
|
|
886
|
-
### `SidebarGroupDirective`
|
|
887
|
-
|
|
888
|
-
A titled section of the sidebar, grouping a label and its menu. Stack as many as the sidebar
|
|
889
|
-
needs; each is an ordinary block, so a `monaSidebarSeparator` between them is optional. A
|
|
890
|
-
`monaSidebarGroupLabel` inside it names the group.
|
|
891
|
-
|
|
892
|
-
**Selector:** `[monaSidebarGroup]`
|
|
893
|
-
|
|
894
|
-
### `SidebarGroupHeaderDirective`
|
|
895
|
-
|
|
896
|
-
The row above a group's content, holding its label and any group action. Collapses to nothing on
|
|
897
|
-
the icon rail rather than leaving an empty gap where the label used to be.
|
|
898
|
-
|
|
899
|
-
**Selector:** `[monaSidebarGroupHeader]`
|
|
900
|
-
|
|
901
|
-
### `SidebarGroupLabelDirective`
|
|
902
|
-
|
|
903
|
-
The name of a group, which the enclosing `monaSidebarGroup` is labelled by. Fades out on the icon
|
|
904
|
-
rail, where there is no width to read it in.
|
|
905
|
-
|
|
906
|
-
**Selector:** `[monaSidebarGroupLabel]`
|
|
907
|
-
|
|
908
|
-
### `SidebarInputDirective`
|
|
909
|
-
|
|
910
|
-
A text input sized for the sidebar, composing `monaTextBox`. Stands down on the icon rail,
|
|
911
|
-
where there is no room to type.
|
|
912
|
-
|
|
913
|
-
**Selector:** `input[monaSidebarInput]`
|
|
914
|
-
|
|
915
|
-
### `SidebarMenuActionDirective`
|
|
916
|
-
|
|
917
|
-
A trailing control on a menu item — an overflow menu, a pin. Sits inside the row's highlight and
|
|
918
|
-
stands down on the icon rail. Give it an `aria-label`: it is icon-only.
|
|
919
|
-
|
|
920
|
-
**Selector:** `button[monaSidebarMenuAction]`
|
|
921
|
-
|
|
922
|
-
### `LocalStorageSidebarStorage`
|
|
923
|
-
|
|
924
|
-
The default `SidebarStorage`: `localStorage`, under the sidebar's `persistKey`.
|
|
925
|
-
|
|
926
|
-
Reads report `null` anywhere `localStorage` cannot answer, and writes are dropped there. That
|
|
927
|
-
covers the server, where there is no such thing, and a browser that refuses it — Safari's private
|
|
928
|
-
mode throws on access rather than returning empty, and a full quota throws on write. None of that
|
|
929
|
-
is worth taking an application down over: the sidebar simply opens the way its input says.
|
|
930
|
-
|
|
931
|
-
A server-rendered application gets the default state in its markup and the remembered one on
|
|
932
|
-
hydration, which shows as a flash. Storage that the server can read too — a cookie, or state
|
|
933
|
-
transferred from the request — avoids it; supply it through `provideSidebarStorage()`.
|
|
934
|
-
|
|
935
|
-
#### Methods
|
|
936
|
-
|
|
937
|
-
| Signature |
|
|
938
|
-
| --- |
|
|
939
|
-
| `read(key: string): boolean \| null` |
|
|
940
|
-
| `write(key: string, expanded: boolean): void` |
|
|
941
|
-
|
|
942
|
-
### `injectSidebar`
|
|
943
|
-
|
|
944
|
-
Reads a sidebar from an injection context: the one that encloses the caller, or from elsewhere in a
|
|
945
|
-
`mona-sidebar-layout`, such as a toolbar in the inset, the layout's first sidebar. Name another one with `for`.
|
|
946
|
-
|
|
947
|
-
Returns the sidebar's state and the commands that are safe to issue from anywhere — opening,
|
|
948
|
-
closing and toggling, each routed to whichever presentation is current. Structural facts such as
|
|
949
|
-
the side, variant and collapsible mode are readable but not settable; those are authored as inputs
|
|
950
|
-
on `mona-sidebar`, and writing them from a descendant would only desynchronise the two.
|
|
951
|
-
|
|
952
|
-
In a layout it follows the sidebar rather than holding it, because the caller may be created first. Until there is
|
|
953
|
-
one, it reads as closed and its commands do nothing.
|
|
954
|
-
|
|
955
|
-
```typescript
|
|
956
|
-
function injectSidebar(options: InjectSidebarOptions & { optional: true }): SidebarController | null;
|
|
957
|
-
function injectSidebar(options?: InjectSidebarOptions): SidebarController;
|
|
958
|
-
```
|
|
959
|
-
|
|
960
|
-
### `provideSidebarStorage`
|
|
961
|
-
|
|
962
|
-
Replaces where sidebars remember whether they were left open. The default is `localStorage`, which
|
|
963
|
-
the server cannot read; supply a cookie- or request-backed storage here to have a server-rendered
|
|
964
|
-
application render the remembered state rather than correcting it on hydration.
|
|
965
|
-
|
|
966
|
-
```typescript
|
|
967
|
-
function provideSidebarStorage(storage: SidebarStorage | (() => SidebarStorage)): EnvironmentProviders;
|
|
968
|
-
```
|
|
969
|
-
|
|
970
421
|
### Types
|
|
971
422
|
|
|
972
423
|
#### `SIDEBAR_DEFAULT_MESSAGES`
|
|
@@ -975,80 +426,6 @@ function provideSidebarStorage(storage: SidebarStorage | (() => SidebarStorage))
|
|
|
975
426
|
const SIDEBAR_DEFAULT_MESSAGES: MonaSidebarMessages;
|
|
976
427
|
```
|
|
977
428
|
|
|
978
|
-
#### `SIDEBAR_STORAGE`
|
|
979
|
-
|
|
980
|
-
Where sidebars given a `persistKey` remember whether they were left open. Defaults to
|
|
981
|
-
`localStorage`. Replace it with `provideSidebarStorage()` — with something the server can read too,
|
|
982
|
-
for an application that renders there.
|
|
983
|
-
|
|
984
|
-
```typescript
|
|
985
|
-
const SIDEBAR_STORAGE: InjectionToken<SidebarStorage>;
|
|
986
|
-
```
|
|
987
|
-
|
|
988
|
-
#### `SidebarController`
|
|
989
|
-
|
|
990
|
-
The safe, read-and-command view of one sidebar, returned by `injectSidebar()`.
|
|
991
|
-
|
|
992
|
-
Structural facts — side, variant, collapsible mode — are readable but not settable. They are
|
|
993
|
-
authored as inputs on `mona-sidebar`, and letting a descendant write them would leave the service
|
|
994
|
-
and the component disagreeing about the same sidebar, with the component winning on the next
|
|
995
|
-
change detection pass. Consumers who need them to change should bind the inputs.
|
|
996
|
-
|
|
997
|
-
| Name | Type | Description |
|
|
998
|
-
| --- | --- | --- |
|
|
999
|
-
| `collapsible` (read-only) | `Signal<SidebarCollapsibleMode>` | How the sidebar behaves when collapsed, as authored on `mona-sidebar`. |
|
|
1000
|
-
| `compact` (read-only) | `Signal<boolean>` | Whether the viewport is narrow enough that the sidebar presents as an overlay drawer rather than as a column in the layout. |
|
|
1001
|
-
| `expanded` (read-only) | `Signal<boolean>` | Whether the sidebar is showing at full width. On a compact viewport this reports the drawer's state, so a single binding drives both presentations. |
|
|
1002
|
-
| `iconOnly` (read-only) | `Signal<boolean>` | Whether the sidebar is currently reduced to its icon rail, meaning parts that only make sense at full width — labels, trailing actions, submenus — should step aside. Never true while compact, where the drawer always presents at full width. |
|
|
1003
|
-
| `mobileOpen` (read-only) | `Signal<boolean>` | Whether the overlay drawer is open. Only meaningful while `compact` is true. |
|
|
1004
|
-
| `side` (read-only) | `Signal<SidebarLogicalSide>` | Which edge the sidebar sits on, resolved to a direction-relative side. |
|
|
1005
|
-
| `sidebarId` (read-only) | `Signal<string>` | The id of the sidebar element, for `aria-controls` on a custom trigger. |
|
|
1006
|
-
| `state` (read-only) | `Signal<"expanded" \| "collapsed">` | The expanded state as a string, for `data-state` bindings and styling hooks. |
|
|
1007
|
-
| `variant` (read-only) | `Signal<SidebarVariant>` | The visual treatment of the sidebar, as authored on `mona-sidebar`. |
|
|
1008
|
-
|
|
1009
|
-
**Methods**
|
|
1010
|
-
|
|
1011
|
-
| Signature | Description |
|
|
1012
|
-
| --- | --- |
|
|
1013
|
-
| `collapse(): void` | Closes the sidebar. On a compact viewport this closes the drawer instead. |
|
|
1014
|
-
| `expand(): void` | Opens the sidebar. On a compact viewport this opens the drawer instead. |
|
|
1015
|
-
| `toggle(): void` | Flips the sidebar between open and closed, on whichever presentation is current. |
|
|
1016
|
-
|
|
1017
|
-
#### `SidebarStorage`
|
|
1018
|
-
|
|
1019
|
-
Where a sidebar remembers whether it was left open. Supplied through `SIDEBAR_STORAGE`, and only
|
|
1020
|
-
ever consulted for a sidebar that was given a `persistKey`.
|
|
1021
|
-
|
|
1022
|
-
Only the docked state is ever handed to it. A drawer on a compact viewport is deliberately never
|
|
1023
|
-
persisted: restoring one open would cover the page on load, in front of the content the reader
|
|
1024
|
-
asked for.
|
|
1025
|
-
|
|
1026
|
-
**Methods**
|
|
1027
|
-
|
|
1028
|
-
| Signature | Description |
|
|
1029
|
-
| --- | --- |
|
|
1030
|
-
| `read(key: string): boolean \| null` | The remembered state for `key`, or `null` when nothing has been stored under it — including when this storage cannot answer, such as on the server. A `null` leaves the sidebar on whatever its `expanded` input says. |
|
|
1031
|
-
| `write(key: string, expanded: boolean): void` | Records the docked state for `key`. Failing to store it must not throw. |
|
|
1032
|
-
|
|
1033
|
-
#### `InjectSidebarOptions`
|
|
1034
|
-
|
|
1035
|
-
| Name | Type | Description |
|
|
1036
|
-
| --- | --- | --- |
|
|
1037
|
-
| `for?` (read-only) | `string` | Reads the sidebar with this id in the enclosing layout, rather than the nearest one. Needs a layout. |
|
|
1038
|
-
| `optional?` (read-only) | `boolean` | Returns `null` instead of throwing when there is no enclosing sidebar or layout. |
|
|
1039
|
-
|
|
1040
|
-
#### `SidebarCollapsibleMode`
|
|
1041
|
-
|
|
1042
|
-
How the sidebar behaves when it is collapsed.
|
|
1043
|
-
|
|
1044
|
-
- `offcanvas` — the sidebar collapses to zero width and leaves the layout.
|
|
1045
|
-
- `icon` — the sidebar shrinks to a narrow rail that keeps icons visible.
|
|
1046
|
-
- `none` — the sidebar cannot be collapsed and stays at its full width.
|
|
1047
|
-
|
|
1048
|
-
```typescript
|
|
1049
|
-
type SidebarCollapsibleMode = "offcanvas" | "icon" | "none";
|
|
1050
|
-
```
|
|
1051
|
-
|
|
1052
429
|
#### `SidebarLogicalSide`
|
|
1053
430
|
|
|
1054
431
|
The direction-relative side, once the `left`/`right` aliases have been folded in.
|
|
@@ -1057,29 +434,6 @@ The direction-relative side, once the `left`/`right` aliases have been folded in
|
|
|
1057
434
|
type SidebarLogicalSide = "start" | "end";
|
|
1058
435
|
```
|
|
1059
436
|
|
|
1060
|
-
#### `SidebarMenuButtonSize`
|
|
1061
|
-
|
|
1062
|
-
How much room the button's leading visual needs.
|
|
1063
|
-
|
|
1064
|
-
- `medium` — sized for an icon, which the icon rail insets so it sits centred in the square.
|
|
1065
|
-
- `large` — sized for a full-height visual such as an avatar, which fills the rail square edge to
|
|
1066
|
-
edge, and which is given a taller row while the sidebar is expanded.
|
|
1067
|
-
|
|
1068
|
-
```typescript
|
|
1069
|
-
type SidebarMenuButtonSize = "medium" | "large";
|
|
1070
|
-
```
|
|
1071
|
-
|
|
1072
|
-
#### `SidebarModalScope`
|
|
1073
|
-
|
|
1074
|
-
How far an open drawer's modality reaches.
|
|
1075
|
-
- `"page"` makes everything outside the drawer inert and locks the page's scroll, and the drawer is `aria-modal`.
|
|
1076
|
-
- `"layout"` does that within `mona-sidebar-layout` only, for a sidebar embedded in part of a page. What's around the
|
|
1077
|
-
layout stays usable, so the drawer isn't `aria-modal`.
|
|
1078
|
-
|
|
1079
|
-
```typescript
|
|
1080
|
-
type SidebarModalScope = "page" | "layout";
|
|
1081
|
-
```
|
|
1082
|
-
|
|
1083
437
|
#### `SidebarSide`
|
|
1084
438
|
|
|
1085
439
|
Which edge of the layout the sidebar sits on. Also determines its order within the layout
|
|
@@ -1124,3 +478,5 @@ From `@nanahoshi/mona-ui/i18n`.
|
|
|
1124
478
|
| --- | --- |
|
|
1125
479
|
| `drawerLabel` (read-only) | `string` |
|
|
1126
480
|
| `rail` (read-only) | `string` |
|
|
481
|
+
|
|
482
|
+
**Documented elsewhere:** [`SidebarCollapsibleMode`](sidebar-state.md), [`SidebarModalScope`](sidebar-state.md)
|