@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.
Files changed (175) 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 +233 -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 +1 -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 +228 -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 +56 -20
  75. package/src/components/grid/grid.js +20 -15
  76. package/src/components/grid/grid.stories.js +39 -11
  77. package/src/components/header/header-code.css.js +20 -11
  78. package/src/components/header/header-code.js +1 -1
  79. package/src/components/header/header.css.js +20 -14
  80. package/src/components/header/header.js +6 -7
  81. package/src/components/header/header.stories.js +29 -24
  82. package/src/components/heading/heading.css.js +11 -0
  83. package/src/components/hero/hero.js +10 -2
  84. package/src/components/highlight/highlight.css.js +30 -6
  85. package/src/components/icons/arrow-icon.js +4 -1
  86. package/src/components/icons/arrow-right-icon.js +5 -1
  87. package/src/components/icons/icon-element.js +18 -0
  88. package/src/components/image/image.js +29 -9
  89. package/src/components/image/image.stories.js +38 -2
  90. package/src/components/input/custom-form.stories.js +38 -7
  91. package/src/components/input/input-clipboard.css.js +15 -1
  92. package/src/components/input/input-clipboard.js +84 -21
  93. package/src/components/input/input.js +27 -7
  94. package/src/components/install-options/install-options.css.js +26 -6
  95. package/src/components/install-options/install-options.js +32 -8
  96. package/src/components/label/label.css.js +1 -1
  97. package/src/components/light-carousel/light-carousel.css.js +100 -48
  98. package/src/components/light-carousel/light-carousel.js +43 -5
  99. package/src/components/link/link.css.js +15 -15
  100. package/src/components/link/link.js +17 -1
  101. package/src/components/link/link.stories.js +20 -7
  102. package/src/components/list/list.css.js +3 -3
  103. package/src/components/logo-marquee/logo-marquee.css.js +12 -1
  104. package/src/components/logo-marquee/logo-marquee.js +33 -8
  105. package/src/components/logo-marquee/logo-marquee.stories.js +10 -4
  106. package/src/components/modal/modal.css.js +74 -40
  107. package/src/components/modal/modal.js +85 -74
  108. package/src/components/modal/modal.stories.js +27 -14
  109. package/src/components/motion-art/motion-art.js +67 -1
  110. package/src/components/page-switcher/page-switcher.css.js +27 -9
  111. package/src/components/page-switcher/page-switcher.js +11 -8
  112. package/src/components/partner-banner/partner-banner.css.js +2 -0
  113. package/src/components/picture/picture.css.js +4 -4
  114. package/src/components/picture/picture.js +13 -3
  115. package/src/components/picture/picture.stories.js +28 -2
  116. package/src/components/post-card/post-card.css.js +18 -3
  117. package/src/components/pricing-cards/adopt-styles.js +16 -0
  118. package/src/components/pricing-cards/new-pricing-card.js +2 -4
  119. package/src/components/pricing-cards/new-pricing-card.stories.js +20 -22
  120. package/src/components/pricing-cards/pricing-card-actions.css.js +8 -12
  121. package/src/components/pricing-cards/pricing-card-actions.js +26 -13
  122. package/src/components/pricing-cards/pricing-card-container.css.js +4 -3
  123. package/src/components/pricing-cards/pricing-card-container.js +10 -4
  124. package/src/components/pricing-cards/pricing-card-header.css.js +5 -4
  125. package/src/components/pricing-cards/pricing-card-header.js +18 -31
  126. package/src/components/pricing-cards/pricing-card-pricing.css.js +84 -61
  127. package/src/components/pricing-cards/pricing-card-pricing.js +38 -24
  128. package/src/components/pricing-cards/pricing-card-show-more.js +8 -3
  129. package/src/components/pricing-cards/pricing-card.css.js +75 -41
  130. package/src/components/pricing-cards/pricing-card.js +356 -308
  131. package/src/components/progress/progress.css.js +58 -13
  132. package/src/components/progress/progress.js +13 -10
  133. package/src/components/progress/progress.stories.js +9 -7
  134. package/src/components/radio/radio-group.css.js +42 -0
  135. package/src/components/radio/radio-group.js +89 -0
  136. package/src/components/radio/radio.css.js +63 -6
  137. package/src/components/radio/radio.js +173 -140
  138. package/src/components/radio/radio.stories.js +99 -44
  139. package/src/components/radio/toggle-radio.js +44 -0
  140. package/src/components/review/review-grid.css.js +5 -1
  141. package/src/components/review/review-grid.js +2 -0
  142. package/src/components/review/review.js +13 -0
  143. package/src/components/shared/announcer.js +37 -0
  144. package/src/components/shared/fill-width.css.js +29 -0
  145. package/src/components/shared/form-control.js +194 -0
  146. package/src/components/shared/form-field.css.js +31 -3
  147. package/src/components/shared/token-scales.js +75 -26
  148. package/src/components/spotlight-section/spotlight-section.js +2 -2
  149. package/src/components/stat/stat-highlight.js +1 -1
  150. package/src/components/stat/stat.css.js +18 -3
  151. package/src/components/switch/switch.css.js +58 -5
  152. package/src/components/switch/switch.js +53 -5
  153. package/src/components/switch/switch.stories.js +30 -8
  154. package/src/components/tab-list/tab-list.css.js +51 -13
  155. package/src/components/tab-list/tab-list.js +7 -2
  156. package/src/components/tab-list/tab-list.stories.js +2 -2
  157. package/src/components/tabs/tabs.css.js +18 -1
  158. package/src/components/tabs/tabs.js +119 -41
  159. package/src/components/terminal/terminal-message.css.js +6 -1
  160. package/src/components/termsOfUse/terms.css.js +4 -2
  161. package/src/components/textarea/textarea.js +22 -7
  162. package/src/components/textarea/textarea.stories.js +12 -9
  163. package/src/components/trust-panel/trust-panel.css.js +13 -3
  164. package/src/components/ultimate-security-demo.stories.js +5 -5
  165. package/src/components/video/video.css.js +5 -0
  166. package/src/components/video/video.js +5 -0
  167. package/src/components/video/video.stories.js +12 -0
  168. package/src/components/video-player/video-player.css.js +20 -8
  169. package/src/components/video-player/video-player.js +74 -20
  170. package/src/components/video-player/video-player.stories.js +17 -3
  171. package/src/tokens/brands.stories.js +1 -1
  172. package/src/tokens/themes/index.js +2 -2
  173. package/src/tokens/typography.stories.js +4 -3
  174. package/src/vendor/motion-art/README.md +4 -1
  175. package/src/components/footer/footer-lp.css.js +0 -159
