@repobit/dex-system-design 2.5.0 → 2.6.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.
Files changed (173) hide show
  1. package/CHANGELOG.md +91 -0
  2. package/README.md +2 -1
  3. package/package.json +14 -27
  4. package/schemas/component-manifest.json +226 -33
  5. package/schemas/manifest-omissions.json +23 -0
  6. package/src/components/accordion/accordion-bg.css.js +39 -30
  7. package/src/components/accordion/accordion-bg.js +17 -28
  8. package/src/components/accordion/accordion-bg.stories.js +5 -0
  9. package/src/components/accordion/accordion-panel.js +24 -0
  10. package/src/components/accordion/accordion.css.js +105 -111
  11. package/src/components/accordion/accordion.js +23 -37
  12. package/src/components/accordion/accordion.stories.js +5 -1
  13. package/src/components/anchor/anchor-nav.css.js +131 -53
  14. package/src/components/anchor/anchor-nav.js +276 -201
  15. package/src/components/annotation/annotation.css.js +7 -4
  16. package/src/components/architecture.stories.js +8 -7
  17. package/src/components/audience-card/audience-card.css.js +30 -4
  18. package/src/components/audience-card/audience-card.js +8 -13
  19. package/src/components/awards/awards-flex.css.js +23 -6
  20. package/src/components/awards/awards-flex.js +21 -6
  21. package/src/components/awards/awards-spotlight.css.js +25 -5
  22. package/src/components/awards/awards-spotlight.js +19 -7
  23. package/src/components/awards/awards.css.js +20 -8
  24. package/src/components/awards/awards.js +30 -91
  25. package/src/components/awards/awards.stories.js +5 -5
  26. package/src/components/awards/scroll-slides.js +128 -0
  27. package/src/components/back/back.css.js +2 -0
  28. package/src/components/badge/badge.css.js +15 -0
  29. package/src/components/bento-grid/bento-grid.css.js +105 -11
  30. package/src/components/bento-grid/bento-grid.js +37 -124
  31. package/src/components/bento-grid/bento-grid.stories.js +3 -2
  32. package/src/components/bento-grid/bento-item.css.js +71 -32
  33. package/src/components/bento-grid/bento-item.js +3 -30
  34. package/src/components/blockquote/blockquote.css.js +2 -2
  35. package/src/components/breadcrumb/breadcrumb.css.js +10 -9
  36. package/src/components/breadcrumb/breadcrumb.js +35 -34
  37. package/src/components/button/button.css.js +42 -17
  38. package/src/components/button/button.js +84 -3
  39. package/src/components/button/button.stories.js +17 -0
  40. package/src/components/card-features/card-features.css.js +23 -2
  41. package/src/components/card-features/card-features.js +6 -48
  42. package/src/components/cards/card.css.js +43 -14
  43. package/src/components/cards/card.js +43 -177
  44. package/src/components/cards/card.stories.js +8 -10
  45. package/src/components/carousel/carousel.css.js +101 -70
  46. package/src/components/carousel/carousel.js +107 -71
  47. package/src/components/carousel/carousel.stories.js +18 -16
  48. package/src/components/checkbox/checkbox.css.js +26 -9
  49. package/src/components/checkbox/checkbox.js +73 -39
  50. package/src/components/checkbox/checkbox.stories.js +35 -18
  51. package/src/components/compare/compare.css.js +68 -10
  52. package/src/components/compare/compare.js +40 -103
  53. package/src/components/compare/compare.stories.js +1 -1
  54. package/src/components/compatibility-table/compatibility-table.css.js +70 -37
  55. package/src/components/compatibility-table/compatibility-table.js +47 -40
  56. package/src/components/compatibility-table/compatibility-table.stories.js +78 -1
  57. package/src/components/display/display.css.js +7 -0
  58. package/src/components/dropdown/dropdown.css.js +20 -3
  59. package/src/components/dropdown/dropdown.js +57 -21
  60. package/src/components/dropdown/dropdown.stories.js +31 -9
  61. package/src/components/features/features.css.js +56 -21
  62. package/src/components/features/features.js +7 -117
  63. package/src/components/fieldset/fieldset.stories.js +68 -0
  64. package/src/components/footer/footer-images.js +34 -0
  65. package/src/components/footer/footer-links-group.css.js +10 -10
  66. package/src/components/footer/footer-locale.js +47 -0
  67. package/src/components/footer/footer-lp.js +27 -114
  68. package/src/components/footer/footer-lp.stories.js +2 -2
  69. package/src/components/footer/footer-nav-menu.css.js +2 -2
  70. package/src/components/footer/footer-nav-menu.js +8 -3
  71. package/src/components/footer/footer.css.js +238 -197
  72. package/src/components/footer/footer.js +109 -187
  73. package/src/components/footer/footer.stories.js +14 -4
  74. package/src/components/grid/grid.css.js +64 -5
  75. package/src/components/header/header-code.css.js +20 -11
  76. package/src/components/header/header-code.js +1 -1
  77. package/src/components/header/header.css.js +20 -14
  78. package/src/components/header/header.js +6 -7
  79. package/src/components/header/header.stories.js +29 -24
  80. package/src/components/heading/heading.css.js +11 -0
  81. package/src/components/hero/hero.js +10 -2
  82. package/src/components/highlight/highlight.css.js +30 -6
  83. package/src/components/icons/arrow-icon.js +4 -1
  84. package/src/components/icons/arrow-right-icon.js +5 -1
  85. package/src/components/icons/icon-element.js +18 -0
  86. package/src/components/image/image.js +29 -9
  87. package/src/components/image/image.stories.js +38 -2
  88. package/src/components/input/custom-form.stories.js +38 -7
  89. package/src/components/input/input-clipboard.css.js +15 -1
  90. package/src/components/input/input-clipboard.js +84 -21
  91. package/src/components/input/input.js +27 -7
  92. package/src/components/install-options/install-options.css.js +26 -6
  93. package/src/components/install-options/install-options.js +32 -8
  94. package/src/components/label/label.css.js +1 -1
  95. package/src/components/light-carousel/light-carousel.css.js +100 -48
  96. package/src/components/light-carousel/light-carousel.js +43 -5
  97. package/src/components/link/link.css.js +15 -15
  98. package/src/components/link/link.js +17 -1
  99. package/src/components/link/link.stories.js +20 -7
  100. package/src/components/list/list.css.js +3 -3
  101. package/src/components/logo-marquee/logo-marquee.css.js +12 -1
  102. package/src/components/logo-marquee/logo-marquee.js +33 -8
  103. package/src/components/logo-marquee/logo-marquee.stories.js +10 -4
  104. package/src/components/modal/modal.css.js +74 -40
  105. package/src/components/modal/modal.js +85 -74
  106. package/src/components/modal/modal.stories.js +27 -14
  107. package/src/components/motion-art/motion-art.js +67 -1
  108. package/src/components/page-switcher/page-switcher.css.js +27 -9
  109. package/src/components/page-switcher/page-switcher.js +11 -8
  110. package/src/components/partner-banner/partner-banner.css.js +2 -0
  111. package/src/components/picture/picture.css.js +4 -4
  112. package/src/components/picture/picture.js +13 -3
  113. package/src/components/picture/picture.stories.js +28 -2
  114. package/src/components/post-card/post-card.css.js +18 -3
  115. package/src/components/pricing-cards/adopt-styles.js +16 -0
  116. package/src/components/pricing-cards/new-pricing-card.js +2 -4
  117. package/src/components/pricing-cards/new-pricing-card.stories.js +20 -22
  118. package/src/components/pricing-cards/pricing-card-actions.css.js +8 -12
  119. package/src/components/pricing-cards/pricing-card-actions.js +26 -13
  120. package/src/components/pricing-cards/pricing-card-container.css.js +4 -3
  121. package/src/components/pricing-cards/pricing-card-container.js +10 -4
  122. package/src/components/pricing-cards/pricing-card-header.css.js +5 -4
  123. package/src/components/pricing-cards/pricing-card-header.js +18 -31
  124. package/src/components/pricing-cards/pricing-card-pricing.css.js +84 -61
  125. package/src/components/pricing-cards/pricing-card-pricing.js +38 -24
  126. package/src/components/pricing-cards/pricing-card-show-more.js +8 -3
  127. package/src/components/pricing-cards/pricing-card.css.js +75 -41
  128. package/src/components/pricing-cards/pricing-card.js +356 -308
  129. package/src/components/progress/progress.css.js +58 -13
  130. package/src/components/progress/progress.js +13 -10
  131. package/src/components/progress/progress.stories.js +9 -7
  132. package/src/components/radio/radio-group.css.js +42 -0
  133. package/src/components/radio/radio-group.js +89 -0
  134. package/src/components/radio/radio.css.js +63 -6
  135. package/src/components/radio/radio.js +173 -140
  136. package/src/components/radio/radio.stories.js +99 -44
  137. package/src/components/radio/toggle-radio.js +44 -0
  138. package/src/components/review/review-grid.css.js +5 -1
  139. package/src/components/review/review-grid.js +2 -0
  140. package/src/components/review/review.js +13 -0
  141. package/src/components/shared/announcer.js +37 -0
  142. package/src/components/shared/fill-width.css.js +33 -0
  143. package/src/components/shared/form-control.js +194 -0
  144. package/src/components/shared/form-field.css.js +31 -3
  145. package/src/components/shared/token-scales.js +75 -26
  146. package/src/components/spotlight-section/spotlight-section.js +2 -2
  147. package/src/components/stat/stat-highlight.js +1 -1
  148. package/src/components/stat/stat.css.js +18 -3
  149. package/src/components/switch/switch.css.js +58 -5
  150. package/src/components/switch/switch.js +53 -5
  151. package/src/components/switch/switch.stories.js +30 -8
  152. package/src/components/tab-list/tab-list.css.js +51 -13
  153. package/src/components/tab-list/tab-list.js +7 -2
  154. package/src/components/tab-list/tab-list.stories.js +2 -2
  155. package/src/components/tabs/tabs.css.js +18 -1
  156. package/src/components/tabs/tabs.js +119 -41
  157. package/src/components/terminal/terminal-message.css.js +6 -1
  158. package/src/components/termsOfUse/terms.css.js +4 -2
  159. package/src/components/textarea/textarea.js +22 -7
  160. package/src/components/textarea/textarea.stories.js +12 -9
  161. package/src/components/trust-panel/trust-panel.css.js +13 -3
  162. package/src/components/ultimate-security-demo.stories.js +5 -5
  163. package/src/components/video/video.css.js +5 -0
  164. package/src/components/video/video.js +5 -0
  165. package/src/components/video/video.stories.js +12 -0
  166. package/src/components/video-player/video-player.css.js +20 -8
  167. package/src/components/video-player/video-player.js +74 -20
  168. package/src/components/video-player/video-player.stories.js +17 -3
  169. package/src/tokens/brands.stories.js +1 -1
  170. package/src/tokens/themes/index.js +2 -2
  171. package/src/tokens/typography.stories.js +4 -3
  172. package/src/vendor/motion-art/README.md +4 -1
  173. package/src/components/footer/footer-lp.css.js +0 -159
