@orange-halo/components 2.1.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/custom-elements.json +968 -362
- package/dist/base.d.ts.map +1 -1
- package/dist/base.js +1 -2
- package/dist/base.js.map +1 -1
- package/dist/index.d.ts +4 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -4
- package/dist/index.js.map +1 -1
- package/dist/oh-accordion.d.ts +53 -8
- package/dist/oh-accordion.d.ts.map +1 -1
- package/dist/oh-accordion.js +99 -29
- package/dist/oh-accordion.js.map +1 -1
- package/dist/oh-alert.d.ts +26 -8
- package/dist/oh-alert.d.ts.map +1 -1
- package/dist/oh-alert.js +96 -36
- package/dist/oh-alert.js.map +1 -1
- package/dist/oh-badge.d.ts +32 -13
- package/dist/oh-badge.d.ts.map +1 -1
- package/dist/oh-badge.js +38 -19
- package/dist/oh-badge.js.map +1 -1
- package/dist/oh-breadcrumb.d.ts +39 -12
- package/dist/oh-breadcrumb.d.ts.map +1 -1
- package/dist/oh-breadcrumb.js +66 -25
- package/dist/oh-breadcrumb.js.map +1 -1
- package/dist/oh-button.d.ts +49 -23
- package/dist/oh-button.d.ts.map +1 -1
- package/dist/oh-button.figma.js +1 -3
- package/dist/oh-button.figma.js.map +1 -1
- package/dist/oh-button.js +133 -82
- package/dist/oh-button.js.map +1 -1
- package/dist/oh-card.d.ts +47 -19
- package/dist/oh-card.d.ts.map +1 -1
- package/dist/oh-card.js +143 -96
- package/dist/oh-card.js.map +1 -1
- package/dist/oh-checkbox-group.d.ts +56 -12
- package/dist/oh-checkbox-group.d.ts.map +1 -1
- package/dist/oh-checkbox-group.figma.js +4 -6
- package/dist/oh-checkbox-group.figma.js.map +1 -1
- package/dist/oh-checkbox-group.js +114 -49
- package/dist/oh-checkbox-group.js.map +1 -1
- package/dist/oh-checkbox.d.ts +54 -17
- package/dist/oh-checkbox.d.ts.map +1 -1
- package/dist/oh-checkbox.js +117 -60
- package/dist/oh-checkbox.js.map +1 -1
- package/dist/oh-cluster.d.ts +19 -14
- package/dist/oh-cluster.d.ts.map +1 -1
- package/dist/oh-cluster.js +19 -19
- package/dist/oh-cluster.js.map +1 -1
- package/dist/oh-container.d.ts +19 -16
- package/dist/oh-container.d.ts.map +1 -1
- package/dist/oh-container.js +21 -23
- package/dist/oh-container.js.map +1 -1
- package/dist/oh-drawer.d.ts +28 -11
- package/dist/oh-drawer.d.ts.map +1 -1
- package/dist/oh-drawer.js +52 -24
- package/dist/oh-drawer.js.map +1 -1
- package/dist/oh-footer.d.ts +37 -18
- package/dist/oh-footer.d.ts.map +1 -1
- package/dist/oh-footer.js +38 -19
- package/dist/oh-footer.js.map +1 -1
- package/dist/oh-grid.d.ts +27 -14
- package/dist/oh-grid.d.ts.map +1 -1
- package/dist/oh-grid.js +28 -21
- package/dist/oh-grid.js.map +1 -1
- package/dist/oh-icon.d.ts +21 -5
- package/dist/oh-icon.d.ts.map +1 -1
- package/dist/oh-icon.js +27 -9
- package/dist/oh-icon.js.map +1 -1
- package/dist/oh-input.d.ts +110 -21
- package/dist/oh-input.d.ts.map +1 -1
- package/dist/oh-input.figma.js +2 -2
- package/dist/oh-input.figma.js.map +1 -1
- package/dist/oh-input.js +227 -71
- package/dist/oh-input.js.map +1 -1
- package/dist/oh-link.d.ts +42 -19
- package/dist/oh-link.d.ts.map +1 -1
- package/dist/oh-link.js +83 -38
- package/dist/oh-link.js.map +1 -1
- package/dist/oh-modal.d.ts +35 -6
- package/dist/oh-modal.d.ts.map +1 -1
- package/dist/oh-modal.js +90 -39
- package/dist/oh-modal.js.map +1 -1
- package/dist/oh-navbar.d.ts +42 -19
- package/dist/oh-navbar.d.ts.map +1 -1
- package/dist/oh-navbar.js +44 -20
- package/dist/oh-navbar.js.map +1 -1
- package/dist/oh-progress.d.ts +26 -7
- package/dist/oh-progress.d.ts.map +1 -1
- package/dist/oh-progress.js +35 -14
- package/dist/oh-progress.js.map +1 -1
- package/dist/oh-radio-group.d.ts +55 -13
- package/dist/oh-radio-group.d.ts.map +1 -1
- package/dist/oh-radio-group.figma.js +2 -2
- package/dist/oh-radio-group.figma.js.map +1 -1
- package/dist/oh-radio-group.js +122 -51
- package/dist/oh-radio-group.js.map +1 -1
- package/dist/oh-radio.d.ts +55 -17
- package/dist/oh-radio.d.ts.map +1 -1
- package/dist/oh-radio.js +120 -61
- package/dist/oh-radio.js.map +1 -1
- package/dist/oh-select.d.ts +59 -16
- package/dist/oh-select.d.ts.map +1 -1
- package/dist/oh-select.js +141 -69
- package/dist/oh-select.js.map +1 -1
- package/dist/oh-skip-link.d.ts +33 -15
- package/dist/oh-skip-link.d.ts.map +1 -1
- package/dist/oh-skip-link.js +43 -32
- package/dist/oh-skip-link.js.map +1 -1
- package/dist/oh-stack.d.ts +17 -14
- package/dist/oh-stack.d.ts.map +1 -1
- package/dist/oh-stack.js +18 -20
- package/dist/oh-stack.js.map +1 -1
- package/dist/oh-tabs.d.ts +55 -30
- package/dist/oh-tabs.d.ts.map +1 -1
- package/dist/oh-tabs.js +100 -76
- package/dist/oh-tabs.js.map +1 -1
- package/dist/oh-textarea.d.ts +129 -0
- package/dist/oh-textarea.d.ts.map +1 -0
- package/dist/oh-textarea.js +401 -0
- package/dist/oh-textarea.js.map +1 -0
- package/dist/oh-toggle.d.ts +45 -12
- package/dist/oh-toggle.d.ts.map +1 -1
- package/dist/oh-toggle.js +84 -34
- package/dist/oh-toggle.js.map +1 -1
- package/dist/styles/typography.js +1 -1
- package/package.json +7 -7
- package/dist/oh-hero.d.ts +0 -33
- package/dist/oh-hero.d.ts.map +0 -1
- package/dist/oh-hero.js +0 -246
- package/dist/oh-hero.js.map +0 -1
package/dist/oh-link.js
CHANGED
|
@@ -1,29 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* oh-link
|
|
3
3
|
*
|
|
4
|
-
* A warm, playful link with retro-inspired styling.
|
|
5
|
-
* Two variants: inline (for body text) and standalone (for CTAs).
|
|
6
|
-
*
|
|
7
4
|
* DESIGN DECISIONS:
|
|
8
5
|
* ─────────────────
|
|
9
|
-
* 1.
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* - Arrow icon option
|
|
20
|
-
*
|
|
21
|
-
* 3. ACCESSIBILITY
|
|
22
|
-
* - Underline always visible (not color-only)
|
|
23
|
-
* - Clear focus state
|
|
24
|
-
* - Proper contrast ratios
|
|
25
|
-
*
|
|
26
|
-
* @element oh-link
|
|
6
|
+
* 1. Two variants: `inline` for links inside body text, `standalone` for
|
|
7
|
+
* links that stand on their own (CTAs, "View all").
|
|
8
|
+
* 2. The underline is a pseudo-element so it can transition. Its shape comes
|
|
9
|
+
* from the `decoration.underline*` tokens; it retracts on hover.
|
|
10
|
+
* 3. Keyboard focus swaps in a solid underline (`color.brand.primary`,
|
|
11
|
+
* `decoration.underlineFocusThickness`) as the indicator; the
|
|
12
|
+
* `focus.glowColor` tint behind it is decoration only.
|
|
13
|
+
* 4. Links are never colour-only: the underline is visible at rest.
|
|
14
|
+
* 5. `target="_blank"` adds an icon, a visually hidden "(opens in new tab)"
|
|
15
|
+
* and `rel="noopener noreferrer"` (unless `rel` is set).
|
|
27
16
|
*/
|
|
28
17
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
29
18
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -34,6 +23,40 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
34
23
|
import { html, css, nothing } from "lit";
|
|
35
24
|
import { customElement, property } from "lit/decorators.js";
|
|
36
25
|
import { OhElement, baseStyles } from "./base.js";
|
|
26
|
+
/**
|
|
27
|
+
* A text link, for use inside body copy or on its own as a call to action.
|
|
28
|
+
*
|
|
29
|
+
* **Use it for** navigating to another page or place. **Don't use it for**
|
|
30
|
+
* actions that don't navigate (use `oh-button` instead).
|
|
31
|
+
*
|
|
32
|
+
* **Variants:** `inline` (default) sits in running text; `standalone` is
|
|
33
|
+
* larger and bolder for links on their own, and can show a trailing arrow
|
|
34
|
+
* (`arrow`). `inverse` is for links on accent surfaces.
|
|
35
|
+
*
|
|
36
|
+
* **Behaviour:** renders a native `<a>`, so Enter follows it and it takes
|
|
37
|
+
* focus in tab order. On hover the underline retracts and the arrow nudges
|
|
38
|
+
* forward. Keyboard focus (`:focus-visible`) shows a solid underline and a
|
|
39
|
+
* tint; mouse focus doesn't. Transitions are cut short under
|
|
40
|
+
* `prefers-reduced-motion`. With `target="_blank"` it adds an external icon,
|
|
41
|
+
* screen-reader text "(opens in new tab)" and `rel="noopener noreferrer"`
|
|
42
|
+
* when `rel` isn't set; the arrow is not shown on external links.
|
|
43
|
+
*
|
|
44
|
+
* **Accessibility:** the underline shows at rest and on focus, so links
|
|
45
|
+
* don't rely on colour. Write link text that makes sense out of context.
|
|
46
|
+
*
|
|
47
|
+
* **Look:** set by tokens — `color.text.link` the colour (`color.text.onAccent`
|
|
48
|
+
* when `inverse`); `decoration.underlineThickness`, `decoration.underlineDash`
|
|
49
|
+
* and `decoration.underlinePeriod` the underline; `color.brand.primary`
|
|
50
|
+
* (`color.text.onAccent` when `inverse`) and
|
|
51
|
+
* `decoration.underlineFocusThickness` the focus underline; `focus.glowColor`
|
|
52
|
+
* (`link.inverse.focusBackground` when `inverse`) the focus tint;
|
|
53
|
+
* `typography.body.fontFamily`, plus `typography.body.lg.fontSize` and
|
|
54
|
+
* `typography.emphasis.fontWeight` for `standalone`; `motion.slow` and
|
|
55
|
+
* `motion.snappy` the transitions.
|
|
56
|
+
*
|
|
57
|
+
* @element oh-link
|
|
58
|
+
* @slot - The link text.
|
|
59
|
+
*/
|
|
37
60
|
let OhLink = class OhLink extends OhElement {
|
|
38
61
|
constructor() {
|
|
39
62
|
super(...arguments);
|
|
@@ -47,11 +70,6 @@ let OhLink = class OhLink extends OhElement {
|
|
|
47
70
|
static { this.styles = [
|
|
48
71
|
baseStyles,
|
|
49
72
|
css `
|
|
50
|
-
/* ═══════════════════════════════════════════════════════════════
|
|
51
|
-
ORANGE HALO LINK
|
|
52
|
-
Warm • Playful • Retro-inspired
|
|
53
|
-
═══════════════════════════════════════════════════════════════ */
|
|
54
|
-
|
|
55
73
|
:host {
|
|
56
74
|
display: inline;
|
|
57
75
|
}
|
|
@@ -74,9 +92,9 @@ let OhLink = class OhLink extends OhElement {
|
|
|
74
92
|
text-decoration: none;
|
|
75
93
|
}
|
|
76
94
|
|
|
77
|
-
/*
|
|
95
|
+
/* Underline via pseudo-element (animatable), shaped by decoration tokens */
|
|
78
96
|
.link__text::after {
|
|
79
|
-
content:
|
|
97
|
+
content: "";
|
|
80
98
|
position: absolute;
|
|
81
99
|
left: 0;
|
|
82
100
|
right: 0;
|
|
@@ -96,7 +114,7 @@ let OhLink = class OhLink extends OhElement {
|
|
|
96
114
|
|
|
97
115
|
/* ═══════════════════════════════════════════════════════════════
|
|
98
116
|
INLINE VARIANT
|
|
99
|
-
|
|
117
|
+
Underline shrinks right-to-left on hover
|
|
100
118
|
═══════════════════════════════════════════════════════════════ */
|
|
101
119
|
|
|
102
120
|
.link--inline {
|
|
@@ -148,7 +166,7 @@ let OhLink = class OhLink extends OhElement {
|
|
|
148
166
|
|
|
149
167
|
/* ═══════════════════════════════════════════════════════════════
|
|
150
168
|
STANDALONE VARIANT
|
|
151
|
-
CTA-style
|
|
169
|
+
CTA-style; underline shrinks on hover
|
|
152
170
|
═══════════════════════════════════════════════════════════════ */
|
|
153
171
|
|
|
154
172
|
.link--standalone {
|
|
@@ -291,7 +309,9 @@ let OhLink = class OhLink extends OhElement {
|
|
|
291
309
|
background-color: transparent;
|
|
292
310
|
}
|
|
293
311
|
|
|
294
|
-
:host([inverse])
|
|
312
|
+
:host([inverse])
|
|
313
|
+
.link--inline:focus:not(:focus-visible)
|
|
314
|
+
.link__text::after {
|
|
295
315
|
background: repeating-linear-gradient(
|
|
296
316
|
to right,
|
|
297
317
|
var(--oh-color-text-on-accent) 0,
|
|
@@ -313,7 +333,9 @@ let OhLink = class OhLink extends OhElement {
|
|
|
313
333
|
background-color: transparent;
|
|
314
334
|
}
|
|
315
335
|
|
|
316
|
-
:host([inverse])
|
|
336
|
+
:host([inverse])
|
|
337
|
+
.link--standalone:focus:not(:focus-visible)
|
|
338
|
+
.link__text::after {
|
|
317
339
|
background: repeating-linear-gradient(
|
|
318
340
|
to right,
|
|
319
341
|
var(--oh-color-text-on-accent) 0,
|
|
@@ -343,9 +365,7 @@ let OhLink = class OhLink extends OhElement {
|
|
|
343
365
|
"link--standalone": this.variant === "standalone",
|
|
344
366
|
});
|
|
345
367
|
// Auto-add rel="noopener noreferrer" for external links
|
|
346
|
-
const computedRel = this.target === "_blank" && !this.rel
|
|
347
|
-
? "noopener noreferrer"
|
|
348
|
-
: this.rel;
|
|
368
|
+
const computedRel = this.target === "_blank" && !this.rel ? "noopener noreferrer" : this.rel;
|
|
349
369
|
const isExternal = this.target === "_blank";
|
|
350
370
|
return html `
|
|
351
371
|
<a
|
|
@@ -355,11 +375,36 @@ let OhLink = class OhLink extends OhElement {
|
|
|
355
375
|
rel=${computedRel || nothing}
|
|
356
376
|
>
|
|
357
377
|
<span class="link__text"><slot></slot></span>${isExternal
|
|
358
|
-
? html `<svg
|
|
378
|
+
? html `<svg
|
|
379
|
+
class="link__external"
|
|
380
|
+
viewBox="0 0 20 20"
|
|
381
|
+
fill="currentColor"
|
|
382
|
+
aria-hidden="true"
|
|
383
|
+
>
|
|
384
|
+
<path
|
|
385
|
+
fill-rule="evenodd"
|
|
386
|
+
d="M4.25 5.5a.75.75 0 00-.75.75v8.5c0 .414.336.75.75.75h8.5a.75.75 0 00.75-.75v-4a.75.75 0 011.5 0v4A2.25 2.25 0 0112.75 17h-8.5A2.25 2.25 0 012 14.75v-8.5A2.25 2.25 0 014.25 4h5a.75.75 0 010 1.5h-5z"
|
|
387
|
+
clip-rule="evenodd"
|
|
388
|
+
/>
|
|
389
|
+
<path
|
|
390
|
+
fill-rule="evenodd"
|
|
391
|
+
d="M6.194 12.753a.75.75 0 001.06.053L16.5 4.44v2.81a.75.75 0 001.5 0v-4.5a.75.75 0 00-.75-.75h-4.5a.75.75 0 000 1.5h2.553l-9.056 8.194a.75.75 0 00-.053 1.06z"
|
|
392
|
+
clip-rule="evenodd"
|
|
393
|
+
/></svg
|
|
394
|
+
><span class="visually-hidden">(opens in new tab)</span>`
|
|
359
395
|
: nothing}${this.variant === "standalone" && this.arrow && !isExternal
|
|
360
396
|
? html `
|
|
361
|
-
<svg
|
|
362
|
-
|
|
397
|
+
<svg
|
|
398
|
+
class="link__arrow"
|
|
399
|
+
viewBox="0 0 20 20"
|
|
400
|
+
fill="currentColor"
|
|
401
|
+
aria-hidden="true"
|
|
402
|
+
>
|
|
403
|
+
<path
|
|
404
|
+
fill-rule="evenodd"
|
|
405
|
+
d="M3 10a.75.75 0 01.75-.75h10.638L10.23 5.29a.75.75 0 111.04-1.08l5.5 5.25a.75.75 0 010 1.08l-5.5 5.25a.75.75 0 11-1.04-1.08l4.158-3.96H3.75A.75.75 0 013 10z"
|
|
406
|
+
clip-rule="evenodd"
|
|
407
|
+
/>
|
|
363
408
|
</svg>
|
|
364
409
|
`
|
|
365
410
|
: nothing}
|
package/dist/oh-link.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oh-link.js","sourceRoot":"","sources":["../src/oh-link.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"oh-link.js","sourceRoot":"","sources":["../src/oh-link.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;;;;;;;AAEH,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC5D,O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O,IAAI,CAAA;;gBAEC,WAAW;eACZ,IAAI,CAAC,IAAI;iBACP,IAAI,CAAC,MAAM,IAAI,OAAO;cACzB,WAAW,IAAI,OAAO;;uDAEmB,UAAU;YACvD,CAAC,CAAC,IAAI,CAAA;;;;;;;;;;;;;;;;uEAgBuD;YAC7D,CAAC,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,KAAK,YAAY,IAAI,IAAI,CAAC,KAAK,IAAI,CAAC,UAAU;YACtE,CAAC,CAAC,IAAI,CAAA;;;;;;;;;;;;;aAaH;YACH,CAAC,CAAC,OAAO;;KAEd,CAAC;IACJ,CAAC;;AAzED;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;oCACjB;AAGV;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;sCACf;AAGZ;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;mCAClB;AAGT;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;uCACK;AAGhC;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;qCACd;AAGd;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;uCAC3B;AArTL,MAAM;IADlB,aAAa,CAAC,SAAS,CAAC;GACZ,MAAM,CAgXlB"}
|
package/dist/oh-modal.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* oh-modal
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* An accessible modal dialog with focus trapping.
|
|
5
5
|
*
|
|
6
6
|
* DESIGN DECISIONS:
|
|
7
7
|
* ─────────────────
|
|
8
|
-
* 1.
|
|
8
|
+
* 1. LOOK FROM TOKENS
|
|
9
9
|
* - stroke.control border like other components
|
|
10
|
-
* - Offset shadow
|
|
11
|
-
* -
|
|
10
|
+
* - Offset shadow: elevation.offset.2xl in elevation.color.overlay
|
|
11
|
+
* - Backdrop: modal.overlay
|
|
12
12
|
*
|
|
13
13
|
* 2. ACCESSIBLE
|
|
14
14
|
* - Focus trap when open (focus guards at each end of the dialog)
|
|
@@ -20,15 +20,44 @@
|
|
|
20
20
|
* - Optional heading
|
|
21
21
|
* - Scrollable body content
|
|
22
22
|
* - Optional footer slot for actions
|
|
23
|
-
*
|
|
24
|
-
* @element oh-modal
|
|
25
23
|
*/
|
|
26
24
|
import { OhElement } from "./base.js";
|
|
27
25
|
export type ModalSize = "sm" | "md" | "lg";
|
|
26
|
+
/**
|
|
27
|
+
* A dialog that opens over the page and holds the user's attention until they close it or act on it.
|
|
28
|
+
*
|
|
29
|
+
* **Use it for** a short task or decision that must be done before going on: a confirmation, a small form. **Don't use it for** content the user may want alongside the page (use `oh-drawer`); for a message that doesn't need an answer (use `oh-alert`); or for long, multi-step flows (use a page).
|
|
30
|
+
*
|
|
31
|
+
* **Parts:** `heading` (a visible `h2`); the default slot for the body, which scrolls when it's taller than the viewport; the `footer` slot for actions.
|
|
32
|
+
*
|
|
33
|
+
* **Sizes:** `sm`, `md` (default) and `lg` set the dialog's width (never wider than the viewport).
|
|
34
|
+
*
|
|
35
|
+
* **Behaviour:** set `open` to show it. On open, focus moves to the Close button (or the first focusable element when there's none), Tab and Shift+Tab wrap inside the dialog, and the page behind stops scrolling. On close, focus returns to the element that had it. With `dismissible` (the default), the Close button, Escape and a click on the backdrop each fire `oh-close` and set `open` to false; without it, only your own buttons close it. Motion is reduced under `prefers-reduced-motion`.
|
|
36
|
+
*
|
|
37
|
+
* **Accessibility:** the panel is `role="dialog"` with `aria-modal="true"`, named by `heading`. Without a visible heading, set `accessible-label` (not `aria-label` on the host, which isn't forwarded). The close button has a visible "Close" label.
|
|
38
|
+
*
|
|
39
|
+
* **Look:** set by tokens. `modal.overlay` sets the backdrop; the panel uses `color.surface.base`, a `stroke.control` border in `color.border.emphasis`, `shape.container` corners and an `elevation.offset.2xl` shadow in `elevation.color.overlay`. Header and footer dividers use `stroke.control` in `color.border.subtle`; the title uses `typography.heading.h4.*`, the body `typography.body.*`. The close button uses `closeButton.*`, `lift.*` and `shape.compact`. Motion uses `motion.gentle` and `motion.easeEmphasized`.
|
|
40
|
+
*
|
|
41
|
+
* @element oh-modal
|
|
42
|
+
* @slot - The dialog body.
|
|
43
|
+
* @slot footer - Actions, below the body.
|
|
44
|
+
* @csspart modal - The dialog panel.
|
|
45
|
+
* @csspart header - The header (heading and close button).
|
|
46
|
+
* @csspart close - The close button (only when `dismissible`).
|
|
47
|
+
* @csspart body - The scrolling body.
|
|
48
|
+
* @csspart footer - The footer.
|
|
49
|
+
* @fires oh-close - When the user closes the dialog with the Close button, Escape or the backdrop. Not fired when you set `open` to false yourself.
|
|
50
|
+
*/
|
|
28
51
|
export declare class OhModal extends OhElement {
|
|
29
52
|
static styles: import("lit").CSSResult[];
|
|
30
53
|
open: boolean;
|
|
31
54
|
heading: string;
|
|
55
|
+
/**
|
|
56
|
+
* Names the dialog when it has no visible heading. Use this rather than
|
|
57
|
+
* aria-label on the host, which isn't forwarded into the shadow root.
|
|
58
|
+
* A visible heading always wins.
|
|
59
|
+
*/
|
|
60
|
+
accessibleLabel?: string;
|
|
32
61
|
dismissible: boolean;
|
|
33
62
|
size: ModalSize;
|
|
34
63
|
private _previousActiveElement;
|
package/dist/oh-modal.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oh-modal.d.ts","sourceRoot":"","sources":["../src/oh-modal.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"oh-modal.d.ts","sourceRoot":"","sources":["../src/oh-modal.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAIH,OAAO,EAAE,SAAS,EAAc,MAAM,WAAW,CAAC;AAGlD,MAAM,MAAM,SAAS,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAE3C;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,qBACa,OAAQ,SAAQ,SAAS;IACpC,OAAgB,MAAM,4BA8OpB;IAGF,IAAI,UAAS;IAGb,OAAO,SAAM;IAEb;;;;OAIG;IAEH,eAAe,CAAC,EAAE,MAAM,CAAC;IAGzB,WAAW,UAAQ;IAGnB,IAAI,EAAE,SAAS,CAAQ;IAGvB,OAAO,CAAC,sBAAsB,CAA4B;IAG1D,OAAO,CAAC,YAAY,CAAqB;IAEzC,iBAAiB;IAKjB,OAAO,CAAC,iBAAiB,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC;IAU/C,OAAO,CAAC,OAAO;IAyBf,OAAO,CAAC,QAAQ;IAchB,OAAO,CAAC,cAAc;IAOtB,4EAA4E;IAC5E,OAAO,CAAC,qBAAqB;IAS7B;;;;OAIG;IACH,OAAO,CAAC,UAAU;IAKlB,OAAO,CAAC,kBAAkB;IAO1B,OAAO,CAAC,oBAAoB;IAM5B,OAAO,CAAC,aAAa;IAKrB,oBAAoB;IAMpB,MAAM;CAqFP;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,UAAU,EAAE,OAAO,CAAC;KACrB;CACF"}
|
package/dist/oh-modal.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* oh-modal
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* An accessible modal dialog with focus trapping.
|
|
5
5
|
*
|
|
6
6
|
* DESIGN DECISIONS:
|
|
7
7
|
* ─────────────────
|
|
8
|
-
* 1.
|
|
8
|
+
* 1. LOOK FROM TOKENS
|
|
9
9
|
* - stroke.control border like other components
|
|
10
|
-
* - Offset shadow
|
|
11
|
-
* -
|
|
10
|
+
* - Offset shadow: elevation.offset.2xl in elevation.color.overlay
|
|
11
|
+
* - Backdrop: modal.overlay
|
|
12
12
|
*
|
|
13
13
|
* 2. ACCESSIBLE
|
|
14
14
|
* - Focus trap when open (focus guards at each end of the dialog)
|
|
@@ -20,8 +20,6 @@
|
|
|
20
20
|
* - Optional heading
|
|
21
21
|
* - Scrollable body content
|
|
22
22
|
* - Optional footer slot for actions
|
|
23
|
-
*
|
|
24
|
-
* @element oh-modal
|
|
25
23
|
*/
|
|
26
24
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
27
25
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -33,6 +31,31 @@ import { html, css, nothing } from "lit";
|
|
|
33
31
|
import { customElement, property, query, state } from "lit/decorators.js";
|
|
34
32
|
import { OhElement, baseStyles } from "./base.js";
|
|
35
33
|
import { getFocusableElementsDeep } from "@orange-halo/utils";
|
|
34
|
+
/**
|
|
35
|
+
* A dialog that opens over the page and holds the user's attention until they close it or act on it.
|
|
36
|
+
*
|
|
37
|
+
* **Use it for** a short task or decision that must be done before going on: a confirmation, a small form. **Don't use it for** content the user may want alongside the page (use `oh-drawer`); for a message that doesn't need an answer (use `oh-alert`); or for long, multi-step flows (use a page).
|
|
38
|
+
*
|
|
39
|
+
* **Parts:** `heading` (a visible `h2`); the default slot for the body, which scrolls when it's taller than the viewport; the `footer` slot for actions.
|
|
40
|
+
*
|
|
41
|
+
* **Sizes:** `sm`, `md` (default) and `lg` set the dialog's width (never wider than the viewport).
|
|
42
|
+
*
|
|
43
|
+
* **Behaviour:** set `open` to show it. On open, focus moves to the Close button (or the first focusable element when there's none), Tab and Shift+Tab wrap inside the dialog, and the page behind stops scrolling. On close, focus returns to the element that had it. With `dismissible` (the default), the Close button, Escape and a click on the backdrop each fire `oh-close` and set `open` to false; without it, only your own buttons close it. Motion is reduced under `prefers-reduced-motion`.
|
|
44
|
+
*
|
|
45
|
+
* **Accessibility:** the panel is `role="dialog"` with `aria-modal="true"`, named by `heading`. Without a visible heading, set `accessible-label` (not `aria-label` on the host, which isn't forwarded). The close button has a visible "Close" label.
|
|
46
|
+
*
|
|
47
|
+
* **Look:** set by tokens. `modal.overlay` sets the backdrop; the panel uses `color.surface.base`, a `stroke.control` border in `color.border.emphasis`, `shape.container` corners and an `elevation.offset.2xl` shadow in `elevation.color.overlay`. Header and footer dividers use `stroke.control` in `color.border.subtle`; the title uses `typography.heading.h4.*`, the body `typography.body.*`. The close button uses `closeButton.*`, `lift.*` and `shape.compact`. Motion uses `motion.gentle` and `motion.easeEmphasized`.
|
|
48
|
+
*
|
|
49
|
+
* @element oh-modal
|
|
50
|
+
* @slot - The dialog body.
|
|
51
|
+
* @slot footer - Actions, below the body.
|
|
52
|
+
* @csspart modal - The dialog panel.
|
|
53
|
+
* @csspart header - The header (heading and close button).
|
|
54
|
+
* @csspart close - The close button (only when `dismissible`).
|
|
55
|
+
* @csspart body - The scrolling body.
|
|
56
|
+
* @csspart footer - The footer.
|
|
57
|
+
* @fires oh-close - When the user closes the dialog with the Close button, Escape or the backdrop. Not fired when you set `open` to false yourself.
|
|
58
|
+
*/
|
|
36
59
|
let OhModal = class OhModal extends OhElement {
|
|
37
60
|
constructor() {
|
|
38
61
|
super(...arguments);
|
|
@@ -46,8 +69,8 @@ let OhModal = class OhModal extends OhElement {
|
|
|
46
69
|
baseStyles,
|
|
47
70
|
css `
|
|
48
71
|
/* ═══════════════════════════════════════════════════════════════
|
|
49
|
-
|
|
50
|
-
|
|
72
|
+
MODAL
|
|
73
|
+
Focus-trapped • Accessible
|
|
51
74
|
═══════════════════════════════════════════════════════════════ */
|
|
52
75
|
|
|
53
76
|
:host {
|
|
@@ -62,16 +85,16 @@ let OhModal = class OhModal extends OhElement {
|
|
|
62
85
|
position: fixed;
|
|
63
86
|
inset: 0;
|
|
64
87
|
z-index: 1000;
|
|
65
|
-
|
|
66
|
-
/*
|
|
88
|
+
|
|
89
|
+
/* Overlay: modal.overlay */
|
|
67
90
|
background-color: var(--oh-modal-overlay);
|
|
68
|
-
|
|
91
|
+
|
|
69
92
|
/* Flexbox centering */
|
|
70
93
|
display: flex;
|
|
71
94
|
align-items: center;
|
|
72
95
|
justify-content: center;
|
|
73
96
|
padding: var(--oh-spacing-4);
|
|
74
|
-
|
|
97
|
+
|
|
75
98
|
/* Animation. Closing: fade, then hide once the fade ends. */
|
|
76
99
|
opacity: 0;
|
|
77
100
|
visibility: hidden;
|
|
@@ -100,22 +123,21 @@ let OhModal = class OhModal extends OhElement {
|
|
|
100
123
|
flex-direction: column;
|
|
101
124
|
max-height: calc(100vh - var(--oh-spacing-8));
|
|
102
125
|
max-width: 100%;
|
|
103
|
-
|
|
104
|
-
/* Warm surface */
|
|
126
|
+
|
|
105
127
|
background-color: var(--oh-color-surface-base);
|
|
106
|
-
|
|
107
|
-
/* Chunky border */
|
|
128
|
+
|
|
108
129
|
border: var(--oh-stroke-control) solid var(--oh-color-border-emphasis);
|
|
109
130
|
border-radius: var(--oh-shape-container);
|
|
110
|
-
|
|
111
|
-
/* Offset shadow
|
|
112
|
-
box-shadow: var(--oh-elevation-offset-2xl)
|
|
113
|
-
|
|
131
|
+
|
|
132
|
+
/* Offset shadow: elevation.offset.2xl */
|
|
133
|
+
box-shadow: var(--oh-elevation-offset-2xl)
|
|
134
|
+
var(--oh-elevation-offset-2xl) 0 0 var(--oh-elevation-color-overlay);
|
|
135
|
+
|
|
114
136
|
/* Animation */
|
|
115
137
|
transform: scale(0.95) translateY(10px);
|
|
116
138
|
opacity: 0;
|
|
117
|
-
transition:
|
|
118
|
-
transform var(--oh-motion-gentle) var(--oh-motion-ease-
|
|
139
|
+
transition:
|
|
140
|
+
transform var(--oh-motion-gentle) var(--oh-motion-ease-emphasized),
|
|
119
141
|
opacity var(--oh-motion-gentle) ease;
|
|
120
142
|
}
|
|
121
143
|
|
|
@@ -147,7 +169,8 @@ let OhModal = class OhModal extends OhElement {
|
|
|
147
169
|
justify-content: space-between;
|
|
148
170
|
gap: var(--oh-spacing-4);
|
|
149
171
|
padding: var(--oh-spacing-4) var(--oh-spacing-5);
|
|
150
|
-
border-bottom: var(--oh-stroke-control) solid
|
|
172
|
+
border-bottom: var(--oh-stroke-control) solid
|
|
173
|
+
var(--oh-color-border-subtle);
|
|
151
174
|
}
|
|
152
175
|
|
|
153
176
|
.modal-title {
|
|
@@ -168,34 +191,36 @@ let OhModal = class OhModal extends OhElement {
|
|
|
168
191
|
display: flex;
|
|
169
192
|
align-items: center;
|
|
170
193
|
gap: var(--oh-spacing-1);
|
|
171
|
-
|
|
194
|
+
|
|
172
195
|
padding: var(--oh-spacing-1) var(--oh-spacing-2);
|
|
173
|
-
|
|
196
|
+
|
|
174
197
|
font-family: var(--oh-typography-body-font-family);
|
|
175
198
|
font-size: var(--oh-typography-body-base-font-size);
|
|
176
199
|
font-weight: var(--oh-typography-label-base-font-weight);
|
|
177
|
-
|
|
200
|
+
|
|
178
201
|
background: transparent;
|
|
179
202
|
border: none;
|
|
180
203
|
border-radius: var(--oh-shape-compact);
|
|
181
204
|
cursor: pointer;
|
|
182
205
|
color: var(--oh-color-text-primary);
|
|
183
|
-
|
|
184
|
-
transition:
|
|
185
|
-
transform var(--oh-motion-snappy) var(--oh-motion-ease-
|
|
186
|
-
box-shadow var(--oh-motion-snappy) var(--oh-motion-ease-
|
|
206
|
+
|
|
207
|
+
transition:
|
|
208
|
+
transform var(--oh-motion-snappy) var(--oh-motion-ease-emphasized),
|
|
209
|
+
box-shadow var(--oh-motion-snappy) var(--oh-motion-ease-emphasized),
|
|
187
210
|
background-color var(--oh-motion-quick) ease;
|
|
188
211
|
}
|
|
189
212
|
|
|
190
213
|
.modal-close:hover {
|
|
191
214
|
background-color: var(--oh-close-button-background-hover);
|
|
192
215
|
transform: translate(var(--oh-lift-hover-md), var(--oh-lift-hover-md));
|
|
193
|
-
box-shadow: var(--oh-elevation-offset-lg) var(--oh-elevation-offset-lg)
|
|
216
|
+
box-shadow: var(--oh-elevation-offset-lg) var(--oh-elevation-offset-lg)
|
|
217
|
+
0 0 var(--oh-close-button-shadow-hover);
|
|
194
218
|
}
|
|
195
219
|
|
|
196
220
|
.modal-close:active {
|
|
197
221
|
transform: translate(var(--oh-lift-press-sm), var(--oh-lift-press-sm));
|
|
198
|
-
box-shadow: var(--oh-elevation-offset-xs) var(--oh-elevation-offset-xs)
|
|
222
|
+
box-shadow: var(--oh-elevation-offset-xs) var(--oh-elevation-offset-xs)
|
|
223
|
+
0 0 var(--oh-close-button-shadow-hover);
|
|
199
224
|
}
|
|
200
225
|
|
|
201
226
|
.modal-close:focus-visible {
|
|
@@ -217,7 +242,7 @@ let OhModal = class OhModal extends OhElement {
|
|
|
217
242
|
flex: 1;
|
|
218
243
|
overflow-y: auto;
|
|
219
244
|
padding: var(--oh-spacing-5);
|
|
220
|
-
|
|
245
|
+
|
|
221
246
|
font-family: var(--oh-typography-body-font-family);
|
|
222
247
|
font-size: var(--oh-typography-body-base-font-size);
|
|
223
248
|
line-height: var(--oh-typography-body-base-line-height);
|
|
@@ -335,7 +360,9 @@ let OhModal = class OhModal extends OhElement {
|
|
|
335
360
|
/** Focusable elements in the dialog, in tab order, excluding the guards. */
|
|
336
361
|
_getFocusableElements() {
|
|
337
362
|
const dialog = this.renderRoot.querySelector(".modal");
|
|
338
|
-
return dialog
|
|
363
|
+
return dialog
|
|
364
|
+
? getFocusableElementsDeep(dialog).filter((el) => !el.classList.contains("focus-guard"))
|
|
365
|
+
: [];
|
|
339
366
|
}
|
|
340
367
|
/**
|
|
341
368
|
* Focus guards: Tab past the last control lands on the end guard, which
|
|
@@ -387,14 +414,23 @@ let OhModal = class OhModal extends OhElement {
|
|
|
387
414
|
role="dialog"
|
|
388
415
|
aria-modal="true"
|
|
389
416
|
aria-labelledby=${labelId || nothing}
|
|
417
|
+
aria-label=${!labelId && this.accessibleLabel
|
|
418
|
+
? this.accessibleLabel
|
|
419
|
+
: nothing}
|
|
390
420
|
part="modal"
|
|
391
421
|
>
|
|
392
|
-
<span
|
|
422
|
+
<span
|
|
423
|
+
class="focus-guard"
|
|
424
|
+
tabindex="0"
|
|
425
|
+
@focus=${() => this._focusEdge("last")}
|
|
426
|
+
></span>
|
|
393
427
|
${this.heading || this.dismissible
|
|
394
428
|
? html `
|
|
395
429
|
<header class="modal-header" part="header">
|
|
396
430
|
${this.heading
|
|
397
|
-
? html `<h2 id="modal-title" class="modal-title"
|
|
431
|
+
? html `<h2 id="modal-title" class="modal-title">
|
|
432
|
+
${this.heading}
|
|
433
|
+
</h2>`
|
|
398
434
|
: html `<span></span>`}
|
|
399
435
|
${this.dismissible
|
|
400
436
|
? html `
|
|
@@ -405,8 +441,16 @@ let OhModal = class OhModal extends OhElement {
|
|
|
405
441
|
part="close"
|
|
406
442
|
>
|
|
407
443
|
<span>Close</span>
|
|
408
|
-
<svg
|
|
409
|
-
|
|
444
|
+
<svg
|
|
445
|
+
viewBox="0 0 20 20"
|
|
446
|
+
fill="currentColor"
|
|
447
|
+
aria-hidden="true"
|
|
448
|
+
>
|
|
449
|
+
<path
|
|
450
|
+
fill-rule="evenodd"
|
|
451
|
+
d="M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z"
|
|
452
|
+
clip-rule="evenodd"
|
|
453
|
+
/>
|
|
410
454
|
</svg>
|
|
411
455
|
</button>
|
|
412
456
|
`
|
|
@@ -422,7 +466,11 @@ let OhModal = class OhModal extends OhElement {
|
|
|
422
466
|
<footer class="modal-footer" part="footer">
|
|
423
467
|
<slot name="footer"></slot>
|
|
424
468
|
</footer>
|
|
425
|
-
<span
|
|
469
|
+
<span
|
|
470
|
+
class="focus-guard"
|
|
471
|
+
tabindex="0"
|
|
472
|
+
@focus=${() => this._focusEdge("first")}
|
|
473
|
+
></span>
|
|
426
474
|
</div>
|
|
427
475
|
</div>
|
|
428
476
|
`;
|
|
@@ -434,6 +482,9 @@ __decorate([
|
|
|
434
482
|
__decorate([
|
|
435
483
|
property({ type: String })
|
|
436
484
|
], OhModal.prototype, "heading", void 0);
|
|
485
|
+
__decorate([
|
|
486
|
+
property({ type: String, attribute: "accessible-label" })
|
|
487
|
+
], OhModal.prototype, "accessibleLabel", void 0);
|
|
437
488
|
__decorate([
|
|
438
489
|
property({ type: Boolean, reflect: true })
|
|
439
490
|
], OhModal.prototype, "dismissible", void 0);
|
package/dist/oh-modal.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oh-modal.js","sourceRoot":"","sources":["../src/oh-modal.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"oh-modal.js","sourceRoot":"","sources":["../src/oh-modal.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;;;;;;;AAEH,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1E,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAClD,OAAO,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAI9D;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEI,IAAM,OAAO,GAAb,MAAM,OAAQ,SAAQ,SAAS;IAA/B;;QAkPL,SAAI,GAAG,KAAK,CAAC;QAGb,YAAO,GAAG,EAAE,CAAC;QAWb,gBAAW,GAAG,IAAI,CAAC;QAGnB,SAAI,GAAc,IAAI,CAAC;QAGf,2BAAsB,GAAuB,IAAI,CAAC;IAmM5D,CAAC;aAxciB,WAAM,GAAG;QACvB,UAAU;QACV,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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
|
4
|
-
* A responsive navigation bar component with logo, links, and mobile drawer.
|
|
5
|
-
*
|
|
6
4
|
* DESIGN DECISIONS:
|
|
7
5
|
* ─────────────────
|
|
8
6
|
* 1. LAYOUT
|
|
9
|
-
* - Logo on the left
|
|
10
|
-
*
|
|
11
|
-
* -
|
|
12
|
-
*
|
|
13
|
-
* 2. STYLING
|
|
14
|
-
* - Surface base background
|
|
15
|
-
* - Chunky bottom border
|
|
16
|
-
* - Links use oh-link styling
|
|
17
|
-
*
|
|
18
|
-
* 3. RESPONSIVE
|
|
19
|
-
* - Desktop: horizontal links
|
|
20
|
-
* - Mobile (< 768px): hamburger + drawer
|
|
21
|
-
*
|
|
22
|
-
* @element oh-navbar
|
|
7
|
+
* - Logo on the left, links pushed to the right, inside an
|
|
8
|
+
* oh-container (size lg)
|
|
9
|
+
* - At and below `size.breakpoint.md` the links hide and a menu button
|
|
10
|
+
* opens an oh-drawer from the left
|
|
23
11
|
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
12
|
+
* 2. DRAWER LINKS ARE A SEPARATE SLOT
|
|
13
|
+
* - The drawer lives outside the bar, so links for it are passed again
|
|
14
|
+
* in the `mobile` slot
|
|
26
15
|
*
|
|
27
|
-
*
|
|
16
|
+
* 3. LOOK FROM TOKENS
|
|
17
|
+
* - `color.surface.base` background, a shadow in `focus.glowColor`,
|
|
18
|
+
* `stroke.divider` / `color.border.subtle` between drawer links
|
|
28
19
|
*/
|
|
29
20
|
import { OhElement } from "./base.js";
|
|
30
21
|
import "./oh-container.js";
|
|
@@ -32,6 +23,38 @@ import "./oh-cluster.js";
|
|
|
32
23
|
import "./oh-drawer.js";
|
|
33
24
|
import "./oh-button.js";
|
|
34
25
|
import "./oh-icon.js";
|
|
26
|
+
/**
|
|
27
|
+
* A site header bar with a logo and the site's main navigation links, which move into a drawer on narrow viewports.
|
|
28
|
+
*
|
|
29
|
+
* **Use it for** the main navigation at the top of every page. **Don't use
|
|
30
|
+
* it for** in-page sections (use `oh-tabs`) or a trail through the hierarchy
|
|
31
|
+
* (use `oh-breadcrumb`).
|
|
32
|
+
*
|
|
33
|
+
* **Parts:** the `logo` slot (a link to the home page), the default slot for
|
|
34
|
+
* the bar's links (`oh-link`), and the `mobile` slot for the same links in the
|
|
35
|
+
* drawer. `drawer-heading` names the drawer (defaults to "Menu").
|
|
36
|
+
*
|
|
37
|
+
* **Behaviour:** at and below the `size.breakpoint.md` width the links hide
|
|
38
|
+
* and an icon-only menu button ("Open navigation menu") opens an `oh-drawer`
|
|
39
|
+
* from the left, which traps focus and closes on Escape or its close button.
|
|
40
|
+
*
|
|
41
|
+
* **Accessibility:** the bar and the drawer each wrap their links in a
|
|
42
|
+
* `<nav>`; the drawer is a modal dialog. Give the logo link an accessible
|
|
43
|
+
* name (`alt` on its image, or text).
|
|
44
|
+
*
|
|
45
|
+
* **Look:** set by tokens — `color.surface.base` the background,
|
|
46
|
+
* `focus.glowColor` the shadow, `typography.body.*` the text, `spacing.*` the
|
|
47
|
+
* padding and gaps, `stroke.divider` and `color.border.subtle` the dividers
|
|
48
|
+
* between drawer links. `--oh-navbar-logo-height` sets the logo height.
|
|
49
|
+
*
|
|
50
|
+
* @element oh-navbar
|
|
51
|
+
*
|
|
52
|
+
* @slot logo - Slot for logo/brand element
|
|
53
|
+
* @slot - Default slot for navigation links
|
|
54
|
+
* @slot mobile - The navigation links again, shown in the drawer
|
|
55
|
+
*
|
|
56
|
+
* @cssprop --oh-navbar-logo-height - Height of the slotted logo link or image
|
|
57
|
+
*/
|
|
35
58
|
export declare class OhNavbar extends OhElement {
|
|
36
59
|
static styles: import("lit").CSSResult[];
|
|
37
60
|
/** Heading shown in the mobile drawer */
|