@@ -1,5 +1,5 @@
1
1
  import { css, unsafeCSS } from "lit";
2
- import { above, below } from "../shared/token-scales.js";
2
+ import { below } from "../shared/token-scales.js";
3
3
 
4
4
  export default css`
5
5
  :host {
@@ -8,6 +8,18 @@ export default css`
8
8
  box-sizing: border-box;
9
9
  }
10
10
 
11
+ /* A brand card is the container its own layout asks: the row, the column
12
+ and the size of the art follow the card's width (BRAND, below). Only the
13
+ brand tone: a size container contributes nothing to its own intrinsic
14
+ width, and the other tones are also set in rows that size them to their
15
+ content (Foundations/Visual Alignment's card family), where one would
16
+ collapse. width: 100% for the same reason, in the grid cell a brand card
17
+ always sits in. */
18
+ :host([tone="brand"]) {
19
+ width: 100%;
20
+ container: bento-item / inline-size;
21
+ }
22
+
11
23
  .bd-bentoitem-box {
12
24
  background: var(--color-surface-container);
13
25
  border-radius: var(--card-radius);
@@ -39,10 +51,17 @@ export default css`
39
51
  }
40
52
 
41
53
 
42
- .bd-bentoitem-box:hover {
43
- transform: translateY(-3px);
44
- box-shadow: 0px 14px 40px #00000012;
45
- }
54
+ /* Only where something can hover: a tap leaves :hover on the card it
55
+ touched, so a touch screen kept the last card lifted until the next tap
56
+ landed somewhere else. */
57
+ @media (hover: hover) {
58
+ .bd-bentoitem-box:hover {
59
+ transform: translateY(-3px);
60
+ /* no token: trust-panel's card lift, the same 7% black layer -- see the
61
+ reason there. */
62
+ box-shadow: 0px 14px 40px color-mix(in srgb, var(--color-neutral-1000) 7%, transparent);
63
+ }
64
+ }
46
65
 
47
66
  /* Same reasoning as trust-panel, checked separately: the shadow is the part
48
67
  that communicates hover, the 3px is the part that moves. */
@@ -134,9 +153,9 @@ box-shadow: 0px 14px 40px #00000012;
134
153
  hover lift: the CTA is the card's one control, and a card that moves as a
135
154
  whole promises a link it does not have.
136
155
 
137
- Phone (below md): a column at the compact inset -- the copy, the art
138
- whole in a square at the card's inner width, the CTA across the card --
139
- 24 apart, at the smaller corner. */
156
+ A card narrower than 518 (every phone): a column at the compact inset --
157
+ the copy, the art whole in a square at the card's inner width, the CTA
158
+ across the card -- 24 apart, at the smaller corner. */
140
159
  :host([tone="brand"]) .bd-bentoitem-box {
141
160
  position: relative;
142
161
  overflow: hidden;
@@ -150,13 +169,23 @@ box-shadow: 0px 14px 40px #00000012;
150
169
  }
151
170
 
152
171
  /* A set of brand cards shares one row height (bento-grid.js), so a card
153
- with shorter copy is taller than its content. On a phone the slack goes
154
- above the CTA, which keeps every card's CTA on its bottom edge rather
155
- than leaving a gap under the shortest one. */
156
- @media ${unsafeCSS(below("md"))} {
172
+ with shorter copy is taller than its content. In the column the slack
173
+ goes above the CTA, which keeps every card's CTA on its bottom edge
174
+ rather than leaving a gap under the shortest one.
175
+
176
+ In the column the CTA also runs the card's width, as the Figma phone
177
+ frame draws it; in the row it hugs its label. --bd-button-width is
178
+ bd-button's width hook. It followed the screen (below md) while the
179
+ layout followed the card, so a 518-543 card on a 550-575 screen drew the
180
+ row with a CTA stretched across its 300 copy column. */
181
+ @container bento-item (width < 518px) {
157
182
  :host([tone="brand"]) .bd-bentoitem-cta {
158
183
  margin-block-start: auto;
159
184
  }
185
+
186
+ :host([tone="brand"]) .bd-bentoitem-cta ::slotted(*) {
187
+ --bd-button-width: 100%;
188
+ }
160
189
  }
161
190
 
162
191
  :host([tone="brand"]) .bd-bentoitem-box:hover {
@@ -215,12 +244,19 @@ box-shadow: 0px 14px 40px #00000012;
215
244
  color: var(--color-brand-on-fill);
216
245
  }
217
246
 
218
- /* From md, tablet and desktop alike, the card is a row at the card inset:
219
- the copy over the CTA in a 300 column on the near side, 24 apart and
220
- centred down the card, and the art from the column's edge out to the
221
- card's, bleeding through the inset. The featured card's column is a
222
- share of the row instead. */
223
- @media ${unsafeCSS(above("md"))} {
247
+ /* A card 518 wide or wider, tablet and desktop alike, is a row at the
248
+ card inset: the copy over the CTA in a 300 column on the near side, 24
249
+ apart and centred down the card, and the art from the column's edge out
250
+ to the card's, bleeding through the inset. The featured card's column is
251
+ a share of the row instead.
252
+
253
+ 518 is the narrowest card the frames draw as a row -- one of the pair at
254
+ xl, half the 1060 column less the gap -- and it reads the card, not the
255
+ screen: it was md, which gave a card in a narrow column at desktop the
256
+ phone's column, and the 656 tablet card and the 518 pair the same row
257
+ for different reasons. Measured: the column up to 511 wide (575 in
258
+ Storybook), the row from 518, in every story. */
259
+ @container bento-item (width >= 518px) {
224
260
  :host([tone="brand"]) .bd-bentoitem-box {
225
261
  display: grid;
226
262
  /* no token: the copy's measure, the 300 every frame gives it */
@@ -264,27 +300,30 @@ box-shadow: 0px 14px 40px #00000012;
264
300
  margin-inline-end: calc(-1 * var(--spacing-32));
265
301
  }
266
302
 
267
- /* Beside the copy the art is larger than its box, as the frames draw it:
268
- held against the copy, centred down the card, and running off the
269
- card's outer edge and its top and bottom -- never off the side its
270
- badges and pills face. 135% of the card's height is the tablet frame's
271
- 434 square on a 321 card; a box wider than that, the featured card's,
272
- takes its own width. */
303
+ /* Beside the copy the art takes the card's height, so in one of the
304
+ desktop pair -- whose art box is a tall strip -- the stack and the
305
+ globe stay in the card beside their pills; a box wider than that, the
306
+ featured card's, takes its own width. */
273
307
  ::slotted(bd-motion-art[slot="media"]) {
274
308
  inset-inline-start: 0;
275
- width: max(100cqw, 135cqh);
276
- margin-block-start: calc(max(100cqw, 135cqh) / -2);
309
+ width: max(100cqw, 100cqh);
310
+ margin-block-start: calc(max(100cqw, 100cqh) / -2);
277
311
  margin-inline-start: 0;
278
312
  }
279
313
  }
280
314
 
281
- /* From lg the desktop frame pairs the cards, and a half-width card's art
282
- box is a tall strip: the art takes the card's height, so the stack and
283
- the globe stay in the card beside their pills. */
284
- @media ${unsafeCSS(above("lg"))} {
315
+ /* A card a whole tablet column wide or wider draws the art larger than its
316
+ box, as the tablet frame does: held against the copy, centred down the
317
+ card, and running off the card's outer edge and its top and bottom --
318
+ never off the side its badges and pills face. 135% of the card's height
319
+ is that frame's 434 square on a 321 card. The pair never reaches 656
320
+ (634 at the widest page) and a card 880 wide is the desktop's, so this
321
+ is the tablet card's rule, between the two; it was the md-to-lg band of
322
+ the screen, where every card is the 656 column. */
323
+ @container bento-item (656px <= width < 880px) {
285
324
  ::slotted(bd-motion-art[slot="media"]) {
286
- width: max(100cqw, 100cqh);
287
- margin-block-start: calc(max(100cqw, 100cqh) / -2);
325
+ width: max(100cqw, 135cqh);
326
+ margin-block-start: calc(max(100cqw, 135cqh) / -2);
288
327
  }
289
328
  }
290
329
 
@@ -3,7 +3,6 @@ import { tokens } from "../../tokens/tokens.js";
3
3
  import "../badge/badge.js";
4
4
  import "../heading/heading.js";
5
5
  import "../paragraph/paragraph.js";
6
- import { below } from "../shared/token-scales.js";
7
6
  import bentoItemCSS from "./bento-item.css.js";
8
7
 
9
8
  class BentoItem extends LitElement {
@@ -34,40 +33,12 @@ class BentoItem extends LitElement {
34
33
  this.tone = "default";
35
34
  this.badge = "";
36
35
  this.as = "h3";
37
- this._ctas = [];
38
- this._ownWidth = new WeakMap();
39
- this._phone = window.matchMedia?.(below("md"));
40
- this._onPhone = () => this._syncCtas();
41
36
  }
42
37
 
43
38
  connectedCallback() {
44
39
  super.connectedCallback();
45
40
  // The grid's track is a role="list"; each card is one of its items.
46
41
  if (!this.hasAttribute("role")) this.setAttribute("role", "listitem");
47
- this._phone?.addEventListener("change", this._onPhone);
48
- }
49
-
50
- disconnectedCallback() {
51
- super.disconnectedCallback();
52
- this._phone?.removeEventListener("change", this._onPhone);
53
- }
54
-
55
- _onCtaSlot(e) {
56
- this._ctas = e.target.assignedElements({ flatten: true });
57
- this._syncCtas();
58
- }
59
-
60
- /* On a phone the CTA runs the card's width, as the Figma phone frame draws
61
- it; from md it hugs its label. A bd-button-link stretches only through
62
- its own fullwidth attribute, so the card sets it below md and gives an
63
- author's own setting back from md. */
64
- _syncCtas() {
65
- const phone = !!this._phone?.matches;
66
- for (const el of this._ctas) {
67
- if (!("fullWidth" in el)) continue;
68
- if (!this._ownWidth.has(el)) this._ownWidth.set(el, el.hasAttribute("fullwidth"));
69
- el.toggleAttribute("fullwidth", phone || this._ownWidth.get(el));
70
- }
71
42
  }
72
43
 
73
44
  /* The homepage AI card, drawn in the foundation Figma file as Bento card:
@@ -87,7 +58,7 @@ class BentoItem extends LitElement {
87
58
  ${this.body ? html`<p class="bd-bentoitem-brand-body">${this.body}</p>` : ""}
88
59
  </div>
89
60
  <div class="bd-bentoitem-media"><slot name="media"></slot></div>
90
- <div class="bd-bentoitem-cta"><slot @slotchange=${this._onCtaSlot}></slot></div>
61
+ <div class="bd-bentoitem-cta"><slot></slot></div>
91
62
  </div>
92
63
  `;
93
64
  }