@@ -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
- position: fixed;
7
- top: var(--spacing-0);
8
- left: var(--spacing-0);
9
- width: 100%;
10
- height: 100%;
11
- /* The scrim. Expressed as a mix over the palette rather than a raw rgba,
12
- which is the house pattern -- --color-border-container-inverse and
13
- spinner's two private aliases are written the same way. A raw
14
- rgba(0,0,0,0.5) is a black no theme can reach; this one follows
15
- --color-neutral-1000. Verified pixel-identical to the rgba it replaces.
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
- display: flex;
22
- justify-content: center;
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
- opacity: 0;
27
- transform: scale(0.9);
28
- transition: opacity var(--transition-duration-slow) var(--transition-easing-ease), transform var(--transition-duration-slow) var(--transition-easing-ease);
29
- /* The counterpart of the pointer-events: auto in the [open] rule below,
30
- which was written without it. A closed modal is still a full-viewport
31
- fixed layer at this z-index, so without this it sits invisibly over the
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
- :host([open]) .bd-modal {
38
- opacity: 1;
39
- transform: scale(1);
40
- pointer-events: auto;
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-content {
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(100vh - var(--spacing-128));
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-content button {
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-content button:focus-visible {
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 scrim scales and fades in. Measured before this: with
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-content {
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-content {
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 surface: a scrim, a centred panel, a title, a description and a
10
- * close control. The consuming page owns `open` and reacts to close-modal.
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
- * `role="dialog"` is on the panel, and it is what makes the two labels this
13
- * element has always declared mean anything. Measured before it: the full
14
- * accessibility tree for an open modal was RootWebArea, image, heading,
15
- * paragraph, button -- no dialog node at any level, so `aria-labelledby` and
16
- * `aria-describedby` pointed at real targets from an element with no role to
17
- * name. With the role, the dialog is exposed and named "VPN Protection" from
18
- * the bd-h it already pointed at; the name resolves across bd-h's shadow
19
- * boundary because the title is slotted light-DOM text.
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
- * `aria-modal="true"` is deliberately NOT set. It is a claim that the rest of
22
- * the page is unavailable, and it is not: measured with a real keyboard, one
23
- * Tab reaches the close button and the next leaves the dialog entirely, with
24
- * seven focusable elements still reachable outside it. Setting the attribute
25
- * without focus containment would tell a screen reader something untrue.
26
- * Making it true is a dialog rework -- containment, an opener to restore focus
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
- * Escape closes through the same channel as the backdrop click: this element
47
- * does not own `open`, the consuming page does, so both gestures dispatch
48
- * close-modal and let the page decide. The channel already existed and
49
- * Escape was the one way in that was missing -- measured, Escape on an open
50
- * modal left open true and did nothing at all.
51
- *
52
- * On the document, guarded on `open`, because focus is normally NOT inside
53
- * this dialog: nothing moves it there when the dialog opens, so a listener
54
- * on the host would only fire after the user had already Tabbed in. Measured
55
- * with the host-scoped version first -- Escape with focus on body left open
56
- * true, which is every real case. The guard means a closed modal listens for
57
- * nothing, and propagation is left alone so a page that wants to react to
58
- * the same Escape still can.
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._onKeydown = e => {
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
- disconnectedCallback() {
70
- document.removeEventListener("keydown", this._onKeydown);
71
- super.disconnectedCallback();
89
+ updated() {
90
+ this._sync();
72
91
  }
73
92
 
74
- /**
75
- * Closing makes the dialog inert, which stops anything inside being reached
76
- * — but focus that was ALREADY inside stays there, on a subtree the user can
77
- * no longer see or operate. Measured: after close, document.activeElement was
78
- * still BD-MODAL with the close button active inside it.
79
- *
80
- * This releases that focus. It is deliberately not focus *restoration*:
81
- * returning focus to whatever opened the dialog needs the opener recorded,
82
- * which is part of the dialog rework this fix is scoped out of.
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
- <div
107
+ <dialog
92
108
  class="bd-modal"
93
- @click="${this._onClose}"
94
- aria-hidden="${!this.open}"
95
- ?inert="${!this.open}"
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
- <div
98
- class="bd-modal-content"
99
- @click="${(e) => e.stopPropagation()}"
100
- role="dialog"
101
- aria-labelledby="modal-title"
102
- aria-describedby="modal-description"
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
- - Clicking the backdrop (\`.bd-modal\`) fires \`close-modal\` event
26
- - Clicking inside \`.bd-modal-content\` stops propagation (does not close)
27
- - The Close button also fires \`close-modal\`
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 close button click
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: 'Controls visibility. Sets `aria-hidden` on the modal wrapper.',
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 — it has <code>aria-hidden="true"</code> but is still in the DOM.</p>
102
+ <p style="font-size:14px;">The modal below is closed — its <code>&lt;dialog&gt;</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` — renders in the DOM with `aria-hidden="true"`. Visibility depends on CSS handling of the open state.' } } }
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 stacked for visual comparison of different content configurations.' } } }
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
- let modalEl;
150
- const handleClose = () => { if (modalEl) modalEl.open = false; };
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="${() => { if (modalEl) modalEl.open = true; }}" style="margin-bottom:16px; padding:8px 16px;">Open Modal</button>
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="${handleClose}"
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
 
@@ -2,6 +2,18 @@
2
2
  import "../../tokens/tokens.js";
3
3
  import { BdHero as MotionArtElement } from "../../vendor/motion-art/motion-art-element.js";
4
4
 
5
+ const BRAND_GROUND = "var(--color-surface-brand)";
6
+
7
+ /* Each palette made once per ground and then reused: the generated element
8
+ restarts its clock whenever its palette is a different object. */
9
+ const grounded = new WeakMap();
10
+ function onGround(palette, ground) {
11
+ let byGround = grounded.get(palette);
12
+ if (!byGround) grounded.set(palette, byGround = new Map());
13
+ if (!byGround.has(ground)) byGround.set(ground, { ...palette, substrate: ground });
14
+ return byGround.get(ground);
15
+ }
16
+
5
17
  /**
6
18
  * The homepage's animated illustrations, one canvas each, square:
7
19
  * brand-surface the B on a glass sphere of network (bd-hero, media slot)
@@ -14,9 +26,11 @@ import { BdHero as MotionArtElement } from "../../vendor/motion-art/motion-art-e
14
26
  * this module imports it as MotionArtElement and registers it under the
15
27
  * package's own name, because bd-hero is the homepage band.
16
28
  *
17
- * Two defaults differ from the generated element's:
29
+ * Three things differ from the generated element:
18
30
  * - no substrate: it draws on a transparent canvas, so the ground is the
19
31
  * component's own --color-surface-brand and a partner brand shows through;
32
+ * - the brand tones' ground colour is that token too, where the generated
33
+ * element paints its own blue -- see willUpdate();
20
34
  * - the pill and badge type is the foundation's sans, read from the token.
21
35
  *
22
36
  * It draws only while on screen, holds a still frame under
@@ -27,6 +41,8 @@ export class MotionArt extends MotionArtElement {
27
41
  constructor() {
28
42
  super();
29
43
  this.substrate = false;
44
+ // The generated element starts on its brand tone, so this is the blue it is drawn on.
45
+ this._generatedGround = this.palette.substrate;
30
46
  }
31
47
 
32
48
  connectedCallback() {
@@ -36,6 +52,56 @@ export class MotionArt extends MotionArtElement {
36
52
  .trim();
37
53
  if (sans) this.labelFont = sans;
38
54
  }
55
+ /* The art takes its size from its first ResizeObserver delivery, and until
56
+ then has no tile and draws nothing. That delivery comes a frame after
57
+ connect, after the generated element's own observer, which it follows
58
+ because observers deliver in the order they were created. */
59
+ this._sized = new Promise(resolve => {
60
+ this._resolveSized = resolve;
61
+ const first = new ResizeObserver(() => { first.disconnect(); resolve(); });
62
+ first.observe(this);
63
+ });
64
+ }
65
+
66
+ disconnectedCallback() {
67
+ // Removed before its first delivery: nothing is coming, so nobody waits.
68
+ this._resolveSized?.();
69
+ super.disconnectedCallback();
70
+ }
71
+
72
+ /* The brand and solid tones were drawn on that blue and paint with it
73
+ wherever the ground should show through: the caption and badge type,
74
+ knocked out of a white pill, and the faces the canvas hides behind
75
+ others. Here the ground is --color-surface-brand, so they take that,
76
+ through the custom property itself so the type follows the brand. */
77
+ willUpdate(changed) {
78
+ super.willUpdate(changed);
79
+ if (this.palette?.substrate === this._generatedGround) this.palette = onGround(this.palette, BRAND_GROUND);
80
+ }
81
+
82
+ /* A canvas takes no var(): the clock gets the colour the property resolves
83
+ to when it starts, and keeps it until the next update starts another. */
84
+ runClock() {
85
+ const palette = this.palette;
86
+ if (palette?.substrate === BRAND_GROUND) {
87
+ const ground = getComputedStyle(this).getPropertyValue("--color-surface-brand")
88
+ .trim();
89
+ this.palette = onGround(palette, ground || this._generatedGround);
90
+ }
91
+ try {
92
+ super.runClock();
93
+ } finally {
94
+ this.palette = palette;
95
+ }
96
+ }
97
+
98
+ /* updateComplete covers the sizing, so `await el.updateComplete` means the
99
+ art is drawn at its size -- the delivery sets the tile, which is one more
100
+ update. */
101
+ async getUpdateComplete() {
102
+ const first = await super.getUpdateComplete();
103
+ await this._sized;
104
+ return (await super.getUpdateComplete()) && first;
39
105
  }
