@redvars/peacock 4.2.1 → 4.3.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/dist/{BaseField-D8ByB0l3.js → BaseField-CHBcjVc2.js} +3 -3
- package/dist/{BaseField-D8ByB0l3.js.map → BaseField-CHBcjVc2.js.map} +1 -1
- package/dist/{BaseInput-xCHvT4AN.js → BaseInput-DZp2O8Gh.js} +2 -2
- package/dist/{BaseInput-xCHvT4AN.js.map → BaseInput-DZp2O8Gh.js.map} +1 -1
- package/dist/ai-badge.js +2 -2
- package/dist/ai-summary.js +2 -2
- package/dist/alert.js +2 -2
- package/dist/anchor-nav.js +2 -2
- package/dist/app-shell.js +2 -2
- package/dist/assistant-panel.js +2 -2
- package/dist/assistant-step.js +2 -2
- package/dist/assistant-steps.js +2 -2
- package/dist/avatar-group.js +2 -2
- package/dist/banner.js +2 -2
- package/dist/{base-progress-DxNgAQtw.js → base-progress-CKQ32Ruw.js} +2 -2
- package/dist/{base-progress-DxNgAQtw.js.map → base-progress-CKQ32Ruw.js.map} +1 -1
- package/dist/bottom-sheet.js +2 -2
- package/dist/breadcrumb.js +2 -2
- package/dist/calendar.js +2 -2
- package/dist/{canvas-base-DHKf2CmA.js → canvas-base-BoKef3yr.js} +2 -2
- package/dist/{canvas-base-DHKf2CmA.js.map → canvas-base-BoKef3yr.js.map} +1 -1
- package/dist/carousel.js +644 -0
- package/dist/carousel.js.map +1 -0
- package/dist/{cartesian-chart-G6VX1aKk.js → cartesian-chart-DqZxnoG1.js} +2 -2
- package/dist/{cartesian-chart-G6VX1aKk.js.map → cartesian-chart-DqZxnoG1.js.map} +1 -1
- package/dist/{cb-group-base-BBDUgxne.js → cb-group-base-DHwx72Gt.js} +3 -1
- package/dist/{cb-group-base-BBDUgxne.js.map → cb-group-base-DHwx72Gt.js.map} +1 -1
- package/dist/{cb-group-base-CZLzCnXK.js → cb-group-base-DXnAJxEK.js} +3 -3
- package/dist/{cb-group-base-CZLzCnXK.js.map → cb-group-base-DXnAJxEK.js.map} +1 -1
- package/dist/cb-group.js +7 -4
- package/dist/cb-group.js.map +1 -1
- package/dist/cb-rule.js +3 -3
- package/dist/chart-area.js +4 -4
- package/dist/chart-bar.js +4 -4
- package/dist/{chart-base-DREru2P0.js → chart-base-ByCJM_9C.js} +2 -2
- package/dist/{chart-base-DREru2P0.js.map → chart-base-ByCJM_9C.js.map} +1 -1
- package/dist/chart-doughnut.js +3 -3
- package/dist/chart-line.js +4 -4
- package/dist/chart-pie.js +3 -3
- package/dist/chat-event.js +2 -2
- package/dist/chat-message.js +2 -2
- package/dist/chat-thread.js +2 -2
- package/dist/checkbox-group.js +3 -3
- package/dist/checkbox.js +3 -3
- package/dist/chip-set.js +2 -2
- package/dist/chip.js +2 -2
- package/dist/circular-progress.js +3 -3
- package/dist/citation.js +2 -2
- package/dist/code-editor.js +3 -3
- package/dist/code-highlighter.js +2 -2
- package/dist/color-field.js +4 -4
- package/dist/color-picker.js +2 -2
- package/dist/command-palette.js +2 -2
- package/dist/comment-composer.js +4 -4
- package/dist/condition-builder.js +4 -4
- package/dist/confirm-dialog.js +2 -2
- package/dist/copy-button.js +2 -2
- package/dist/currency-field.js +4 -4
- package/dist/custom-elements-jsdocs.json +902 -74
- package/dist/custom-elements.json +3301 -446
- package/dist/date-field.js +5 -5
- package/dist/date-picker.js +2 -2
- package/dist/date-range-field.js +5 -5
- package/dist/datetime-field.js +5 -5
- package/dist/dependency-map.js +3 -3
- package/dist/description-item.js +2 -2
- package/dist/description-list.js +2 -2
- package/dist/{diagram-CHF70xTL.js → diagram-Cnrj-4y3.js} +2 -2
- package/dist/{diagram-CHF70xTL.js.map → diagram-Cnrj-4y3.js.map} +1 -1
- package/dist/diagram-controls.js +2 -2
- package/dist/diagram-minimap.js +2 -2
- package/dist/diagram.js +4 -4
- package/dist/diff-viewer.js +2 -2
- package/dist/discussion-activity.js +2 -2
- package/dist/discussion-comment.js +2 -2
- package/dist/discussion.js +4 -4
- package/dist/{document-editor-Cb9fCxvA.js → document-editor-C8ThjDQ7.js} +2 -2
- package/dist/{document-editor-Cb9fCxvA.js.map → document-editor-C8ThjDQ7.js.map} +1 -1
- package/dist/document-editor.js +3 -3
- package/dist/draft-card.js +2 -2
- package/dist/erd.js +3 -3
- package/dist/file-upload.js +3 -3
- package/dist/filter-bar.js +2 -2
- package/dist/flow.js +4 -4
- package/dist/form.js +2 -2
- package/dist/{generative-view-C4fJ2zI7.js → generative-view-CQ8-g1wY.js} +2 -2
- package/dist/{generative-view-C4fJ2zI7.js.map → generative-view-CQ8-g1wY.js.map} +1 -1
- package/dist/generative-view.js +3 -3
- package/dist/highlight-Be0wu7kh.js +252 -0
- package/dist/highlight-Be0wu7kh.js.map +1 -0
- package/dist/highlight.js +6 -0
- package/dist/highlight.js.map +1 -0
- package/dist/html-editor.js +4 -4
- package/dist/{i18n-controller-CH4e9sju.js → i18n-controller-DLJcJ5gO.js} +2 -2
- package/dist/{i18n-controller-CH4e9sju.js.map → i18n-controller-DLJcJ5gO.js.map} +1 -1
- package/dist/image.js +2 -2
- package/dist/index.js +27 -17
- package/dist/index.js.map +1 -1
- package/dist/inline-edit.js +2 -2
- package/dist/input.js +3 -3
- package/dist/json-viewer.js +2 -2
- package/dist/kanban.js +2 -2
- package/dist/kbd.js +2 -2
- package/dist/linear-progress.js +3 -3
- package/dist/listbox.js +2 -2
- package/dist/loader-full.js +19 -9
- package/dist/loader-full.js.map +1 -1
- package/dist/loader.js +46 -9
- package/dist/loader.js.map +1 -1
- package/dist/markdown-editor.js +4 -4
- package/dist/mention-input.js +4 -4
- package/dist/modal.js +2 -2
- package/dist/navigation-bar.js +2 -2
- package/dist/navigation-drawer.js +2 -2
- package/dist/navigation-rail.js +2 -2
- package/dist/notification-center.js +2 -2
- package/dist/number-field.js +4 -4
- package/dist/page-header.js +2 -2
- package/dist/pagination.js +2 -2
- package/dist/password-field.js +4 -4
- package/dist/password-rules.js +2 -2
- package/dist/phone-field.js +4 -4
- package/dist/{picker-field-loXW-xrW.js → picker-field-B5xOFc3-.js} +3 -3
- package/dist/{picker-field-loXW-xrW.js.map → picker-field-B5xOFc3-.js.map} +1 -1
- package/dist/pin-input.js +4 -4
- package/dist/presence-indicator.js +2 -2
- package/dist/prompt-input.js +4 -4
- package/dist/radio.js +3 -3
- package/dist/rating.js +3 -3
- package/dist/redvars-loader.js +2 -2
- package/dist/relative-time.js +2 -2
- package/dist/resizable-panels.js +2 -2
- package/dist/{rich-text-input-B5j0eqCJ.js → rich-text-input-C4B9D6oD.js} +3 -3
- package/dist/{rich-text-input-B5j0eqCJ.js.map → rich-text-input-C4B9D6oD.js.map} +1 -1
- package/dist/{schema-BJzlGRP1.js → schema-CPhNrjrx.js} +2 -2
- package/dist/{schema-BJzlGRP1.js.map → schema-CPhNrjrx.js.map} +1 -1
- package/dist/search.js +3 -3
- package/dist/select.js +4 -4
- package/dist/side-sheet.js +2 -2
- package/dist/signature-pad.js +3 -3
- package/dist/site-footer-group.js +142 -0
- package/dist/site-footer-group.js.map +1 -0
- package/dist/site-footer.js +338 -0
- package/dist/site-footer.js.map +1 -0
- package/dist/site-header.js +774 -0
- package/dist/site-header.js.map +1 -0
- package/dist/site-nav-group.js +123 -0
- package/dist/site-nav-group.js.map +1 -0
- package/dist/site-nav-link.js +321 -0
- package/dist/site-nav-link.js.map +1 -0
- package/dist/site-nav-menu.js +506 -0
- package/dist/site-nav-menu.js.map +1 -0
- package/dist/site-nav-shared-BDR2HG8e.js +23 -0
- package/dist/site-nav-shared-BDR2HG8e.js.map +1 -0
- package/dist/slider.js +3 -3
- package/dist/snackbar.js +2 -2
- package/dist/sparkline.js +2 -2
- package/dist/split-button.js +2 -2
- package/dist/src/__internal/i18n/strings.d.ts +24 -0
- package/dist/src/carousel/carousel.d.ts +135 -0
- package/dist/src/carousel/index.d.ts +1 -0
- package/dist/src/highlight/highlight.d.ts +56 -0
- package/dist/src/highlight/index.d.ts +2 -0
- package/dist/src/highlight/matches.d.ts +9 -0
- package/dist/src/index.d.ts +9 -0
- package/dist/src/site-footer/index.d.ts +2 -0
- package/dist/src/site-footer/site-footer-group.d.ts +34 -0
- package/dist/src/site-footer/site-footer.d.ts +74 -0
- package/dist/src/site-header/index.d.ts +4 -0
- package/dist/src/site-header/site-header.d.ts +170 -0
- package/dist/src/site-header/site-nav-group.d.ts +32 -0
- package/dist/src/site-header/site-nav-link.d.ts +65 -0
- package/dist/src/site-header/site-nav-menu.d.ts +104 -0
- package/dist/src/site-header/site-nav-shared.d.ts +13 -0
- package/dist/src/table/table.d.ts +5 -0
- package/dist/src/video/index.d.ts +2 -0
- package/dist/src/video/video-source.d.ts +12 -0
- package/dist/src/video/video.d.ts +80 -0
- package/dist/stat.js +2 -2
- package/dist/status-indicator.js +2 -2
- package/dist/step.js +2 -2
- package/dist/stepper.js +2 -2
- package/dist/{strings-o6v6Hrmn.js → strings-MXyrGrNs.js} +28 -1
- package/dist/strings-MXyrGrNs.js.map +1 -0
- package/dist/svg.js +2 -2
- package/dist/switch.js +3 -3
- package/dist/table.js +53 -10
- package/dist/table.js.map +1 -1
- package/dist/test/carousel.test.d.ts +1 -0
- package/dist/test/highlight.test.d.ts +1 -0
- package/dist/test/site-footer.test.d.ts +1 -0
- package/dist/test/site-header.test.d.ts +1 -0
- package/dist/test/video.test.d.ts +1 -0
- package/dist/textarea.js +4 -4
- package/dist/time-field.js +5 -5
- package/dist/time-picker.js +2 -2
- package/dist/timeline-item.js +2 -2
- package/dist/timeline.js +2 -2
- package/dist/{toggle-base-BSzBnLZN.js → toggle-base-I1wE_fVe.js} +2 -2
- package/dist/{toggle-base-BSzBnLZN.js.map → toggle-base-I1wE_fVe.js.map} +1 -1
- package/dist/tour.js +2 -2
- package/dist/transfer-list.js +3 -3
- package/dist/tree-chart.js +3 -3
- package/dist/tree-item.js +2 -2
- package/dist/tree.js +2 -2
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/typing-indicator.js +2 -2
- package/dist/url-field.js +4 -4
- package/dist/user-menu.js +2 -2
- package/dist/video-IwNmHyft.js +509 -0
- package/dist/video-IwNmHyft.js.map +1 -0
- package/dist/video.js +12 -0
- package/dist/video.js.map +1 -0
- package/dist/virtual-list.js +2 -2
- package/dist/workflow-timeline.js +2 -2
- package/dist/workflow.js +3 -3
- package/dist/workspace-switcher.js +2 -2
- package/package.json +1 -1
- package/readme.md +5 -0
- package/src/__internal/i18n/strings.ts +31 -0
- package/src/carousel/carousel.scss +124 -0
- package/src/carousel/carousel.ts +547 -0
- package/src/carousel/index.ts +1 -0
- package/src/condition-builder/cb-group-base.scss +5 -1
- package/src/condition-builder/cb-group-base.ts +1 -1
- package/src/condition-builder/cb-group.scss +4 -0
- package/src/highlight/highlight.scss +25 -0
- package/src/highlight/highlight.ts +123 -0
- package/src/highlight/index.ts +2 -0
- package/src/highlight/matches.ts +94 -0
- package/src/index.ts +18 -0
- package/src/loader.ts +36 -0
- package/src/site-footer/index.ts +2 -0
- package/src/site-footer/site-footer-group.scss +53 -0
- package/src/site-footer/site-footer-group.ts +52 -0
- package/src/site-footer/site-footer.scss +171 -0
- package/src/site-footer/site-footer.ts +151 -0
- package/src/site-header/index.ts +8 -0
- package/src/site-header/site-header.scss +238 -0
- package/src/site-header/site-header.ts +565 -0
- package/src/site-header/site-nav-group.scss +29 -0
- package/src/site-header/site-nav-group.ts +57 -0
- package/src/site-header/site-nav-link.scss +154 -0
- package/src/site-header/site-nav-link.ts +140 -0
- package/src/site-header/site-nav-menu.scss +182 -0
- package/src/site-header/site-nav-menu.ts +336 -0
- package/src/site-header/site-nav-shared.ts +27 -0
- package/src/table/table.scss +52 -2
- package/src/table/table.ts +20 -6
- package/src/video/index.ts +2 -0
- package/src/video/video-source.ts +80 -0
- package/src/video/video.scss +183 -0
- package/src/video/video.ts +246 -0
- package/dist/strings-o6v6Hrmn.js.map +0 -1
|
@@ -0,0 +1,565 @@
|
|
|
1
|
+
import { html, LitElement, nothing, type PropertyValues } from 'lit';
|
|
2
|
+
import { property, query, state } from 'lit/decorators.js';
|
|
3
|
+
import { classMap } from 'lit/directives/class-map.js';
|
|
4
|
+
import IndividualComponent from '@/IndividualComponent.js';
|
|
5
|
+
import { I18nController } from '@/__internal/i18n/i18n-controller.js';
|
|
6
|
+
import {
|
|
7
|
+
type CloseReason,
|
|
8
|
+
OverlayController,
|
|
9
|
+
} from '@/__internal/controllers/overlay-controller.js';
|
|
10
|
+
import { SiteNavMenu } from './site-nav-menu.js';
|
|
11
|
+
import { SiteNavGroup } from './site-nav-group.js';
|
|
12
|
+
import { SiteNavLink } from './site-nav-link.js';
|
|
13
|
+
import { NAV_PARTS, syncCollapsed } from './site-nav-shared.js';
|
|
14
|
+
import styles from './site-header.scss';
|
|
15
|
+
|
|
16
|
+
/** Detail of the `close` event. */
|
|
17
|
+
export interface SiteHeaderCloseDetail {
|
|
18
|
+
/** Why the navigation drawer closed. */
|
|
19
|
+
reason: CloseReason;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* @label Site Header
|
|
24
|
+
* @tag wc-site-header
|
|
25
|
+
* @rawTag site-header
|
|
26
|
+
*
|
|
27
|
+
* @summary The top navigation bar of a website or portal: brand, links, menus and actions.
|
|
28
|
+
* @overview
|
|
29
|
+
* <p>Site header is the banner of a site: the brand at the start, the site's navigation, and actions
|
|
30
|
+
* such as Sign in or a call to action at the end. It is for websites and portals. For an
|
|
31
|
+
* application's own chrome use <code>wc-app-bar</code>, and for a bar at the bottom of a phone
|
|
32
|
+
* screen <code>wc-navigation-bar</code>.</p>
|
|
33
|
+
* <p>Put <code>wc-site-nav-link</code> elements in it for destinations and
|
|
34
|
+
* <code>wc-site-nav-menu</code> elements for sections with several pages. A menu is a disclosure
|
|
35
|
+
* button that opens a panel of links, as a list or, with <code>layout="columns"</code>, as columns
|
|
36
|
+
* of <code>wc-site-nav-group</code> with a featured card. These are links and disclosure buttons,
|
|
37
|
+
* not an ARIA menu, so Tab moves through them as through any links.</p>
|
|
38
|
+
* <p>When the header is narrower than <code>collapse-at</code> (720px by default), or too narrow
|
|
39
|
+
* for the bar's content to fit, the links and
|
|
40
|
+
* menus move into a drawer that slides in from the start edge, opened by a menu button. The
|
|
41
|
+
* <code>actions</code> slot moves to the bottom of the drawer; the <code>end</code> slot stays in
|
|
42
|
+
* the bar, for something that must always show, such as a user menu or one short button.</p>
|
|
43
|
+
* <p>A visually hidden <em>Skip to main content</em> link is the first focusable element. It moves
|
|
44
|
+
* focus to <code>skip-target</code> (<code>#main</code> by default).</p>
|
|
45
|
+
*
|
|
46
|
+
* @slot brand - The site's logo and name, usually a link to the home page.
|
|
47
|
+
* @slot - The navigation: `wc-site-nav-link` and `wc-site-nav-menu` elements.
|
|
48
|
+
* @slot actions - Buttons at the end of the bar, such as Sign in and a call to action. They move to the bottom of the drawer when the header is collapsed.
|
|
49
|
+
* @slot end - Content that always stays in the bar, such as a `wc-user-menu`, a search button or one short call to action.
|
|
50
|
+
*
|
|
51
|
+
* @fires {CustomEvent} open - Dispatched when the navigation drawer opens on a narrow header.
|
|
52
|
+
* @fires {CustomEvent<{reason: 'escape' | 'light-dismiss' | 'action' | 'api'}>} close - Dispatched when the navigation drawer closes: Escape, a click on the scrim, choosing a link, or `hideDrawer()` (and widening the header past `collapse-at`).
|
|
53
|
+
*
|
|
54
|
+
* @csspart bar - The `<header>` bar.
|
|
55
|
+
* @csspart nav - The navigation landmark in the bar.
|
|
56
|
+
* @csspart skip-link - The skip link.
|
|
57
|
+
* @csspart menu-button - The button that opens the drawer.
|
|
58
|
+
* @csspart drawer - The drawer `<dialog>` on a narrow header.
|
|
59
|
+
*
|
|
60
|
+
* @cssprop --site-header-height - Height of the bar. Defaults to 4rem.
|
|
61
|
+
* @cssprop --site-header-background - Background of the bar. Defaults to `--color-surface`.
|
|
62
|
+
* @cssprop --site-header-max-width - Width the bar's content is centred in, for a full-bleed background with a narrower content column. Defaults to `none`.
|
|
63
|
+
* @cssprop --site-header-z-index - Stacking order of the header and its panels. Defaults to 10.
|
|
64
|
+
* @cssprop --site-header-drawer-width - Width of the drawer. Defaults to 22.5rem.
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* ```html
|
|
68
|
+
* <wc-site-header>
|
|
69
|
+
* <a slot="brand" href="/">Redvars</a>
|
|
70
|
+
* <wc-site-nav-menu label="Solutions">
|
|
71
|
+
* <wc-site-nav-link href="/itsm">IT service management</wc-site-nav-link>
|
|
72
|
+
* <wc-site-nav-link href="/support">Customer support</wc-site-nav-link>
|
|
73
|
+
* </wc-site-nav-menu>
|
|
74
|
+
* <wc-site-nav-link href="/docs" current>Docs</wc-site-nav-link>
|
|
75
|
+
* <wc-site-nav-link href="/pricing">Pricing</wc-site-nav-link>
|
|
76
|
+
* <wc-link-button slot="actions" variant="text" href="/sign-in">Sign in</wc-link-button>
|
|
77
|
+
* <wc-link-button slot="actions" href="/waitlist">Join the waitlist</wc-link-button>
|
|
78
|
+
* </wc-site-header>
|
|
79
|
+
* ```
|
|
80
|
+
* @example
|
|
81
|
+
* ```html
|
|
82
|
+
* <wc-site-header sticky hide-on-scroll>
|
|
83
|
+
* <a slot="brand" href="/p/support">Acme Support</a>
|
|
84
|
+
* <wc-site-nav-link href="/p/support" current>Home</wc-site-nav-link>
|
|
85
|
+
* <wc-site-nav-link href="/p/support/tickets">My tickets</wc-site-nav-link>
|
|
86
|
+
* <wc-user-menu slot="end" name="Ada Lovelace"></wc-user-menu>
|
|
87
|
+
* </wc-site-header>
|
|
88
|
+
* ```
|
|
89
|
+
* @tags navigation layout
|
|
90
|
+
*/
|
|
91
|
+
@IndividualComponent
|
|
92
|
+
export class SiteHeader extends LitElement {
|
|
93
|
+
// ── Static ───────────────────────────────────────────────────────────────
|
|
94
|
+
|
|
95
|
+
static styles = [styles];
|
|
96
|
+
|
|
97
|
+
static Menu = SiteNavMenu;
|
|
98
|
+
|
|
99
|
+
static Group = SiteNavGroup;
|
|
100
|
+
|
|
101
|
+
static Link = SiteNavLink;
|
|
102
|
+
|
|
103
|
+
// ── Properties ───────────────────────────────────────────────────────────
|
|
104
|
+
|
|
105
|
+
/** Accessible name of the navigation landmark. Defaults to Peacock's "Main navigation". */
|
|
106
|
+
@property() label = '';
|
|
107
|
+
|
|
108
|
+
/** Header width in pixels below which the navigation moves into a drawer. The header also collapses whenever the bar's content does not fit. */
|
|
109
|
+
@property({ type: Number, attribute: 'collapse-at' }) collapseAt = 720;
|
|
110
|
+
|
|
111
|
+
/** Keeps the header at the top of the viewport while the page scrolls. */
|
|
112
|
+
@property({ type: Boolean, reflect: true }) sticky = false;
|
|
113
|
+
|
|
114
|
+
/** With `sticky`, slides the header away while scrolling down and back while scrolling up. */
|
|
115
|
+
@property({ type: Boolean, reflect: true, attribute: 'hide-on-scroll' })
|
|
116
|
+
hideOnScroll = false;
|
|
117
|
+
|
|
118
|
+
/** Selector of the element the skip link moves focus to. */
|
|
119
|
+
@property({ attribute: 'skip-target' }) skipTarget = '#main';
|
|
120
|
+
|
|
121
|
+
/** Opens a menu's panel when a mouse rests on it, as well as on click. */
|
|
122
|
+
@property({ type: Boolean, reflect: true, attribute: 'open-on-hover' })
|
|
123
|
+
openOnHover = false;
|
|
124
|
+
|
|
125
|
+
/** Whether the navigation drawer is open. Only has an effect while the header is collapsed. */
|
|
126
|
+
@property({ type: Boolean, reflect: true, attribute: 'drawer-open' })
|
|
127
|
+
drawerOpen = false;
|
|
128
|
+
|
|
129
|
+
// ── State ────────────────────────────────────────────────────────────────
|
|
130
|
+
|
|
131
|
+
/** Whether the header is narrower than `collapse-at`. */
|
|
132
|
+
@state() private compact = false;
|
|
133
|
+
|
|
134
|
+
/** Whether the header has slid away while scrolling down. */
|
|
135
|
+
@state() private scrolledAway = false;
|
|
136
|
+
|
|
137
|
+
/** Which slots have content. */
|
|
138
|
+
@state() private filled = { nav: false, actions: false, end: false };
|
|
139
|
+
|
|
140
|
+
// ── Queries ──────────────────────────────────────────────────────────────
|
|
141
|
+
|
|
142
|
+
@query('.drawer') private dialogElement?: HTMLDialogElement;
|
|
143
|
+
|
|
144
|
+
// ── Private fields ───────────────────────────────────────────────────────
|
|
145
|
+
|
|
146
|
+
/** Peacock's strings for the skip link, the menu button and the landmark. */
|
|
147
|
+
private readonly i18n = new I18nController(this);
|
|
148
|
+
|
|
149
|
+
private readonly overlay = new OverlayController(this, {
|
|
150
|
+
surface: () => this.dialogElement,
|
|
151
|
+
modal: true,
|
|
152
|
+
initialFocus: () => {
|
|
153
|
+
const links = Array.from(
|
|
154
|
+
this.querySelectorAll<SiteNavLink>('wc-site-nav-link'),
|
|
155
|
+
).filter(link => !link.closest('wc-site-nav-menu:not([open])'));
|
|
156
|
+
return (
|
|
157
|
+
links.find(link => link.current) ??
|
|
158
|
+
this.querySelector<HTMLElement>(
|
|
159
|
+
':scope > wc-site-nav-link, :scope > wc-site-nav-menu',
|
|
160
|
+
)
|
|
161
|
+
);
|
|
162
|
+
},
|
|
163
|
+
requestClose: reason => this.closeDrawer(reason),
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
/** Watches the header's width against `collapse-at`. */
|
|
167
|
+
private resizeObserver?: ResizeObserver;
|
|
168
|
+
|
|
169
|
+
/** Watches the children, since a slot that is not rendered fires no `slotchange`. */
|
|
170
|
+
private readonly childObserver = new MutationObserver(() => {
|
|
171
|
+
this.syncSlots();
|
|
172
|
+
syncCollapsed(this, this.compact);
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
/** The last measured width of the header. */
|
|
176
|
+
private width = 0;
|
|
177
|
+
|
|
178
|
+
/** The header width the bar's content needs, measured while it was last shown wide. */
|
|
179
|
+
private neededWidth = 0;
|
|
180
|
+
|
|
181
|
+
/** Watches the bar's parts, whose width changes as links render, fonts load or text changes. */
|
|
182
|
+
private contentObserver?: ResizeObserver;
|
|
183
|
+
|
|
184
|
+
/** Pending measurement after the bar's parts changed size. */
|
|
185
|
+
private fitTimer?: ReturnType<typeof setTimeout>;
|
|
186
|
+
|
|
187
|
+
/** Scroll position at the last scroll event, to tell the direction. */
|
|
188
|
+
private lastScrollY = 0;
|
|
189
|
+
|
|
190
|
+
/** Why the drawer is closing, for the next `close` event. */
|
|
191
|
+
private closeReason: CloseReason = 'api';
|
|
192
|
+
|
|
193
|
+
/** Whether the drawer was open at the last `open`/`close` event, so each change fires once. */
|
|
194
|
+
private announcedOpen?: boolean;
|
|
195
|
+
|
|
196
|
+
// ── Lifecycle ────────────────────────────────────────────────────────────
|
|
197
|
+
|
|
198
|
+
override connectedCallback() {
|
|
199
|
+
super.connectedCallback();
|
|
200
|
+
this.syncSlots();
|
|
201
|
+
this.childObserver.observe(this, {
|
|
202
|
+
childList: true,
|
|
203
|
+
attributes: true,
|
|
204
|
+
attributeFilter: ['slot'],
|
|
205
|
+
});
|
|
206
|
+
if (typeof ResizeObserver !== 'undefined') {
|
|
207
|
+
this.resizeObserver = new ResizeObserver(entries => {
|
|
208
|
+
const entry = entries[entries.length - 1];
|
|
209
|
+
if (!entry) return;
|
|
210
|
+
this.width = entry.contentRect.width;
|
|
211
|
+
if (!this.compact) this.measureFit();
|
|
212
|
+
this.syncCompact();
|
|
213
|
+
});
|
|
214
|
+
this.resizeObserver.observe(this);
|
|
215
|
+
// On the next task: measuring here could resize what is observed in the same frame.
|
|
216
|
+
this.contentObserver = new ResizeObserver(() => {
|
|
217
|
+
clearTimeout(this.fitTimer);
|
|
218
|
+
this.fitTimer = setTimeout(() => {
|
|
219
|
+
if (!this.isConnected || this.compact) return;
|
|
220
|
+
this.measureFit();
|
|
221
|
+
this.syncCompact();
|
|
222
|
+
});
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
window.addEventListener('scroll', this.handleScroll, { passive: true });
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
override disconnectedCallback() {
|
|
229
|
+
this.resizeObserver?.disconnect();
|
|
230
|
+
this.resizeObserver = undefined;
|
|
231
|
+
this.contentObserver?.disconnect();
|
|
232
|
+
this.contentObserver = undefined;
|
|
233
|
+
clearTimeout(this.fitTimer);
|
|
234
|
+
this.childObserver.disconnect();
|
|
235
|
+
window.removeEventListener('scroll', this.handleScroll);
|
|
236
|
+
super.disconnectedCallback();
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
protected override willUpdate(changed: PropertyValues) {
|
|
240
|
+
// Measure now on the first render, so a narrow screen never flashes the wide bar.
|
|
241
|
+
if (!this.hasUpdated || changed.has('collapseAt')) {
|
|
242
|
+
this.width = this.getBoundingClientRect().width;
|
|
243
|
+
this.syncCompact();
|
|
244
|
+
}
|
|
245
|
+
// Widening past `collapse-at` closes the drawer; the bar shows the links instead.
|
|
246
|
+
if (
|
|
247
|
+
changed.has('compact') &&
|
|
248
|
+
changed.get('compact') === true &&
|
|
249
|
+
!this.compact &&
|
|
250
|
+
this.drawerOpen
|
|
251
|
+
) {
|
|
252
|
+
this.closeReason = 'api';
|
|
253
|
+
this.drawerOpen = false;
|
|
254
|
+
}
|
|
255
|
+
if (!this.hideOnScroll || !this.sticky) this.scrolledAway = false;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
protected override updated(changed: PropertyValues) {
|
|
259
|
+
if (changed.has('compact')) {
|
|
260
|
+
syncCollapsed(this, this.compact);
|
|
261
|
+
this.close();
|
|
262
|
+
}
|
|
263
|
+
if (!this.compact) {
|
|
264
|
+
this.renderRoot
|
|
265
|
+
.querySelectorAll('.brand, .nav, .actions, .end')
|
|
266
|
+
.forEach(part => this.contentObserver?.observe(part));
|
|
267
|
+
this.measureFit();
|
|
268
|
+
this.syncCompact();
|
|
269
|
+
}
|
|
270
|
+
this.toggleAttribute('data-scrolled-away', this.scrolledAway);
|
|
271
|
+
if (changed.has('drawerOpen') || changed.has('compact')) {
|
|
272
|
+
this.overlay.sync(this.drawerShown);
|
|
273
|
+
}
|
|
274
|
+
const shown = this.drawerShown;
|
|
275
|
+
if (this.announcedOpen === undefined) {
|
|
276
|
+
// `drawer-open` set in markup is not a user action.
|
|
277
|
+
this.announcedOpen = shown;
|
|
278
|
+
return;
|
|
279
|
+
}
|
|
280
|
+
if (shown === this.announcedOpen) return;
|
|
281
|
+
this.announcedOpen = shown;
|
|
282
|
+
if (shown) {
|
|
283
|
+
this.dispatchEvent(
|
|
284
|
+
new CustomEvent('open', { bubbles: true, composed: true }),
|
|
285
|
+
);
|
|
286
|
+
} else {
|
|
287
|
+
this.dispatchEvent(
|
|
288
|
+
new CustomEvent<SiteHeaderCloseDetail>('close', {
|
|
289
|
+
detail: { reason: this.closeReason },
|
|
290
|
+
bubbles: true,
|
|
291
|
+
composed: true,
|
|
292
|
+
}),
|
|
293
|
+
);
|
|
294
|
+
}
|
|
295
|
+
this.closeReason = 'api';
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
// ── Public methods ───────────────────────────────────────────────────────
|
|
299
|
+
|
|
300
|
+
/** Whether the header is narrower than `collapse-at`, with its navigation in the drawer. */
|
|
301
|
+
get collapsed(): boolean {
|
|
302
|
+
return this.compact;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
/** Opens the navigation drawer (while collapsed). */
|
|
306
|
+
showDrawer() {
|
|
307
|
+
this.drawerOpen = true;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
/** Closes the navigation drawer. */
|
|
311
|
+
hideDrawer() {
|
|
312
|
+
this.closeDrawer('api');
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
/** Closes every open menu panel in the bar. */
|
|
316
|
+
close() {
|
|
317
|
+
if (this.compact) return;
|
|
318
|
+
for (const menu of this.querySelectorAll<SiteNavMenu>(NAV_PARTS.menu)) {
|
|
319
|
+
menu.open = false;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
// ── Private methods ──────────────────────────────────────────────────────
|
|
324
|
+
|
|
325
|
+
/** Whether the drawer is showing right now. */
|
|
326
|
+
private get drawerShown() {
|
|
327
|
+
return this.compact && this.drawerOpen;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
private closeDrawer(reason: CloseReason) {
|
|
331
|
+
if (!this.drawerOpen) return;
|
|
332
|
+
this.closeReason = reason;
|
|
333
|
+
this.drawerOpen = false;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
private syncCompact() {
|
|
337
|
+
if (this.width <= 0) return;
|
|
338
|
+
this.compact = this.width < Math.max(this.collapseAt, this.neededWidth);
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
/**
|
|
342
|
+
* Measures the width the wide bar's content needs: the brand, links, actions and end at their
|
|
343
|
+
* natural widths, with the gaps and padding. The header collapses below it, as below
|
|
344
|
+
* `collapse-at`, so links never run into the actions.
|
|
345
|
+
*/
|
|
346
|
+
private measureFit() {
|
|
347
|
+
const inner = this.renderRoot.querySelector<HTMLElement>('.inner');
|
|
348
|
+
if (!inner || !inner.clientWidth) return;
|
|
349
|
+
const style = getComputedStyle(inner);
|
|
350
|
+
const gap = parseFloat(style.columnGap) || 0;
|
|
351
|
+
const padding =
|
|
352
|
+
(parseFloat(style.paddingInlineStart) || 0) +
|
|
353
|
+
(parseFloat(style.paddingInlineEnd) || 0);
|
|
354
|
+
const parts = Array.from(inner.children).filter(
|
|
355
|
+
(part): part is HTMLElement =>
|
|
356
|
+
part instanceof HTMLElement &&
|
|
357
|
+
!part.hidden &&
|
|
358
|
+
getComputedStyle(part).display !== 'none',
|
|
359
|
+
);
|
|
360
|
+
const content = parts.reduce(
|
|
361
|
+
(sum, part) =>
|
|
362
|
+
part.classList.contains('spacer')
|
|
363
|
+
? sum
|
|
364
|
+
: sum + part.getBoundingClientRect().width,
|
|
365
|
+
0,
|
|
366
|
+
);
|
|
367
|
+
const needed = content + gap * Math.max(0, parts.length - 1) + padding;
|
|
368
|
+
// In header widths, since a max-width can make the bar narrower than the header.
|
|
369
|
+
this.neededWidth = Math.ceil(needed + (this.width - inner.clientWidth));
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
/** Reads which slots have content from the light DOM, so it does not depend on what is rendered. */
|
|
373
|
+
private syncSlots = () => {
|
|
374
|
+
const children = Array.from(this.children);
|
|
375
|
+
const filled = {
|
|
376
|
+
nav: children.some(child => !child.hasAttribute('slot')),
|
|
377
|
+
actions: children.some(child => child.getAttribute('slot') === 'actions'),
|
|
378
|
+
end: children.some(child => child.getAttribute('slot') === 'end'),
|
|
379
|
+
};
|
|
380
|
+
if (
|
|
381
|
+
filled.nav !== this.filled.nav ||
|
|
382
|
+
filled.actions !== this.filled.actions ||
|
|
383
|
+
filled.end !== this.filled.end
|
|
384
|
+
) {
|
|
385
|
+
this.filled = filled;
|
|
386
|
+
}
|
|
387
|
+
};
|
|
388
|
+
|
|
389
|
+
private handleScroll = () => {
|
|
390
|
+
const y = window.scrollY;
|
|
391
|
+
const delta = y - this.lastScrollY;
|
|
392
|
+
this.lastScrollY = y;
|
|
393
|
+
if (!this.sticky || !this.hideOnScroll || this.drawerShown) return;
|
|
394
|
+
if (delta < 0 || y <= this.offsetHeight) {
|
|
395
|
+
this.scrolledAway = false;
|
|
396
|
+
return;
|
|
397
|
+
}
|
|
398
|
+
// Never slide away from under focus or an open panel.
|
|
399
|
+
const busy =
|
|
400
|
+
this.matches(':focus-within') ||
|
|
401
|
+
!!this.querySelector(`${NAV_PARTS.menu}[open]`);
|
|
402
|
+
if (delta > 0 && !busy) this.scrolledAway = true;
|
|
403
|
+
};
|
|
404
|
+
|
|
405
|
+
/**
|
|
406
|
+
* Fragment links do not reach elements inside shadow roots, so move focus directly. The target is
|
|
407
|
+
* looked for beside the header first, for a header in an app's own shadow root, then in the page.
|
|
408
|
+
*/
|
|
409
|
+
private handleSkipClick(event: MouseEvent) {
|
|
410
|
+
let target: HTMLElement | null = null;
|
|
411
|
+
try {
|
|
412
|
+
const root = this.getRootNode() as Document | ShadowRoot;
|
|
413
|
+
target =
|
|
414
|
+
root.querySelector<HTMLElement>(this.skipTarget) ??
|
|
415
|
+
document.querySelector<HTMLElement>(this.skipTarget);
|
|
416
|
+
} catch {
|
|
417
|
+
target = null;
|
|
418
|
+
}
|
|
419
|
+
if (!target) return;
|
|
420
|
+
event.preventDefault();
|
|
421
|
+
if (target.tabIndex < 0 && !target.hasAttribute('tabindex')) {
|
|
422
|
+
target.setAttribute('tabindex', '-1');
|
|
423
|
+
}
|
|
424
|
+
target.focus();
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
private handleMenuButtonClick() {
|
|
428
|
+
if (this.drawerOpen) this.hideDrawer();
|
|
429
|
+
else this.showDrawer();
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
private handleCloseButtonClick() {
|
|
433
|
+
this.closeDrawer('action');
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
/** Choosing a link in the drawer closes it. */
|
|
437
|
+
private handleDrawerLinkClick(event: MouseEvent) {
|
|
438
|
+
const link = event
|
|
439
|
+
.composedPath()
|
|
440
|
+
.find(
|
|
441
|
+
target => target instanceof Element && target.matches(NAV_PARTS.link),
|
|
442
|
+
);
|
|
443
|
+
if (link) this.closeDrawer('action');
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
/** The native Escape `cancel`: keep `drawer-open` in charge. */
|
|
447
|
+
private handleCancel(event: Event) {
|
|
448
|
+
event.preventDefault();
|
|
449
|
+
this.closeDrawer('escape');
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
/** The browser closed the dialog on its own: keep `drawer-open` in step. */
|
|
453
|
+
private handleNativeClose(event: Event) {
|
|
454
|
+
if (event.target !== this.dialogElement) return;
|
|
455
|
+
if (this.overlay.takeOwnClose()) return;
|
|
456
|
+
this.closeDrawer('escape');
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
/** A click outside the drawer's box lands on its backdrop: a light dismiss. */
|
|
460
|
+
private handleDialogClick(event: MouseEvent) {
|
|
461
|
+
const dialog = this.dialogElement;
|
|
462
|
+
if (!dialog) return;
|
|
463
|
+
if (event.target !== dialog) {
|
|
464
|
+
this.handleDrawerLinkClick(event);
|
|
465
|
+
return;
|
|
466
|
+
}
|
|
467
|
+
const rect = dialog.getBoundingClientRect();
|
|
468
|
+
const inside =
|
|
469
|
+
event.clientX >= rect.left &&
|
|
470
|
+
event.clientX <= rect.right &&
|
|
471
|
+
event.clientY >= rect.top &&
|
|
472
|
+
event.clientY <= rect.bottom;
|
|
473
|
+
if (!inside) this.closeDrawer('light-dismiss');
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
// ── Render helpers ───────────────────────────────────────────────────────
|
|
477
|
+
|
|
478
|
+
private renderMenuButton() {
|
|
479
|
+
if (!this.compact || !this.filled.nav) return nothing;
|
|
480
|
+
return html`<wc-icon-button
|
|
481
|
+
class="menu-button"
|
|
482
|
+
part="menu-button"
|
|
483
|
+
variant="text"
|
|
484
|
+
shape="round"
|
|
485
|
+
aria-label=${this.i18n.t('openMenu')}
|
|
486
|
+
aria-expanded=${String(this.drawerOpen)}
|
|
487
|
+
aria-controls="drawer"
|
|
488
|
+
@click=${this.handleMenuButtonClick}
|
|
489
|
+
>
|
|
490
|
+
<wc-icon name="menu"></wc-icon>
|
|
491
|
+
</wc-icon-button>`;
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
private renderDrawer() {
|
|
495
|
+
if (!this.compact) return nothing;
|
|
496
|
+
const label = this.label || this.i18n.t('mainNavigation');
|
|
497
|
+
// The scrim click has its keyboard equivalent in Escape, which the overlay controller handles.
|
|
498
|
+
/* eslint-disable lit-a11y/click-events-have-key-events */
|
|
499
|
+
return html`<dialog
|
|
500
|
+
id="drawer"
|
|
501
|
+
class="drawer"
|
|
502
|
+
part="drawer"
|
|
503
|
+
aria-label=${label}
|
|
504
|
+
@cancel=${this.handleCancel}
|
|
505
|
+
@close=${this.handleNativeClose}
|
|
506
|
+
@click=${this.handleDialogClick}
|
|
507
|
+
>
|
|
508
|
+
<div class="drawer-header">
|
|
509
|
+
<wc-icon-button
|
|
510
|
+
class="close-button"
|
|
511
|
+
variant="text"
|
|
512
|
+
shape="round"
|
|
513
|
+
aria-label=${this.i18n.t('close')}
|
|
514
|
+
@click=${this.handleCloseButtonClick}
|
|
515
|
+
>
|
|
516
|
+
<wc-icon name="close"></wc-icon>
|
|
517
|
+
</wc-icon-button>
|
|
518
|
+
</div>
|
|
519
|
+
<nav class="drawer-nav" aria-label=${label}>
|
|
520
|
+
<slot @slotchange=${this.syncSlots}></slot>
|
|
521
|
+
</nav>
|
|
522
|
+
<div class="drawer-actions" ?hidden=${!this.filled.actions}>
|
|
523
|
+
<slot name="actions" @slotchange=${this.syncSlots}></slot>
|
|
524
|
+
</div>
|
|
525
|
+
</dialog>`;
|
|
526
|
+
/* eslint-enable lit-a11y/click-events-have-key-events */
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
// ── Render ───────────────────────────────────────────────────────────────
|
|
530
|
+
|
|
531
|
+
render() {
|
|
532
|
+
const label = this.label || this.i18n.t('mainNavigation');
|
|
533
|
+
return html`
|
|
534
|
+
<a
|
|
535
|
+
class="skip-link"
|
|
536
|
+
part="skip-link"
|
|
537
|
+
href=${this.skipTarget}
|
|
538
|
+
@click=${this.handleSkipClick}
|
|
539
|
+
>${this.i18n.t('skipToMainContent')}</a
|
|
540
|
+
>
|
|
541
|
+
<header
|
|
542
|
+
class=${classMap({ bar: true, compact: this.compact })}
|
|
543
|
+
part="bar"
|
|
544
|
+
>
|
|
545
|
+
<div class="inner">
|
|
546
|
+
<div class="brand"><slot name="brand"></slot></div>
|
|
547
|
+
${this.compact
|
|
548
|
+
? html`<span class="spacer"></span>`
|
|
549
|
+
: html`<nav class="nav" part="nav" aria-label=${label}>
|
|
550
|
+
<slot @slotchange=${this.syncSlots}></slot>
|
|
551
|
+
</nav>
|
|
552
|
+
<span class="spacer"></span>
|
|
553
|
+
<div class="actions" ?hidden=${!this.filled.actions}>
|
|
554
|
+
<slot name="actions" @slotchange=${this.syncSlots}></slot>
|
|
555
|
+
</div>`}
|
|
556
|
+
<div class="end" ?hidden=${!this.filled.end}>
|
|
557
|
+
<slot name="end" @slotchange=${this.syncSlots}></slot>
|
|
558
|
+
</div>
|
|
559
|
+
${this.renderMenuButton()}
|
|
560
|
+
</div>
|
|
561
|
+
</header>
|
|
562
|
+
${this.renderDrawer()}
|
|
563
|
+
`;
|
|
564
|
+
}
|
|
565
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
@use '../../scss/mixin';
|
|
2
|
+
|
|
3
|
+
@include mixin.base-styles;
|
|
4
|
+
|
|
5
|
+
:host {
|
|
6
|
+
display: block;
|
|
7
|
+
min-inline-size: 0;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.title {
|
|
11
|
+
@include mixin.get-typography(label-medium);
|
|
12
|
+
|
|
13
|
+
margin-block-end: var(--spacing-100);
|
|
14
|
+
padding-inline: var(--spacing-150);
|
|
15
|
+
color: var(--color-on-surface-variant);
|
|
16
|
+
text-transform: uppercase;
|
|
17
|
+
letter-spacing: 0.04em;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.links {
|
|
21
|
+
display: flex;
|
|
22
|
+
flex-direction: column;
|
|
23
|
+
gap: var(--spacing-025);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
:host([data-collapsed]) .title {
|
|
27
|
+
margin-block: var(--spacing-150) var(--spacing-050);
|
|
28
|
+
padding-inline: var(--spacing-400);
|
|
29
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { html, LitElement } from 'lit';
|
|
2
|
+
import { property } from 'lit/decorators.js';
|
|
3
|
+
import IndividualComponent from '@/IndividualComponent.js';
|
|
4
|
+
import { adoptCollapsed } from './site-nav-shared.js';
|
|
5
|
+
import styles from './site-nav-group.scss';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @label Site Nav Group
|
|
9
|
+
* @tag wc-site-nav-group
|
|
10
|
+
* @rawTag site-nav-group
|
|
11
|
+
*
|
|
12
|
+
* @summary A titled column of links in a site header menu.
|
|
13
|
+
* @overview
|
|
14
|
+
* <p>Groups <code>wc-site-nav-link</code> elements under a title inside a
|
|
15
|
+
* <code>wc-site-nav-menu</code>, usually one with <code>layout="columns"</code>, where each group is
|
|
16
|
+
* a column. The group is labelled by its title for assistive technology.</p>
|
|
17
|
+
*
|
|
18
|
+
* @slot - The group's `wc-site-nav-link` elements.
|
|
19
|
+
*
|
|
20
|
+
* @csspart title - The group's title.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```html
|
|
24
|
+
* <wc-site-nav-group label="Build">
|
|
25
|
+
* <wc-site-nav-link href="/tables">Tables and forms</wc-site-nav-link>
|
|
26
|
+
* <wc-site-nav-link href="/rules">Rules</wc-site-nav-link>
|
|
27
|
+
* </wc-site-nav-group>
|
|
28
|
+
* ```
|
|
29
|
+
* @tags navigation
|
|
30
|
+
*/
|
|
31
|
+
@IndividualComponent
|
|
32
|
+
export class SiteNavGroup extends LitElement {
|
|
33
|
+
// ── Static ───────────────────────────────────────────────────────────────
|
|
34
|
+
|
|
35
|
+
static styles = [styles];
|
|
36
|
+
|
|
37
|
+
// ── Properties ───────────────────────────────────────────────────────────
|
|
38
|
+
|
|
39
|
+
/** The group's title. */
|
|
40
|
+
@property() label = '';
|
|
41
|
+
|
|
42
|
+
// ── Lifecycle ────────────────────────────────────────────────────────────
|
|
43
|
+
|
|
44
|
+
override connectedCallback() {
|
|
45
|
+
super.connectedCallback();
|
|
46
|
+
adoptCollapsed(this);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// ── Render ───────────────────────────────────────────────────────────────
|
|
50
|
+
|
|
51
|
+
render() {
|
|
52
|
+
return html`<div class="group" role="group" aria-labelledby="title">
|
|
53
|
+
<div id="title" class="title" part="title">${this.label}</div>
|
|
54
|
+
<div class="links"><slot></slot></div>
|
|
55
|
+
</div>`;
|
|
56
|
+
}
|
|
57
|
+
}
|