@@ -15,8 +15,8 @@ export const blockquoteCSS = css`
15
15
  }
16
16
 
17
17
  .quote {
18
- padding-left: var(--spacing-16);
19
- border-left: var(--border-width-4) solid var(--color-border-brand);
18
+ padding-inline-start: var(--spacing-16);
19
+ border-inline-start: var(--border-width-4) solid var(--color-border-brand);
20
20
  font-family: var(--typography-body-large-fontFamily);
21
21
  font-size: var(--typography-body-large-fontSize);
22
22
  font-weight: var(--typography-body-large-fontWeight);
@@ -13,6 +13,9 @@ export default css`
13
13
  gap: 0;
14
14
  margin: 0;
15
15
  padding: 0;
16
+ /* an <ol> for its semantics, not its numbers. Inside a <nav>, so Safari
17
+ keeps announcing it as a list without them. */
18
+ list-style: none;
16
19
  }
17
20
 
18
21
  /* Item container */
@@ -32,20 +35,19 @@ export default css`
32
35
  and :not(:last-child) could not have helped anyway, since that div is
33
36
  the only child of its root and so is always the last one. */
34
37
  .bd-breadcrumb--horizontal ::slotted(bd-breadcrumb-item:not(:last-child)) {
35
- margin-right: var(--spacing-8);
38
+ margin-inline-end: var(--spacing-8);
36
39
  }
37
40
 
38
41
  /* Divider styles */
39
42
  .bd-breadcrumb__divider {
40
- margin-left: var(--spacing-8);
41
- margin-right: var(--spacing-8);
42
- /* the "/" is rendered text and is not aria-hidden, so it needs 4.5:1;
43
+ margin-inline: var(--spacing-8);
44
+ /* The "/" is aria-hidden -- the list says what it said, item by item --
45
+ but it is still text a sighted reader reads, so it keeps 4.5:1;
43
46
  neutral-400 gave 3.23 */
44
47
  color: var(--color-text-subtle);
45
- /* no role: the "/" is real rendered text -- see the contrast note above on
46
- why it is not aria-hidden -- but it is a single glyph in a fixed-height
47
- divider, the same category as the icon-only line box rule 7 already
48
- covers for its leading. Sizing a separator is not a text role. */
48
+ /* no role: the "/" is real rendered text, but it is a single glyph in a
49
+ fixed-height divider, the same category as the icon-only line box rule 7
50
+ already covers for its leading. Sizing a separator is not a text role. */
49
51
  font-size: var(--typography-fontSize-sm);
50
52
  line-height: var(--typography-lineHeight-none);
51
53
  }
@@ -101,7 +103,6 @@ export default css`
101
103
  holds the text. */