40
106
  }
41
107
 
@@ -72,17 +72,16 @@ export const pageSwitcherStyles = css`
72
72
 
73
73
  The last row is the one that changed behaviour rather than value: the
74
74
  current item used to turn blue under the pointer, because
75
- .bd-link--primary:hover outweighed .bd-link--active. bd-link now declares
76
- .bd-link--active:hover and it holds.
75
+ .bd-link--primary:hover outweighed the atom's current class. bd-link now
76
+ declares a current-and-hovered rule and it holds.
77
77
 
78
78
  None of those was what this sheet declared: the host went to
79
79
  --color-action-primary-hover on hover and no text ever read it, and the
80
- semibold on .page-link.active lost to the atom's .bd-link--active bold.
80
+ semibold on the current item lost to the atom's own current bold.
81
81
  What is left here is the box -- position, padding, the indicator -- and the
82
82
  ink is asked for through the atom's API, which is where it renders. */
83
83
  .page-link {
84
84
  position: relative;
85
- text-decoration: none !important;
86
85
  display: inline-block;
87
86
  font-size: var(--typography-body-regular-fontSize);
88
87
  font-family: var(--typography-body-regular-fontFamily);
@@ -93,7 +92,7 @@ export const pageSwitcherStyles = css`
93
92
  A host's padding does not extend the anchor inside it, so this rule used
