@repobit/dex-system-design 2.5.1 → 2.7.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/CHANGELOG.md +91 -0
- package/README.md +2 -1
- package/package.json +14 -27
- package/schemas/component-manifest.json +233 -33
- package/schemas/manifest-omissions.json +23 -0
- package/src/components/accordion/accordion-bg.css.js +39 -30
- package/src/components/accordion/accordion-bg.js +17 -28
- package/src/components/accordion/accordion-bg.stories.js +5 -0
- package/src/components/accordion/accordion-panel.js +24 -0
- package/src/components/accordion/accordion.css.js +105 -111
- package/src/components/accordion/accordion.js +23 -37
- package/src/components/accordion/accordion.stories.js +5 -1
- package/src/components/anchor/anchor-nav.css.js +131 -53
- package/src/components/anchor/anchor-nav.js +276 -201
- package/src/components/annotation/annotation.css.js +7 -4
- package/src/components/architecture.stories.js +8 -7
- package/src/components/audience-card/audience-card.css.js +30 -4
- package/src/components/audience-card/audience-card.js +8 -13
- package/src/components/awards/awards-flex.css.js +23 -6
- package/src/components/awards/awards-flex.js +21 -6
- package/src/components/awards/awards-spotlight.css.js +25 -5
- package/src/components/awards/awards-spotlight.js +19 -7
- package/src/components/awards/awards.css.js +20 -8
- package/src/components/awards/awards.js +30 -91
- package/src/components/awards/awards.stories.js +5 -5
- package/src/components/awards/scroll-slides.js +128 -0
- package/src/components/back/back.css.js +2 -0
- package/src/components/badge/badge.css.js +15 -0
- package/src/components/bento-grid/bento-grid.css.js +105 -11
- package/src/components/bento-grid/bento-grid.js +37 -124
- package/src/components/bento-grid/bento-grid.stories.js +3 -2
- package/src/components/bento-grid/bento-item.css.js +71 -32
- package/src/components/bento-grid/bento-item.js +1 -30
- package/src/components/blockquote/blockquote.css.js +2 -2
- package/src/components/breadcrumb/breadcrumb.css.js +10 -9
- package/src/components/breadcrumb/breadcrumb.js +35 -34
- package/src/components/button/button.css.js +42 -17
- package/src/components/button/button.js +84 -3
- package/src/components/button/button.stories.js +17 -0
- package/src/components/card-features/card-features.css.js +23 -2
- package/src/components/card-features/card-features.js +6 -48
- package/src/components/cards/card.css.js +43 -14
- package/src/components/cards/card.js +43 -177
- package/src/components/cards/card.stories.js +8 -10
- package/src/components/carousel/carousel.css.js +101 -70
- package/src/components/carousel/carousel.js +107 -71
- package/src/components/carousel/carousel.stories.js +18 -16
- package/src/components/checkbox/checkbox.css.js +26 -9
- package/src/components/checkbox/checkbox.js +73 -39
- package/src/components/checkbox/checkbox.stories.js +35 -18
- package/src/components/compare/compare.css.js +68 -10
- package/src/components/compare/compare.js +40 -103
- package/src/components/compare/compare.stories.js +1 -1
- package/src/components/compatibility-table/compatibility-table.css.js +70 -37
- package/src/components/compatibility-table/compatibility-table.js +47 -40
- package/src/components/compatibility-table/compatibility-table.stories.js +78 -1
- package/src/components/display/display.css.js +7 -0
- package/src/components/dropdown/dropdown.css.js +20 -3
- package/src/components/dropdown/dropdown.js +57 -21
- package/src/components/dropdown/dropdown.stories.js +31 -9
- package/src/components/features/features.css.js +56 -21
- package/src/components/features/features.js +7 -117
- package/src/components/fieldset/fieldset.stories.js +68 -0
- package/src/components/footer/footer-images.js +34 -0
- package/src/components/footer/footer-links-group.css.js +10 -10
- package/src/components/footer/footer-locale.js +47 -0
- package/src/components/footer/footer-lp.js +27 -114
- package/src/components/footer/footer-lp.stories.js +2 -2
- package/src/components/footer/footer-nav-menu.css.js +2 -2
- package/src/components/footer/footer-nav-menu.js +8 -3
- package/src/components/footer/footer.css.js +228 -197
- package/src/components/footer/footer.js +109 -187
- package/src/components/footer/footer.stories.js +14 -4
- package/src/components/grid/grid.css.js +56 -20
- package/src/components/grid/grid.js +20 -15
- package/src/components/grid/grid.stories.js +39 -11
- package/src/components/header/header-code.css.js +20 -11
- package/src/components/header/header-code.js +1 -1
- package/src/components/header/header.css.js +20 -14
- package/src/components/header/header.js +6 -7
- package/src/components/header/header.stories.js +29 -24
- package/src/components/heading/heading.css.js +11 -0
- package/src/components/hero/hero.js +10 -2
- package/src/components/highlight/highlight.css.js +30 -6
- package/src/components/icons/arrow-icon.js +4 -1
- package/src/components/icons/arrow-right-icon.js +5 -1
- package/src/components/icons/icon-element.js +18 -0
- package/src/components/image/image.js +29 -9
- package/src/components/image/image.stories.js +38 -2
- package/src/components/input/custom-form.stories.js +38 -7
- package/src/components/input/input-clipboard.css.js +15 -1
- package/src/components/input/input-clipboard.js +84 -21
- package/src/components/input/input.js +27 -7
- package/src/components/install-options/install-options.css.js +26 -6
- package/src/components/install-options/install-options.js +32 -8
- package/src/components/label/label.css.js +1 -1
- package/src/components/light-carousel/light-carousel.css.js +100 -48
- package/src/components/light-carousel/light-carousel.js +43 -5
- package/src/components/link/link.css.js +15 -15
- package/src/components/link/link.js +17 -1
- package/src/components/link/link.stories.js +20 -7
- package/src/components/list/list.css.js +3 -3
- package/src/components/logo-marquee/logo-marquee.css.js +12 -1
- package/src/components/logo-marquee/logo-marquee.js +33 -8
- package/src/components/logo-marquee/logo-marquee.stories.js +10 -4
- package/src/components/modal/modal.css.js +74 -40
- package/src/components/modal/modal.js +85 -74
- package/src/components/modal/modal.stories.js +27 -14
- package/src/components/motion-art/motion-art.js +67 -1
- package/src/components/page-switcher/page-switcher.css.js +27 -9
- package/src/components/page-switcher/page-switcher.js +11 -8
- package/src/components/partner-banner/partner-banner.css.js +2 -0
- package/src/components/picture/picture.css.js +4 -4
- package/src/components/picture/picture.js +13 -3
- package/src/components/picture/picture.stories.js +28 -2
- package/src/components/post-card/post-card.css.js +18 -3
- package/src/components/pricing-cards/adopt-styles.js +16 -0
- package/src/components/pricing-cards/new-pricing-card.js +2 -4
- package/src/components/pricing-cards/new-pricing-card.stories.js +20 -22
- package/src/components/pricing-cards/pricing-card-actions.css.js +8 -12
- package/src/components/pricing-cards/pricing-card-actions.js +26 -13
- package/src/components/pricing-cards/pricing-card-container.css.js +4 -3
- package/src/components/pricing-cards/pricing-card-container.js +10 -4
- package/src/components/pricing-cards/pricing-card-header.css.js +5 -4
- package/src/components/pricing-cards/pricing-card-header.js +18 -31
- package/src/components/pricing-cards/pricing-card-pricing.css.js +84 -61
- package/src/components/pricing-cards/pricing-card-pricing.js +38 -24
- package/src/components/pricing-cards/pricing-card-show-more.js +8 -3
- package/src/components/pricing-cards/pricing-card.css.js +75 -41
- package/src/components/pricing-cards/pricing-card.js +356 -308
- package/src/components/progress/progress.css.js +58 -13
- package/src/components/progress/progress.js +13 -10
- package/src/components/progress/progress.stories.js +9 -7
- package/src/components/radio/radio-group.css.js +42 -0
- package/src/components/radio/radio-group.js +89 -0
- package/src/components/radio/radio.css.js +63 -6
- package/src/components/radio/radio.js +173 -140
- package/src/components/radio/radio.stories.js +99 -44
- package/src/components/radio/toggle-radio.js +44 -0
- package/src/components/review/review-grid.css.js +5 -1
- package/src/components/review/review-grid.js +2 -0
- package/src/components/review/review.js +13 -0
- package/src/components/shared/announcer.js +37 -0
- package/src/components/shared/fill-width.css.js +29 -0
- package/src/components/shared/form-control.js +194 -0
- package/src/components/shared/form-field.css.js +31 -3
- package/src/components/shared/token-scales.js +75 -26
- package/src/components/spotlight-section/spotlight-section.js +2 -2
- package/src/components/stat/stat-highlight.js +1 -1
- package/src/components/stat/stat.css.js +18 -3
- package/src/components/switch/switch.css.js +58 -5
- package/src/components/switch/switch.js +53 -5
- package/src/components/switch/switch.stories.js +30 -8
- package/src/components/tab-list/tab-list.css.js +51 -13
- package/src/components/tab-list/tab-list.js +7 -2
- package/src/components/tab-list/tab-list.stories.js +2 -2
- package/src/components/tabs/tabs.css.js +18 -1
- package/src/components/tabs/tabs.js +119 -41
- package/src/components/terminal/terminal-message.css.js +6 -1
- package/src/components/termsOfUse/terms.css.js +4 -2
- package/src/components/textarea/textarea.js +22 -7
- package/src/components/textarea/textarea.stories.js +12 -9
- package/src/components/trust-panel/trust-panel.css.js +13 -3
- package/src/components/ultimate-security-demo.stories.js +5 -5
- package/src/components/video/video.css.js +5 -0
- package/src/components/video/video.js +5 -0
- package/src/components/video/video.stories.js +12 -0
- package/src/components/video-player/video-player.css.js +20 -8
- package/src/components/video-player/video-player.js +74 -20
- package/src/components/video-player/video-player.stories.js +17 -3
- package/src/tokens/brands.stories.js +1 -1
- package/src/tokens/themes/index.js +2 -2
- package/src/tokens/typography.stories.js +4 -3
- package/src/vendor/motion-art/README.md +4 -1
- package/src/components/footer/footer-lp.css.js +0 -159
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { LitElement, html } from "lit";
|
|
2
2
|
import { tokens } from "../../tokens/tokens.js";
|
|
3
|
+
import "../button/button.js";
|
|
4
|
+
import "../icons/pause-icon.js";
|
|
5
|
+
import "../icons/play-icon.js";
|
|
3
6
|
import { ensembleCSS } from "../shared/ensemble.css.js";
|
|
4
7
|
import { spacing } from "../shared/token-scales.js";
|
|
5
8
|
import { logoMarqueeCSS } from "./logo-marquee.css.js";
|
|
@@ -16,17 +19,23 @@ import { logoMarqueeCSS } from "./logo-marquee.css.js";
|
|
|
16
19
|
* by one copy -- the jump back is then exactly one repeat, and invisible. The
|
|
17
20
|
* copies are aria-hidden and inert: a screen reader reads the set once.
|
|
18
21
|
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
+
* It moves on its own for longer than five seconds, so it has a pause button
|
|
23
|
+
* (WCAG 2.2.2): holding it on hover or focus was not enough, because the
|
|
24
|
+
* logos are usually images and nothing in the row takes focus. The button
|
|
25
|
+
* sets `paused`, which a page can also set. The pointer or focus on the row
|
|
26
|
+
* still holds it. Under prefers-reduced-motion it never moves -- the set
|
|
27
|
+
* wraps in place instead, so nothing is hidden behind the fade -- and the
|
|
28
|
+
* button goes with the motion.
|
|
22
29
|
*/
|
|
23
30
|
export class LogoMarquee extends LitElement {
|
|
24
31
|
static properties = {
|
|
25
|
-
label
|
|
26
|
-
duration: { type: Number },
|
|
27
|
-
gap
|
|
28
|
-
paused
|
|
29
|
-
|
|
32
|
+
label : { type: String },
|
|
33
|
+
duration : { type: Number },
|
|
34
|
+
gap : { type: String },
|
|
35
|
+
paused : { type: Boolean, reflect: true },
|
|
36
|
+
pauseLabel: { type: String, attribute: "pause-label" },
|
|
37
|
+
playLabel : { type: String, attribute: "play-label" },
|
|
38
|
+
_copies : { state: true }
|
|
30
39
|
};
|
|
31
40
|
|
|
32
41
|
static styles = [tokens, ensembleCSS, logoMarqueeCSS];
|
|
@@ -39,6 +48,8 @@ export class LogoMarquee extends LitElement {
|
|
|
39
48
|
// a step on the spacing scale, between two logos
|
|
40
49
|
this.gap = "48";
|
|
41
50
|
this.paused = false;
|
|
51
|
+
this.pauseLabel = "Pause the moving logos";
|
|
52
|
+
this.playLabel = "Play the moving logos";
|
|
42
53
|
// copies of the set after the original; at least one, or there is no loop
|
|
43
54
|
this._copies = 1;
|
|
44
55
|
this._resize = new ResizeObserver(() => this._measure());
|
|
@@ -91,6 +102,10 @@ export class LogoMarquee extends LitElement {
|
|
|
91
102
|
if (changed.has("_copies")) this._fillCopies();
|
|
92
103
|
}
|
|
93
104
|
|
|
105
|
+
_toggle() {
|
|
106
|
+
this.paused = !this.paused;
|
|
107
|
+
}
|
|
108
|
+
|
|
94
109
|
render() {
|
|
95
110
|
const copies = Array.from({ length: this._copies });
|
|
96
111
|
return html`
|
|
@@ -105,6 +120,16 @@ export class LogoMarquee extends LitElement {
|
|
|
105
120
|
${copies.map(() => html`<div class="group copy" aria-hidden="true" inert></div>`)}
|
|
106
121
|
</div>
|
|
107
122
|
</div>
|
|
123
|
+
<bd-button
|
|
124
|
+
class="toggle"
|
|
125
|
+
variant="ghost"
|
|
126
|
+
size="sm"
|
|
127
|
+
icon-only
|
|
128
|
+
label="${this.paused ? this.playLabel : this.pauseLabel}"
|
|
129
|
+
@click=${this._toggle}
|
|
130
|
+
>${this.paused
|
|
131
|
+
? html`<bd-play-icon size="sm"></bd-play-icon>`
|
|
132
|
+
: html`<bd-pause-icon size="sm"></bd-pause-icon>`}</bd-button>
|
|
108
133
|
</section>
|
|
109
134
|
`;
|
|
110
135
|
}
|
|
@@ -35,13 +35,19 @@ needs and moves the track by one copy, so the loop has no seam. The copies are
|
|
|
35
35
|
| \`label\` | String | \`""\` | Names the region, in the page's language |
|
|
36
36
|
| \`duration\` | Number | \`35\` | Seconds for one copy of the set to pass (35 for partners and awards) |
|
|
37
37
|
| \`gap\` | String | \`"48"\` | A spacing step between two logos (48 partners, 24 awards) |
|
|
38
|
-
| \`paused\` | Boolean | \`false\` | Stopped;
|
|
38
|
+
| \`paused\` | Boolean | \`false\` | Stopped; the pause button sets it, and so can a page |
|
|
39
|
+
| \`pause-label\` | String | \`"Pause the moving logos"\` | The pause button's accessible name while it moves |
|
|
40
|
+
| \`play-label\` | String | \`"Play the moving logos"\` | The button's accessible name while it is paused |
|
|
39
41
|
|
|
40
42
|
### Motion
|
|
41
43
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
44
|
+
It moves on its own for longer than five seconds, so a pause button sits at
|
|
45
|
+
the row's end (WCAG 2.2.2): the logos are usually images, so nothing in the
|
|
46
|
+
row takes focus and holding it on focus alone was no way to stop it. The
|
|
47
|
+
button sets \`paused\`, and a page can set it too; the pointer or focus on the
|
|
48
|
+
row still holds it. Under \`prefers-reduced-motion\` it never moves: the set
|
|
49
|
+
wraps in place, the fade goes, nothing is hidden, and the button goes too.
|
|
50
|
+
Pass \`pause-label\` and \`play-label\` in the page's language.
|
|
45
51
|
`
|
|
46
52
|
}
|
|
47
53
|
}
|
|
@@ -2,43 +2,80 @@ import { css, unsafeCSS } from "lit";
|
|
|
2
2
|
import { below } from "../shared/token-scales.js";
|
|
3
3
|
|
|
4
4
|
export default css`
|
|
5
|
+
/* The panel is the <dialog> itself. Its user-agent border and colour are
|
|
6
|
+
reset so the tokens below are all there is; the browser still centres it
|
|
7
|
+
and puts it in the top layer, which is why there is no z-index here. */
|
|
5
8
|
.bd-modal {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
border: none;
|
|
10
|
+
color: inherit;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/* The scrim. ::backdrop reads the tokens because it inherits from its
|
|
14
|
+
dialog. */
|
|
15
|
+
.bd-modal::backdrop {
|
|
16
|
+
/* Expressed as a mix over the palette rather than a raw rgba, which is the
|
|
17
|
+
house pattern -- --color-border-container-inverse and spinner's two
|
|
18
|
+
private aliases are written the same way. A raw rgba(0,0,0,0.5) is a
|
|
19
|
+
black no theme can reach; this one follows --color-neutral-1000.
|
|
20
|
+
Verified pixel-identical to the rgba it replaces.
|
|
16
21
|
.
|
|
17
22
|
no role: a page scrim has no role, and with one consumer it should not
|
|
18
23
|
have one yet. If a second component ever needs to darken the page behind
|
|
19
24
|
itself, that is the point to name it. */
|
|
20
25
|
background: color-mix(in srgb, var(--color-neutral-1000) 50%, transparent);
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
align-items: center;
|
|
24
|
-
z-index: var(--z-modal);
|
|
26
|
+
/* Safari before 18 knows the blur only by its prefixed name */
|
|
27
|
+
-webkit-backdrop-filter: blur(var(--spacing-12));
|
|
25
28
|
backdrop-filter: blur(var(--spacing-12));
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
whole page and swallows every click: elementsFromPoint at the centre of
|
|
33
|
-
the viewport returned [BD-MODAL, HTML] with the modal closed. */
|
|
34
|
-
pointer-events: none;
|
|
29
|
+
/* Scrolling over the scrim, or past the end of a tall panel, no longer
|
|
30
|
+
scrolls the page behind it. overscroll-behavior is Widely available;
|
|
31
|
+
holding back a scroll that is not a scroll container's is newer, and
|
|
32
|
+
where it is missing the page scrolls behind, as it always has. */
|
|
33
|
+
overflow: hidden;
|
|
34
|
+
overscroll-behavior: contain;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
37
|
+
.bd-modal:modal {
|
|
38
|
+
overscroll-behavior: contain;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/* The panel scales and fades in and the scrim fades. Animating into and out
|
|
42
|
+
of the top layer -- @starting-style, and display and overlay transitioned
|
|
43
|
+
with allow-discrete -- is newer than the Widely available target, so it
|
|
44
|
+
is an enhancement: without it the dialog simply appears and goes. */
|
|
45
|
+
@supports (transition-behavior: allow-discrete) {
|
|
46
|
+
.bd-modal,
|
|
47
|
+
.bd-modal::backdrop {
|
|
48
|
+
opacity: 0;
|
|
49
|
+
transition-property: opacity, transform, display, overlay;
|
|
50
|
+
transition-duration: var(--transition-duration-slow);
|
|
51
|
+
transition-timing-function: var(--transition-easing-ease);
|
|
52
|
+
transition-behavior: allow-discrete;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.bd-modal {
|
|
56
|
+
transform: scale(0.9);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.bd-modal[open],
|
|
60
|
+
.bd-modal[open]::backdrop {
|
|
61
|
+
opacity: 1;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.bd-modal[open] {
|
|
65
|
+
transform: scale(1);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
@starting-style {
|
|
69
|
+
.bd-modal[open],
|
|
70
|
+
.bd-modal[open]::backdrop {
|
|
71
|
+
opacity: 0;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.bd-modal[open] {
|
|
75
|
+
transform: scale(0.9);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
42
79
|
|
|
43
80
|
/* max-height and overflow, because without them the bottom of a tall dialog
|
|
44
81
|
is simply gone. Measured on Components/Modal "Long Modal Text": the panel
|
|
@@ -62,7 +99,7 @@ export default css`
|
|
|
62
99
|
which took the panel from 564px wide to 500 and rewrapped its text a line
|
|
63
100
|
taller. That is a visible change to an axis this fix has no business
|
|
64
101
|
touching, so the arithmetic goes in the calc instead. */
|
|
65
|
-
.bd-modal
|
|
102
|
+
.bd-modal {
|
|
66
103
|
/* --color-surface-default, the role, not --color-neutral-0, the primitive
|
|
67
104
|
it resolves to. Same value; the category is the point, and CLAUDE.md's
|
|
68
105
|
"same primitive value is not same semantic meaning" section exists for
|
|
@@ -73,7 +110,7 @@ export default css`
|
|
|
73
110
|
padding: 2em;
|
|
74
111
|
border-radius: var(--shape-radius-xl);
|
|
75
112
|
max-width: 500px;
|
|
76
|
-
max-height: calc(
|
|
113
|
+
max-height: calc(100dvh - var(--spacing-128));
|
|
77
114
|
overflow-y: auto;
|
|
78
115
|
text-align: start;
|
|
79
116
|
/* --shadow-md, the role this package already uses for a floating overlay
|
|
@@ -117,7 +154,7 @@ export default css`
|
|
|
117
154
|
The values now match the atom's md size (8/16 at --radius-sm) and are
|
|
118
155
|
spelled with the tokens it uses. Visible: corners tighten from 8px to
|
|
119
156
|
4px. */
|
|
120
|
-
.bd-modal
|
|
157
|
+
.bd-modal button {
|
|
121
158
|
margin-top: var(--spacing-16);
|
|
122
159
|
padding: var(--spacing-8) var(--spacing-16);
|
|
123
160
|
background: var(--color-surface-brand);
|
|
@@ -128,7 +165,7 @@ export default css`
|
|
|
128
165
|
font-family: var(--typography-fontFamily-sans);
|
|
129
166
|
}
|
|
130
167
|
|
|
131
|
-
.bd-modal
|
|
168
|
+
.bd-modal button:focus-visible {
|
|
132
169
|
/* the one focus ring — see Foundations/Focus */
|
|
133
170
|
/* forced-colors mode does not paint box-shadow, so the ring
|
|
134
171
|
vanishes there; it does paint an outline, in a system colour. This one
|
|
@@ -139,31 +176,28 @@ export default css`
|
|
|
139
176
|
box-shadow: var(--focus-outline-primary);
|
|
140
177
|
}
|
|
141
178
|
|
|
142
|
-
/* The
|
|
179
|
+
/* The panel scales and fades in. Measured before this: with
|
|
143
180
|
prefers-reduced-motion: reduce the transition still reported
|
|
144
181
|
0.3s on opacity and transform, so a reader who asked for less motion got
|
|
145
182
|
the panel zooming in anyway. Every other animated component in this
|
|
146
183
|
package honours the query -- see the tooltip two files over. */
|
|
147
184
|
@media (prefers-reduced-motion: reduce) {
|
|
148
|
-
.bd-modal
|
|
185
|
+
.bd-modal,
|
|
186
|
+
.bd-modal::backdrop {
|
|
149
187
|
transition: none;
|
|
150
188
|
transform: none;
|
|
151
189
|
}
|
|
152
|
-
|
|
153
|
-
:host([open]) .bd-modal {
|
|
154
|
-
transform: none;
|
|
155
|
-
}
|
|
156
190
|
}
|
|
157
191
|
|
|
158
192
|
@media ${unsafeCSS(below('md'))} {
|
|
159
|
-
.bd-modal
|
|
193
|
+
.bd-modal {
|
|
160
194
|
max-width: 90%;
|
|
161
195
|
padding: 1.5em;
|
|
162
196
|
}
|
|
163
197
|
}
|
|
164
198
|
|
|
165
199
|
@media (max-width: 480px) {
|
|
166
|
-
.bd-modal
|
|
200
|
+
.bd-modal {
|
|
167
201
|
padding: 2em;
|
|
168
202
|
}
|
|
169
203
|
}
|
|
@@ -5,27 +5,31 @@ import "../heading/heading.js";
|
|
|
5
5
|
import modalCSS from "../modal/modal.css.js";
|
|
6
6
|
import "../paragraph/paragraph.js";
|
|
7
7
|
|
|
8
|
+
/* <dialog closedby> is newer than the policy's Widely available target: where
|
|
9
|
+
the browser has it, a click on the backdrop is a close request like Esc;
|
|
10
|
+
where it does not, the click is recognised here. */
|
|
11
|
+
const CLOSEDBY = "closedBy" in HTMLDialogElement.prototype;
|
|
12
|
+
|
|
8
13
|
/**
|
|
9
|
-
* A dialog
|
|
10
|
-
*
|
|
14
|
+
* A dialog: a scrim, a centred panel, a title, a description and a close
|
|
15
|
+
* control. The consuming page owns `open` and reacts to close-modal.
|
|
11
16
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
17
|
+
* It is a native <dialog> opened with showModal(), and that is what makes it
|
|
18
|
+
* modal rather than a panel drawn over the page. The browser supplies what
|
|
19
|
+
* this element used to approximate or leave out: the dialog role and modal
|
|
20
|
+
* state, a page made inert behind it, focus moved in on open and returned to
|
|
21
|
+
* whatever opened it on close, Esc, and the top layer, so no z-index decides
|
|
22
|
+
* whether it is on top. Until it was a <dialog> it was a <div role="dialog">
|
|
23
|
+
* without aria-modal -- measured, one Tab reached the close button and the
|
|
24
|
+
* next left the dialog entirely with seven controls still reachable behind
|
|
25
|
+
* it -- and closing it had to blur the focus it left behind by hand.
|
|
20
26
|
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
* to, and a scroll lock -- and that is a decision with more than one valid
|
|
28
|
-
* shape, so P6C.4 reports it rather than picking one.
|
|
27
|
+
* Every way out asks the page instead of closing: Esc and a backdrop click
|
|
28
|
+
* arrive as `cancel`, which is prevented and turned into close-modal, and the
|
|
29
|
+
* Close button dispatches close-modal directly. The dialog closes when the
|
|
30
|
+
* page sets open back to false. A browser may refuse to let a second Esc be
|
|
31
|
+
* cancelled; it then closes the dialog itself, and `close` still tells the
|
|
32
|
+
* page.
|
|
29
33
|
*
|
|
30
34
|
* The icon is `alt=""`. It was `alt="icon"`, which a screen reader announced
|
|
31
35
|
* as the word "icon" beside a title that already says what the dialog is.
|
|
@@ -38,81 +42,88 @@ export class BdModal extends LitElement {
|
|
|
38
42
|
modalText: { type: String }
|
|
39
43
|
};
|
|
40
44
|
|
|
45
|
+
get _dialog() {
|
|
46
|
+
return this.renderRoot?.querySelector("dialog");
|
|
47
|
+
}
|
|
48
|
+
|
|
41
49
|
_onClose() {
|
|
42
50
|
this.dispatchEvent(new CustomEvent("close-modal", { bubbles: true, composed: true }));
|
|
43
51
|
}
|
|
44
52
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
53
|
+
_onCancel(e) {
|
|
54
|
+
e.preventDefault();
|
|
55
|
+
this._onClose();
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/* Only a dialog that is actually closed counts. A `close` event can arrive
|
|
59
|
+
after the page has already reopened the dialog -- measured in Chromium:
|
|
60
|
+
closed from a backdrop click, the event was delivered on the next
|
|
61
|
+
showModal(), and read as a close it asked the page to shut the dialog it
|
|
62
|
+
had just opened. */
|
|
63
|
+
_onDialogClose() {
|
|
64
|
+
if (this.open && !this._dialog?.open) this._onClose();
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/* The backdrop belongs to the dialog, so a click on it targets the dialog
|
|
68
|
+
itself; a click on the panel's own padding does too, and is told apart by
|
|
69
|
+
landing inside the dialog's box. */
|
|
70
|
+
_onClick(e) {
|
|
71
|
+
if (CLOSEDBY || e.target !== this._dialog) return;
|
|
72
|
+
const box = this._dialog.getBoundingClientRect();
|
|
73
|
+
const inside = e.clientX >= box.left && e.clientX <= box.right
|
|
74
|
+
&& e.clientY >= box.top && e.clientY <= box.bottom;
|
|
75
|
+
if (!inside) this._onClose();
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/* Reconnecting keeps the rendered dialog, but not as a modal: removing a
|
|
79
|
+
dialog from the document takes it out of the top layer and drops its
|
|
80
|
+
modal state while leaving its open attribute, so a modal moved while open
|
|
81
|
+
comes back an ordinary open dialog -- in the flow, no backdrop, the page
|
|
82
|
+
behind it live and no Esc. _sync() asks whether it is :modal, not only
|
|
83
|
+
open, and shows it as one again. */
|
|
60
84
|
connectedCallback() {
|
|
61
85
|
super.connectedCallback();
|
|
62
|
-
this.
|
|
63
|
-
if (e.key !== "Escape" || !this.open) return;
|
|
64
|
-
this._onClose();
|
|
65
|
-
};
|
|
66
|
-
document.addEventListener("keydown", this._onKeydown);
|
|
86
|
+
if (this.hasUpdated) this._sync();
|
|
67
87
|
}
|
|
68
88
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
super.disconnectedCallback();
|
|
89
|
+
updated() {
|
|
90
|
+
this._sync();
|
|
72
91
|
}
|
|
73
92
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
updated(changed) {
|
|
85
|
-
if (!changed.has("open") || this.open) return;
|
|
86
|
-
if (this.renderRoot?.activeElement) this.renderRoot.activeElement.blur();
|
|
93
|
+
_sync() {
|
|
94
|
+
const dialog = this._dialog;
|
|
95
|
+
if (!dialog?.isConnected) return;
|
|
96
|
+
if (this.open && !dialog.matches(":modal")) {
|
|
97
|
+
// showModal() throws on a dialog that is already open, modal or not
|
|
98
|
+
if (dialog.open) dialog.close();
|
|
99
|
+
dialog.showModal();
|
|
100
|
+
} else if (!this.open && dialog.open) {
|
|
101
|
+
dialog.close();
|
|
102
|
+
}
|
|
87
103
|
}
|
|
88
104
|
|
|
89
105
|
render() {
|
|
90
106
|
return html`
|
|
91
|
-
<
|
|
107
|
+
<dialog
|
|
92
108
|
class="bd-modal"
|
|
93
|
-
|
|
94
|
-
aria-
|
|
95
|
-
|
|
109
|
+
closedby="any"
|
|
110
|
+
aria-labelledby="modal-title"
|
|
111
|
+
aria-describedby="modal-description"
|
|
112
|
+
@cancel="${this._onCancel}"
|
|
113
|
+
@close="${this._onDialogClose}"
|
|
114
|
+
@click="${this._onClick}"
|
|
96
115
|
>
|
|
97
|
-
|
|
98
|
-
class="bd-modal-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
${this.icon
|
|
105
|
-
? html`<img src="${this.icon}" alt="" class="bd-carousel-modal-icon" />`
|
|
106
|
-
: ""}
|
|
107
|
-
<bd-h as="h2" id="modal-title" paddingBottom="16">${this.title}</bd-h>
|
|
108
|
-
<bd-p variant="regular" id="modal-description">${this.modalText}</bd-p>
|
|
109
|
-
<button @click="${this._onClose}" aria-label="Close modal">Close</button>
|
|
110
|
-
</div>
|
|
111
|
-
</div>
|
|
116
|
+
${this.icon
|
|
117
|
+
? html`<img src="${this.icon}" alt="" class="bd-carousel-modal-icon" />`
|
|
118
|
+
: ""}
|
|
119
|
+
<bd-h as="h2" id="modal-title" paddingBottom="16">${this.title}</bd-h>
|
|
120
|
+
<bd-p variant="regular" id="modal-description">${this.modalText}</bd-p>
|
|
121
|
+
<button @click="${this._onClose}" aria-label="Close modal" autofocus>Close</button>
|
|
122
|
+
</dialog>
|
|
112
123
|
`;
|
|
113
124
|
}
|
|
114
125
|
}
|
|
115
126
|
|
|
116
127
|
BdModal.styles = [modalCSS];
|
|
117
128
|
|
|
118
|
-
customElements.define("bd-modal", BdModal);
|
|
129
|
+
customElements.define("bd-modal", BdModal);
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { html } from 'lit';
|
|
2
|
+
import { createRef, ref } from 'lit/directives/ref.js';
|
|
3
|
+
import { expect, waitFor, within } from 'storybook/test';
|
|
2
4
|
import './modal.js';
|
|
3
5
|
|
|
4
6
|
export default {
|
|
@@ -6,6 +8,7 @@ export default {
|
|
|
6
8
|
tags : ['autodocs'],
|
|
7
9
|
parameters: {
|
|
8
10
|
docs: {
|
|
11
|
+
story : { inline: false, height: '480px' },
|
|
9
12
|
description: {
|
|
10
13
|
component: `
|
|
11
14
|
**BdModal** is a Lit modal dialog component with icon, title, and description support.
|
|
@@ -22,17 +25,18 @@ export default {
|
|
|
22
25
|
\`\`\`
|
|
23
26
|
|
|
24
27
|
### Behavior
|
|
25
|
-
-
|
|
26
|
-
-
|
|
27
|
-
-
|
|
28
|
-
- \`aria-hidden\` is set to \`"false"\` when open, \`"true"\` when closed
|
|
28
|
+
- A native \`<dialog>\` opened with \`showModal()\`: the page behind it is inert, focus moves to the Close button and returns to whatever opened it
|
|
29
|
+
- Esc, a click on the backdrop and the Close button each fire \`close-modal\`; the dialog closes when the page sets \`open\` to false
|
|
30
|
+
- A closed modal is not rendered, so it is out of the accessibility tree and takes no clicks
|
|
29
31
|
|
|
30
32
|
### Events
|
|
31
|
-
- \`close-modal\` — CustomEvent, bubbles and composed, fired on backdrop click or
|
|
33
|
+
- \`close-modal\` — CustomEvent, bubbles and composed, fired on Esc, a backdrop click or the Close button
|
|
32
34
|
|
|
33
35
|
### Accessibility
|
|
34
36
|
- \`aria-labelledby="modal-title"\` links to the \`<bd-h>\` heading
|
|
35
37
|
- \`aria-describedby="modal-description"\` links to the \`<bd-p>\` text
|
|
38
|
+
|
|
39
|
+
On this page each story renders in its own frame: an open modal makes everything behind it inert, and inline it would take this page with it.
|
|
36
40
|
`
|
|
37
41
|
}
|
|
38
42
|
}
|
|
@@ -40,7 +44,7 @@ export default {
|
|
|
40
44
|
argTypes: {
|
|
41
45
|
open: {
|
|
42
46
|
control : 'boolean',
|
|
43
|
-
description: '
|
|
47
|
+
description: 'Opens the dialog with `showModal()` when true and closes it when false.',
|
|
44
48
|
table : { type: { summary: 'boolean' }, defaultValue: { summary: 'false' }, category: 'State' }
|
|
45
49
|
},
|
|
46
50
|
title: {
|
|
@@ -95,7 +99,7 @@ export const Default = {
|
|
|
95
99
|
export const Closed = {
|
|
96
100
|
name : 'Closed State',
|
|
97
101
|
render: () => html`
|
|
98
|
-
<p style="font-size:14px;">The modal below is closed —
|
|
102
|
+
<p style="font-size:14px;">The modal below is closed — its <code><dialog></code> is in the DOM but not rendered.</p>
|
|
99
103
|
<bd-modal
|
|
100
104
|
.open="${false}"
|
|
101
105
|
title="VPN Protection"
|
|
@@ -103,7 +107,7 @@ export const Closed = {
|
|
|
103
107
|
icon="/icons/privacy_protection.png"
|
|
104
108
|
></bd-modal>
|
|
105
109
|
`,
|
|
106
|
-
parameters: { docs: { description: { story: 'Modal with `open=false` —
|
|
110
|
+
parameters: { docs: { description: { story: 'Modal with `open=false` — the `<dialog>` is in the DOM, closed, so it is not rendered and not in the accessibility tree.' } } }
|
|
107
111
|
};
|
|
108
112
|
|
|
109
113
|
export const NoIcon = {
|
|
@@ -140,25 +144,34 @@ export const DifferentTitles = {
|
|
|
140
144
|
<bd-modal .open="${true}" title="Parental Controls" icon="/icons/bd-icon-family.png" modalText="Monitor your children's online activity and set screen time limits."></bd-modal>
|
|
141
145
|
</div>
|
|
142
146
|
`,
|
|
143
|
-
parameters: { docs: { description: { story: 'Three modals
|
|
147
|
+
parameters: { docs: { description: { story: 'Three modals open at once. Each is a modal dialog in the top layer, so the last one opened is on top and the others are behind its backdrop.' } } }
|
|
144
148
|
};
|
|
145
149
|
|
|
146
150
|
export const CloseInteraction = {
|
|
147
151
|
name : 'Close Interaction Demo',
|
|
148
152
|
render: () => {
|
|
149
|
-
|
|
150
|
-
const
|
|
153
|
+
/* The page owns `open`: it opens the modal, and closes it on close-modal. */
|
|
154
|
+
const modal = createRef();
|
|
151
155
|
return html`
|
|
152
|
-
<button @click="${() => {
|
|
156
|
+
<button @click="${() => { modal.value.open = true; }}" style="margin-bottom:16px; padding:8px 16px;">Open Modal</button>
|
|
153
157
|
<bd-modal
|
|
158
|
+
${ref(modal)}
|
|
154
159
|
.open="${false}"
|
|
155
160
|
title="Interactive Modal"
|
|
156
161
|
modalText="Click the backdrop or the Close button to dismiss this modal. The close-modal event is dispatched."
|
|
157
|
-
@close-modal="${
|
|
158
|
-
${(el) => { modalEl = el; }}
|
|
162
|
+
@close-modal="${() => { modal.value.open = false; }}"
|
|
159
163
|
></bd-modal>
|
|
160
164
|
`;
|
|
161
165
|
},
|
|
166
|
+
/* The Open button never opened anything while the element was bound with a
|
|
167
|
+
bare function, which Lit ignores in element position; this keeps it honest. */
|
|
168
|
+
play: async ({ canvas, canvasElement, userEvent }) => {
|
|
169
|
+
const dialog = canvasElement.querySelector('bd-modal').shadowRoot.querySelector('dialog');
|
|
170
|
+
await userEvent.click(canvas.getByRole('button', { name: 'Open Modal' }));
|
|
171
|
+
await waitFor(() => expect(dialog.open).toBe(true));
|
|
172
|
+
await userEvent.click(within(dialog).getByRole('button', { name: 'Close modal' }));
|
|
173
|
+
await waitFor(() => expect(dialog.open).toBe(false));
|
|
174
|
+
},
|
|
162
175
|
parameters: { docs: { description: { story: 'Interactive demo: click the button to open, then click backdrop or Close button to dismiss via the `close-modal` event.' } } }
|
|
163
176
|
};
|
|
164
177
|
|