102
104
  bd-link.bd-breadcrumb__item {
103
105
  text-decoration: none;
104
- transition: all var(--transition-duration-fast) var(--transition-easing-smooth);
105
106
  }
106
107
 
107
108
  bd-link.bd-breadcrumb__item:hover::part(link) {
@@ -17,12 +17,19 @@ export class Breadcrumb extends LitElement {
17
17
  this.noTrailingSlash = false;
18
18
  this.mobileBreakpoint = 768;
19
19
  this._isMobile = false;
20
- this._resizeObserver = null;
20
+ this._onViewport = () => { this._isMobile = this._viewport.matches; };
21
+ }
22
+
23
+ connectedCallback() {
24
+ super.connectedCallback();
25
+ if (this.hasUpdated) this._watchViewport();
26
+ }
27
+
28
+ willUpdate(changedProperties) {
29
+ if (changedProperties.has('mobileBreakpoint')) this._watchViewport();
21
30
  }
22
31
 
23
32
  firstUpdated() {
24
- this._checkMobile();
25
- this._setupResizeListener();
26
33
  this._updateChildItems();
27
34
  /* Items slotted later still have to be told, or they render with the
28
35
  constructor default. */
@@ -60,37 +67,26 @@ export class Breadcrumb extends LitElement {
60
67
  });
61
68
  }