94
93
  to build a 44px-tall row around a 24px-tall target: measured 93x44 on the
95
94
  host with a 93x24 <a> inside it, and elementsFromPoint 4px below the top
96
- edge came back bd-page-switcher > bd-root > div with no <a> in the stack at
95
+ edge came back bd-page-switcher > bd-root (the former Storybook wrapper) > div with no <a> in the stack at
97
96
  all. The top and bottom 10px of every item were dead, 45% of the height a
98
97
  reader aims at.
99
98
 
@@ -130,14 +129,24 @@ export const pageSwitcherStyles = css`
130
129
  position: absolute;
131
130
  left: var(--spacing-0);
132
131
  bottom: calc(-1 * var(--spacing-16));
133
- width: 0%;
132
+ /* Grown with scale from the inline start, not with width -- see
133
+ bd-tab-list's underline, the same line. */
134
+ width: 100%;
135
+ scale: 0 1;
136
+ transform-origin: left center;
134
137
  height: var(--indicator-underline-height);
135
138
  background-color: var(--indicator-color);
136
- transition: width var(--indicator-underline-duration) var(--indicator-underline-easing);
139
+ transition: scale var(--indicator-underline-duration) var(--indicator-underline-easing);
137
140
  }
138
141
 
139
- .page-link.active::after {
140
- width: 100%;
142
+ .page-link:dir(rtl)::after {
143
+ transform-origin: right center;
144
+ }
145
+
146
+ /* [current] is the bd-link attribute that becomes aria-current on its <a>,
147
+ so the indicator and the announcement are one state. */
148
+ .page-link[current]::after {
149
+ scale: 1;
141
150
  }
142
151
 
143
152
  /* No .page-link:focus-visible rule. .page-link is the class this component
@@ -154,4 +163,13 @@ export const pageSwitcherStyles = css`
154
163
  transition: none !important;
155
164
  }
156
165
  }
166
+
167
+ /* The indicator is a background, which forced colours repaint as Canvas;
168
+ it opts out and draws in Highlight, as bd-tab-list's does. */
169
+ @media (forced-colors: active) {
170
+ .page-link::after {
171
+ forced-color-adjust: none;
172
+ background-color: Highlight;
173
+ }
174
+ }
157
175
  `;