62
69
 
63
- _checkMobile() {
64
- /* Strictly narrower, which is what the rest of the package means by a
65
- breakpoint: shared/token-scales.js derives below('md') as
66
- max-width 767.98px so that exactly 768px is the wider layout. With <=
67
- this element was the one component that read 768 as mobile, so at that
68
- one width a page could show a vertical breadcrumb above a desktop
69
- anchor nav. */
70
- this._isMobile = window.innerWidth < this.mobileBreakpoint;
71
- }
72
-
73
- _setupResizeListener() {
74
- let resizeTimeout;
75
- const handleResize = () => {
76
- clearTimeout(resizeTimeout);
77
- resizeTimeout = setTimeout(() => {
78
- const wasMobile = this._isMobile;
79
- this._checkMobile();
80
- if (wasMobile !== this._isMobile) {
81
- this.requestUpdate();
82
- }
83
- }, 100);
84
- };
85
-
86
- window.addEventListener('resize', handleResize);
87
- this._resizeObserver = handleResize;
70
+ /* Vertical below mobileBreakpoint, as a media query the browser evaluates:
71
+ it says when the width crosses the breakpoint, so nothing reads the
72
+ window's width on every resize. It was window.innerWidth on a debounced
73
+ resize listener. The breakpoint is an attribute, so the query is built
74
+ from it, and rebuilt when it changes.
75
+
76
+ Strictly narrower, which is what the rest of the package means by a
77
+ breakpoint: shared/token-scales.js derives below('md') as max-width
78
+ 767.98px so that exactly 768px is the wider layout. With <= this element
79
+ was the one component that read 768 as mobile, so at that one width a
80
+ page could show a vertical breadcrumb above a desktop anchor nav. */
81
+ _watchViewport() {
82
+ this._viewport?.removeEventListener('change', this._onViewport);
83
+ this._viewport = window.matchMedia(`(width < ${this.mobileBreakpoint}px)`);
84
+ this._viewport.addEventListener('change', this._onViewport);
85
+ this._isMobile = this._viewport.matches;
88
86
  }
89
87
 
90
88
  disconnectedCallback() {
91
- if (this._resizeObserver) {
92
- window.removeEventListener('resize', this._resizeObserver);
93
- }
89
+ this._viewport?.removeEventListener('change', this._onViewport);
94
90
  super.disconnectedCallback();
95
91
  }
96
92
 
@@ -100,9 +96,9 @@ export class Breadcrumb extends LitElement {
100
96
  return html`
101
97
  <nav class="bd-breadcrumb bd-breadcrumb--${orientation}"
102
98
  aria-label="Breadcrumb">
103
- <div class="bd-breadcrumb__items">
99
+ <ol class="bd-breadcrumb__items">
104
100
  <slot></slot>
105
- </div>
101
+ </ol>
106
102
  </nav>
107
103
  `;
108
104
  }
@@ -126,6 +122,11 @@ export class BreadcrumbItem extends LitElement {
126
122
 
127
123
  constructor() {
128
124
  super();
125
+ /* Each item is an <li> of the breadcrumb's <ol> in the flattened tree, so
126
+ a screen reader says "list, 3 items" and where the reader is in it. The
127
+ role is the element's own, through ElementInternals, so no attribute is
128
+ written on markup the page owns. */
129
+ this.attachInternals().role = 'listitem';
129
130
  this.href = '';
130
131
  this.current = false;
131
132
  this.noTrailingSlash = false;
@@ -169,7 +170,7 @@ export class BreadcrumbItem extends LitElement {
169
170
  return html`
170
171
  <div class="bd-breadcrumb-item">
171
172
  ${content}
172
- ${showDivider ? html`<span class="bd-breadcrumb__divider">/</span>` : ''}
173
+ ${showDivider ? html`<span class="bd-breadcrumb__divider" aria-hidden="true">/</span>` : ''}
173
174
  </div>
174
175
  `;
175
176
  }
@@ -88,6 +88,25 @@ export default css`
88
88
  --bd-button-border-width: var(--border-width-2);
89
89
  }
90
90
 
91
+ /* ============================================
92
+ WIDTH
93
+ --bd-button-width is how wide the button is, and it is the container's
94
+ to set: on the element, or from a ::slotted() rule, which is the one
95
+ thing a component holding a slotted button can reach. bd-anchor-nav and
96
+ bd-bento-item run their CTA full width on a phone this way, where they
97
+ used to listen to the window and write fullwidth on the page's own
98
+ element. Unset, the button hugs its label as before. fullwidth and align
99
+ still win -- :where() gives the inner rule no weight -- and an icon-only
100
+ circle ignores it, as it ignores fullwidth.
101
+ ============================================ */
102
+ :host(:not([icon-only])) {
103
+ width: var(--bd-button-width, auto);
104
+ }
105
+
106
+ :where(.button:not(.button--icon-only)) {
107
+ width: var(--bd-button-width, auto);
108
+ }
109
+
91
110
  /* ============================================
92
111
  ALIGNMENT
93
112
  ============================================ */
@@ -149,13 +168,10 @@ export default css`
149
168
 
150
169
  This used to be driven from JavaScript: two requestAnimationFrame hops
151
170
  checked :focus-visible and set a data attribute the CSS then styled.
152
- :focus-visible does that natively.
171
+ :focus-visible does that natively. There is no :focus { outline: none }
172
+ beside it: the browser's own ring is a :focus-visible ring too, so a
173
+ pointer focus never drew one, and the rule below replaces it.
153
174
  ============================================ */
154
- button:focus,
155
- a:focus {
156
- outline: none;
157
- }
158
-
159
175
  .button:focus-visible {
160
176
  outline: var(--bd-button-focus-ring);
161
177
  outline-offset: var(--button-shared-focus-outlineOffset);
@@ -321,18 +337,26 @@ export default css`
321
337
 
322
338
  /* ============================================
323
339
  HOVER ARROW — accent, unless no-arrow
324
- The button keeps its width: the label slides left and the arrow,
325
- absolutely positioned, fades in where the label was.
340
+ The button keeps its width: the label slides toward the inline start
341
+ and the arrow, absolutely positioned at the end, fades in where the
342
+ label was. --_dir turns both slides round on a right-to-left page, the
343
+ multiplier bd-pagination-dots uses; the arrow itself mirrors there (see
344
+ icon-element.js), so it still points the way the label moved from.
326
345
  ============================================ */
327
346
  .button__label {
328
347
  display: inline-block;
329
348
  }
330
349
 
331
350
  .button--with-arrow {
351
+ --_dir: 1;
332
352
  position: relative;
333
353
  overflow: hidden;
334
354
  }
335
355
 
356
+ :host(:dir(rtl)) .button--with-arrow {
357
+ --_dir: -1;
358
+ }
359
+
336
360
  .button--with-arrow .button__label {
337
361
  transition: transform var(--transition-duration-normal) var(--transition-easing-smooth);
338
362
  }
@@ -340,34 +364,35 @@ export default css`
340
364
  .button--with-arrow .button__arrow {
341
365
  position: absolute;
342
366
  top: 50%;
343
- right: var(--spacing-12);
367
+ inset-inline-end: var(--spacing-12);
344
368
  opacity: 0;
345
- transform: translate(calc(-1 * var(--spacing-8)), -50%);
369
+ transform: translate(calc(-1 * var(--_dir) * var(--spacing-8)), -50%);
346
370
  transition:
347
371
  opacity var(--transition-duration-normal) var(--transition-easing-smooth),
348
372
  transform var(--transition-duration-normal) var(--transition-easing-smooth);
349
373
  pointer-events: none;
350
374
  }
351
375
 
352
- .button--with-arrow:hover .button__label,
353
376
  .button--with-arrow:focus-visible .button__label {
354
- transform: translateX(calc(-1 * var(--spacing-12)));
377
+ transform: translateX(calc(-1 * var(--_dir) * var(--spacing-12)));
355
378
  }
356
379
 
357
- .button--with-arrow:hover .button__arrow,
358
380
  .button--with-arrow:focus-visible .button__arrow {
359
381
  opacity: 1;
360
382
  transform: translate(var(--spacing-0), -50%);
361
383
  }
362
384
 
363
- /* A touch screen has no real hover; do not leave the arrow stuck after a tap. */
364
- @media (hover: none) {
385
+ /* Only where a pointer can hover. A touch screen has no real hover, and a
386
+ tap left the arrow stuck out; this was a (hover: none) block undoing the
387
+ hover rules after the fact, and asking first is the same thing said once. */
388
+ @media (hover: hover) {
365
389
  .button--with-arrow:hover .button__label {
366
- transform: none;
390
+ transform: translateX(calc(-1 * var(--_dir) * var(--spacing-12)));
367
391
  }
368
392
 
369
393
  .button--with-arrow:hover .button__arrow {
370
- opacity: 0;
394
+ opacity: 1;
395
+ transform: translate(var(--spacing-0), -50%);
371
396
  }
372
397
  }
373
398
 
@@ -3,6 +3,7 @@ import { LitElement, html, nothing } from "lit";
3
3
  import "../../tokens/tokens.js";
4
4
  import buttonsCSS from "./button.css.js";
5
5
  import { fontSize, fontWeight } from "../shared/token-scales.js";
6
+ import { FormControl } from "../shared/form-control.js";
6
7
  // the trailing arrow on bd-contact-button; an atom now, not a local registry
7
8
  import "../icons/arrow-icon.js";
8
9
 
@@ -32,6 +33,7 @@ const SIZE_CLASS = { sm: "button--small", md: "button--medium", lg: "button--lar
32
33
  const RESPONSIVE_SIZE_CLASS = "button--responsive";
33
34
  const SURFACES = ["light", "dark", "brand"];
34
35
  const SHAPES = ["default", "rounded"];
36
+ const TYPES = ["button", "submit", "reset"];
35
37
 
36
38
  /* custom-click bubbles and is composed, like every sibling event in the
37
39
  package -- bd-checkbox's and bd-radio's change, bd-switch's and
@@ -49,6 +51,11 @@ const clickEvent = () => new CustomEvent("custom-click", { bubbles: true, compos
49
51
  * navigates. No CSS substitutes for it — only the link appears in a screen
50
52
  * reader's list of links and offers open-in-new-tab, and only the button
51
53
  * responds to Space as well as Enter.
54
+ *
55
+ * That element is exposed as part="button", for what only the element that
56
+ * takes the click can do -- a stretched-link ::after across a card, as
57
+ * bd-audience-card draws. Width has its own hook, --bd-button-width, because a
58
+ * part cannot be reached through ::slotted().
52
59
  */
53
60
  class BdButtonBase extends LitElement {
54
61
  static styles = [buttonsCSS];
@@ -208,17 +215,66 @@ class BdButtonBase extends LitElement {
208
215
  }
209
216
  }
210
217
 
211
- /** Performs an action in place. */
212
- class Button extends BdButtonBase {
218
+ /**
219
+ * Performs an action in place -- and, with type="submit" or "reset", that
220
+ * action is the form it sits in.
221
+ *
222
+ * The <button> it renders is in this shadow root, where it has no form owner,
223
+ * so a type on it could never reach a form: a page that wanted bd-button to
224
+ * submit had to fall back to a native one. The element is form-associated
225
+ * instead (shared/form-control.js), and does the submit or reset itself:
226
+ * requestSubmit(), so the form validates first and fires submit as it would
227
+ * for a native button, or reset(). A <fieldset disabled> around it disables
228
+ * it too, and el.click() presses it.
229
+ *
230
+ * type defaults to "button", not the native "submit": every bd-button on a
231
+ * page today was written to do nothing to its form, and stays that way.
232
+ */
233
+ class Button extends FormControl(BdButtonBase) {
234
+ static properties = {
235
+ type: { type: String }
236
+ };
237
+
238
+ constructor() {
239
+ super();
240
+ this.type = "button";
241
+ }
242
+
243
+ willUpdate(changed) {
244
+ super.willUpdate(changed);
245
+ if (changed.has("type") && !TYPES.includes(this.type)) this.type = "button";
246
+ }
247
+
248
+ get _control() {
249
+ return this.renderRoot?.querySelector?.("button");
250
+ }
251
+
252
+ get _inert() {
253
+ return super._inert || this._formDisabled;
254
+ }
255
+
256
+ // el.click() and a <label for> press it, as they press a native button
257
+ _activate() {
258
+ this._control?.click();
259
+ }
260
+
261
+ _handleClick(e) {
262
+ super._handleClick(e);
263
+ if (this._inert) return;
264
+ if (this.type === "submit") this.form?.requestSubmit();
265
+ else if (this.type === "reset") this.form?.reset();
266
+ }
267
+
213
268
  render() {
214
269
  return html`
215
270
  <button
216
271
  type="button"
272
+ part="button"
217
273
  class="${this._classes}"
218
274
  aria-label="${this.label || nothing}"
219
275
  aria-busy="${this.loading ? "true" : nothing}"
220
276
  aria-describedby="${this._describedBy}"
221
- ?disabled="${this.disabled}"
277
+ ?disabled="${this.disabled || this._formDisabled}"
222
278
  style="${this._inlineStyle}"
223
279
  @click=${this._handleClick}
224
280
  >${this._content}</button>${this._description}
@@ -248,6 +304,30 @@ class ButtonLink extends BdButtonBase {
248
304
  this.rel = "";
249
305
  }
250
306
 
307
+ /* A buy link's href is the store's to fill, on the anchor in this shadow
308
+ root -- and @repobit/dex-store-elements only searches the shadow tree of a
309
+ host matching '[shadow], [data-bd-watch-shadow]' (renders/index.ts), the
310
+ same opt-in bd-header reflects. Without it the store never found the
311
+ anchor, and every buy link rendered with no href at all.
312
+
313
+ Set on connect, not in an update. The store hears of a new element from
314
+ its MutationObserver, whose callback runs before the element's first
315
+ update, and reads the opt-in then and not again. Set in willUpdate, it was
316
+ there for the links on the page when the store first looked and missing
317
+ for every link rendered after -- the cards a plan switch brings in.
318
+ connectedCallback runs inside the insertion, so the attribute and the
319
+ shadow root are both in place when the observer reads them. */
320
+ connectedCallback() {
321
+ super.connectedCallback();
322
+ this.toggleAttribute("data-bd-watch-shadow", this.buyLink);
323
+ }
324
+
325
+ // buyLink changed on a link already on the page
326
+ willUpdate(changed) {
327
+ super.willUpdate(changed);
328
+ if (changed.has("buyLink") && this.isConnected) this.toggleAttribute("data-bd-watch-shadow", this.buyLink);
329
+ }
330
+
251
331
  /* Reverse tabnabbing is the reason rather than convention: a new tab opened
252
332
  from here keeps a window.opener handle back unless rel says otherwise. An
253
333
  explicit rel always wins, so a consumer can still opt out deliberately. */
@@ -264,6 +344,7 @@ class ButtonLink extends BdButtonBase {
264
344
 
265
345
  return html`
266
346
  <a
347
+ part="button"
267
348
  href="${href}"
268
349
  target="${this.target || nothing}"
269
350
  rel="${this._rel || nothing}"
@@ -99,6 +99,23 @@ variant, so every \`variant\`, \`size\`, \`surface\` and state applies unchanged
99
99
  | \`center\` | Centers button horizontally |
100
100
  | \`right\` | Aligns button to the right |
101
101
 
102
+ ### In a form
103
+ \`bd-button\` is form-associated. \`type="submit"\` submits the form it sits
104
+ in -- the form validates first and fires \`submit\`, as for a native submit
105
+ button -- and \`type="reset"\` resets it. The default is \`type="button"\`,
106
+ which does neither: a native \`<button>\` defaults to submit, but no
107
+ \`bd-button\` could ever submit, so every one already on a page stays inert to
108
+ its form. A \`<fieldset disabled>\` around it disables it, and \`el.click()\`
109
+ presses it. A \`type="submit"\` button is also the form's default button, the
110
+ one Enter in a checkbox, radio or switch presses.
111
+
112
+ ### Width and the inner element
113
+ \`--bd-button-width\` sets how wide the button is, and a container can set it
114
+ from a \`::slotted()\` rule: \`bd-anchor-nav\` and \`bd-bento-item\` run their
115
+ CTA full width on a phone this way. \`fullwidth\` and \`align\` still win, and
116
+ an icon-only circle ignores it. The inner \`<button>\` or \`<a>\` is
117
+ \`part="button"\`.
118
+
102
119
  ### Events
103
120
  - \`custom-click\` — dispatched on click or Enter/Space keypress. It bubbles and is composed, so a wrapper can listen for it
104
121
  `