@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
@@ -70,10 +70,15 @@ export const switchCSS = css`
70
70
  --bd-switch-travel: calc(var(--dimension-40) - var(--dimension-20) - 2 * var(--bd-switch-inset));
71
71
  }
72
72
 
73
+ /* The thumb starts at the inline start and travels toward the end, so on a
74
+ right-to-left page off is on the right, as a native switch draws it.
75
+ --_dir turns the travel round, the multiplier bd-pagination-dots uses for
76
+ its fill. */
73
77
  .thumb {
78
+ --_dir: 1;
74
79
  position: absolute;
75
80
  top: var(--bd-switch-inset);
76
- left: var(--bd-switch-inset);
81
+ inset-inline-start: var(--bd-switch-inset);
77
82
  width: var(--dimension-20);
78
83
  height: var(--dimension-20);
79
84
  /* the knob on the track, white on both tracks: --color-action-on-fill,
@@ -93,7 +98,8 @@ export const switchCSS = css`
93
98
  If a second component ever needs it, that is when it earns a name. */
94
99
  label:hover .track { background: var(--color-neutral-500); }
95
100
  :host([checked]) label:hover .track { background: var(--color-action-primary-hover); }
96
- :host([checked]) .thumb { transform: translateX(var(--bd-switch-travel)); }
101
+ :host(:dir(rtl)) .thumb { --_dir: -1; }
102
+ :host([checked]) .thumb { transform: translateX(calc(var(--_dir) * var(--bd-switch-travel))); }
97
103
  /* On the checked track the thumb sits on the brand fill, so it takes the
98
104
  brand's ink; on the off track it stays white, the foundation's own pair. */
99
105
  :host([checked]) .thumb { background: var(--color-brand-on-fill); }
@@ -112,13 +118,60 @@ export const switchCSS = css`
112
118
  border-radius: var(--focus-outline-radius);
113
119
  }
114
120
 
115
- :host([disabled]) label { cursor: not-allowed; color: var(--color-text-subtle); }
116
- :host([disabled]) label:hover .track,
117
- :host([disabled]) .track { background: var(--color-border-subtle); }
121
+ /* :disabled rather than [disabled], so a <fieldset disabled> around the
122
+ switch greys it too: a form-associated element matches :disabled for
123
+ both. */
124
+ :host(:disabled) label { cursor: not-allowed; color: var(--color-text-subtle); }
125
+ :host(:disabled) label:hover .track,
126
+ :host(:disabled) .track { background: var(--color-border-subtle); }
118
127
 
119
128
  @media (prefers-reduced-motion: reduce) {
120
129
  .track, .thumb { transition: none; }
121
130
  }
131
+
132
+ /* Forced colours repaint every background as Canvas, so the track and the
133
+ thumb both vanished there, on and off alike, and only the label was left.
134
+ The two opt out and state system colours, as bd-progress does: off is a
135
+ CanvasText ring round a CanvasText knob, on is a Highlight track with a
136
+ HighlightText knob -- the pair a forced palette keeps apart for a
137
+ selected thing -- and disabled is GrayText. The ring is an outline drawn
138
+ inward, not a border, so the thumb's inset and travel are untouched. The
139
+ hover selectors are repeated because they outrank these, and the knob's
140
+ shadow goes because opting out would otherwise paint it. */
141
+ @media (forced-colors: active) {
142
+ .track,
143
+ .thumb {
144
+ forced-color-adjust: none;
145
+ }
146
+
147
+ .track,
148
+ label:hover .track {
149
+ background: Canvas;
150
+ outline: var(--border-width-1) solid CanvasText;
151
+ outline-offset: calc(-1 * var(--border-width-1));
152
+ }
153
+
154
+ .thumb {
155
+ background: CanvasText;
156
+ box-shadow: none;
157
+ }
158
+
159
+ :host([checked]) .track,
160
+ :host([checked]) label:hover .track {
161
+ background: Highlight;
162
+ outline-color: Highlight;
163
+ }
164
+
165
+ :host([checked]) .thumb { background: HighlightText; }
166
+
167
+ :host(:disabled) .track,
168
+ :host(:disabled) label:hover .track {
169
+ background: Canvas;
170
+ outline-color: GrayText;
171
+ }
172
+
173
+ :host(:disabled) .thumb { background: GrayText; }
174
+ }
122
175
  `;
123
176
 
124
177
  export default switchCSS;
@@ -1,16 +1,23 @@
1
- import { LitElement, html, nothing } from 'lit';
1
+ import { LitElement, html } from 'lit';
2
2
  // Installs the design tokens into document scope; see src/tokens/tokens.js
3
3
  import '../../tokens/tokens.js';
4
4
  import { switchCSS } from './switch.css.js';
5
+ import { FormControl, omitEmpty } from '../shared/form-control.js';
5
6
 
6
- export class BdSwitch extends LitElement {
7
+ export class BdSwitch extends FormControl(LitElement) {
7
8
  static styles = [switchCSS];
8
9
 
9
10
  static properties = {
10
11
  checked : { type: Boolean, reflect: true },
11
12
  disabled: { type: Boolean, reflect: true },
12
13
  label : { type: String },
13
- name : { type: String }
14
+ /* It always had a name and rendered it on the native input, where it did
15
+ nothing: that input is in a shadow root and has no form. The host is
16
+ what a form reads now, so the name reflects onto it -- see
17
+ shared/form-control.js. */
18
+ name : { type: String, reflect: true, converter: omitEmpty },
19
+ value : { type: String },
20
+ required: { type: Boolean }
14
21
  };
15
22
 
16
23
  constructor() {
@@ -18,6 +25,46 @@ export class BdSwitch extends LitElement {
18
25
  this.checked = false;
19
26
  this.disabled = false;
20
27
  this.label = '';
28
+ this.value = '';
29
+ this.required = false;
30
+ }
31
+
32
+ connectedCallback() {
33
+ super.connectedCallback();
34
+ // what reset returns to, as in bd-checkbox: checked reflects, so the
35
+ // attribute cannot hold the default
36
+ this._defaults ??= { checked: this.checked };
37
+ }
38
+
39
+ get _control() {
40
+ return this.renderRoot?.querySelector?.('input');
41
+ }
42
+
43
+ // a native switch toggles when its label is clicked, or on el.click()
44
+ _activate() {
45
+ this._control?.click();
46
+ }
47
+
48
+ updated() {
49
+ // with no value it submits "on", as the native checkbox under it would
50
+ this._internals.setFormValue(this.checked ? this.value || 'on' : null, String(this.checked));
51
+ this._mirrorValidity(this._control);
52
+ }
53
+
54
+ formResetCallback() {
55
+ super.formResetCallback();
56
+ this.checked = this._defaults.checked;
57
+ }
58
+
59
+ formStateRestoreCallback(state) {
60
+ this.checked = state === 'true';
61
+ }
62
+
63
+ // Enter submits the form, as from the native checkbox under it; Space toggles
64
+ _onKeydown(e) {
65
+ if (e.key !== 'Enter') return;
66
+ e.preventDefault();
67
+ this._submitImplicitly();
21
68
  }
22
69
 
23
70
  render() {
@@ -26,9 +73,10 @@ export class BdSwitch extends LitElement {
26
73
  <input
27
74
  type="checkbox"
28
75
  role="switch"
29
- name=${this.name || nothing}
30
76
  .checked=${this.checked}
31
- ?disabled=${this.disabled}
77
+ ?disabled=${this.disabled || this._formDisabled}
78
+ ?required=${this.required}
79
+ @keydown=${this._onKeydown}
32
80
  @change=${e => {
33
81
  this.checked = e.target.checked;
34
82
  // bubbles and composed, as every sibling form atom's event is: with
@@ -27,7 +27,9 @@ that difference is the whole reason both exist.
27
27
  | \`checked\` | boolean, on or off | \`false\` |
28
28
  | \`disabled\` | boolean | \`false\` |
29
29
  | \`label\` | label text | \`''\` |
30
- | \`name\` | carried for your own use | \`''\` |
30
+ | \`name\` | the name it submits under in a form | \`''\` |
31
+ | \`value\` | what it submits when on; \`on\` when empty | \`''\` |
32
+ | \`required\` | boolean, must be on to submit | \`false\` |
31
33
 
32
34
  Content can also come from the default slot, which renders after \`label\` — so
33
35
  set one or the other, not both.
@@ -41,11 +43,21 @@ It is a real \`<input type="checkbox">\` with \`role="switch"\`, inside a
41
43
  \`<label>\`, so it is keyboard-operable and announced as a switch with an on/off
42
44
  state rather than checked/unchecked.
43
45
 
44
- ### Not form-associated
45
- The input lives in this element's shadow root, and a native input inside a
46
- shadow root does not participate in an outer \`<form>\`. **\`name\` is carried but
47
- nothing is submitted** — read the state from \`bd-change\` or the \`checked\`
48
- property.
46
+ ### In a form
47
+ \`bd-switch\` is **form-associated**: a \`<form>\` around it sees it as the
48
+ native checkbox it is built on.
49
+
50
+ | | |
51
+ |---|---|
52
+ | Submit | \`name=value\` when on — \`name=on\` with no \`value\` — and nothing when off. |
53
+ | Reset | Back to the \`checked\` it joined the page with. |
54
+ | \`required\` | Blocks the submit until it is on, with the browser's own message. |
55
+ | \`<fieldset disabled>\` | Disables it and leaves it out of the submit, without touching its \`disabled\`. |
56
+ | \`<label for>\`, \`el.click()\` | Toggle it. |
57
+
58
+ A switch still takes effect immediately; that it can also be submitted is for
59
+ a settings form that saves the lot. **Fieldset → In a form** shows every
60
+ control together.
49
61
  `
50
62
  }
51
63
  }
@@ -58,7 +70,12 @@ property.
58
70
  },
59
71
  disabled: {
60
72
  control : 'boolean',
61
- description: 'Blocks interaction.',
73
+ description: 'Blocks interaction, and leaves it out of a form submit.',
74
+ table : { type: { summary: 'boolean' }, defaultValue: { summary: "false" }, category: 'State' }
75
+ },
76
+ required: {
77
+ control : 'boolean',
78
+ description: 'In a form, blocks the submit until it is on.',
62
79
  table : { type: { summary: 'boolean' }, defaultValue: { summary: "false" }, category: 'State' }
63
80
  },
64
81
  label: {
@@ -68,7 +85,12 @@ property.
68
85
  },
69
86
  name: {
70
87
  control : 'text',
71
- description: 'Carried for your own use. NOT submitted with a form — see the notes.',
88
+ description: 'The name it submits under in a form.',
89
+ table : { type: { summary: 'string' }, defaultValue: { summary: "" }, category: 'Data' }
90
+ },
91
+ value: {
92
+ control : 'text',
93
+ description: 'Submitted with a form when on; `on` when empty.',
72
94
  table : { type: { summary: 'string' }, defaultValue: { summary: "" }, category: 'Data' }
73
95
  }
74
96
  }
@@ -59,7 +59,7 @@ export const tabListCSS = css`
59
59
  own. An 18px label sat on IBM Plex Sans's own metric while the nav bars
60
60
  beside it sat on a declared 24px -- and a leading nobody declares is the
61
61
  blind spot neither gate can see: lint:tokens needs a DECLARED value to
62
- report, and verify:typography only fails on multi-line text, which a
62
+ report, and typography coverage only fails on multi-line text, which a
63
63
  single-line tab label never is. */
64
64
  font-size: var(--bd-tab-font-size, var(--typography-body-regular-fontSize));
65
65
  line-height: var(--bd-tab-line-height, var(--typography-body-regular-lineHeight));
@@ -74,11 +74,23 @@ export const tabListCSS = css`
74
74
  position: absolute;
75
75
  left: 0;
76
76
  bottom: 0;
77
- width: 0;
78
- transition: width var(--bd-tab-underline-duration, var(--indicator-underline-duration))
77
+ /* Full width, scaled to nothing at rest and grown with scale, as
78
+ bd-pagination-dots grows its fill: the compositor draws it, where the
79
+ width transition that stood here re-laid the line out every frame. It
80
+ grows from the inline start. :dir() on the button rather than :host(),
81
+ because the stories use this sheet at document scope, where :host()
82
+ matches nothing. */
83
+ width: 100%;
84
+ scale: 0 1;
85
+ transform-origin: left center;
86
+ transition: scale var(--bd-tab-underline-duration, var(--indicator-underline-duration))
79
87
  var(--indicator-underline-easing);
80
88
  }
81
89
 
90
+ .bd-tab-button:dir(rtl)::after {
91
+ transform-origin: right center;
92
+ }
93
+
82
94
  /* The transition two rules up had nothing to animate on pointer: this sheet
83
95
  declared a colour transition and then no :hover rule anywhere, so a tab
84
96
  was the one control in the package that gave no feedback under the
@@ -88,21 +100,25 @@ export const tabListCSS = css`
88
100
  interactive element under the pointer -- bd-link's :hover and the anchor
89
101
  nav's engaged dropdown option both resolve to it -- and it is a step
90
102
  darker than the resting --color-text-brand, so the change is visible
91
- without becoming the selected ink. Excluding .bd-selected keeps the
92
- selected tab's text/primary from moving under the cursor. */
93
- .bd-tab-button:hover:not(.bd-selected) {
103
+ without becoming the selected ink. Excluding the selected tab keeps its
104
+ text/primary from moving under the cursor.
105
+
106
+ Selected is read off aria-selected, the attribute the tab already
107
+ carries for a screen reader, rather than a class kept in step with it:
108
+ what is drawn and what is announced cannot disagree. */
109
+ .bd-tab-button:hover:not([aria-selected="true"]) {
94
110
  color: var(--color-action-primary-active);
95
111
  }
96
112
 
97
- .bd-tab-button.bd-selected::after {
98
- width: 100%;
113
+ .bd-tab-button[aria-selected="true"]::after {
114
+ scale: 1;
99
115
  }
100
116
 
101
- .bd-tab-button.bd-selected {
117
+ .bd-tab-button[aria-selected="true"] {
102
118
  color: var(--bd-tab-color-selected, var(--color-text-primary));
103
119
  /* no role: the weight that marks the current item -- a state or modifier
104
120
  weight, not a text-content type. See button.css.js's .button--bold for
105
- the argument, and bd-link's .bd-link--active, which is the same 700 on
121
+ the argument, and bd-link's current link, which is the same 700 on
106
122
  the same job in the other two components of this family. The tab used to
107
123
  carry semibold at rest AND selected, so its weight said nothing about
108
124
  which item you were on -- colour and the indicator carried it alone. */
@@ -136,6 +152,17 @@ export const tabListCSS = css`
136
152
  }
137
153
  }
138
154
 
155
+ /* The underline is a background, and forced colours repaint every
156
+ background as Canvas, so the selected tab lost its line and kept only
157
+ its weight. It opts out and draws in Highlight, the system colour for a
158
+ selected thing. */
159
+ @media (forced-colors: active) {
160
+ .bd-tab-button::after {
161
+ forced-color-adjust: none;
162
+ background: Highlight;
163
+ }
164
+ }
165
+
139
166
  /* Narrower than sm. A media condition cannot read a custom property, so
140
167
  below() interpolates the value; 600px was on no scale at all, and the
141
168
  576px that replaced it still matched at exactly 576px, where sm begins. */
@@ -224,12 +251,12 @@ export const contentSwitcherCSS = css`
224
251
  background-color var(--transition-duration-fast) var(--transition-easing-smooth);
225
252
  }
226
253
 
227
- .bd-tabs-container--switcher .bd-tab-button.bd-selected {
254
+ .bd-tabs-container--switcher .bd-tab-button[aria-selected="true"] {
228
255
  background: var(--color-surface-default);
229
256
  }
230
257
 
231
258
  /* The underline belongs to the other appearance. Left as display:none rather
232
- than content:none so the base rule's width transition has nothing to
259
+ than content:none so the base rule's scale transition has nothing to
233
260
  animate either. */
234
261
  .bd-tabs-container--switcher .bd-tab-button::after {
235
262
  display: none;
@@ -240,7 +267,7 @@ export const contentSwitcherCSS = css`
240
267
  The unselected option is already white, so the pointer affordance is the
241
268
  pill appearing under it -- white at 12%, which reads on blue-500 without
242
269
  competing with the selected option's solid white. */
243
- .bd-tabs-container--switcher .bd-tab-button:hover:not(.bd-selected) {
270
+ .bd-tabs-container--switcher .bd-tab-button:hover:not([aria-selected="true"]) {
244
271
  color: var(--color-brand-on-fill);
245
272
  background: var(--color-border-container-inverse);
246
273
  }
@@ -250,6 +277,17 @@ export const contentSwitcherCSS = css`
250
277
  transition: none;
251
278
  }
252
279
  }
280
+
281
+ /* The pill is the whole of the selected state here, and forced colours
282
+ repaint it -- and the track under it -- as Canvas: every option read the
283
+ same. The selected one opts out into the system's selected pair. */
284
+ @media (forced-colors: active) {
285
+ .bd-tabs-container--switcher .bd-tab-button[aria-selected="true"] {
286
+ forced-color-adjust: none;
287
+ background: Highlight;
288
+ color: HighlightText;
289
+ }
290
+ }
253
291
  `;
254
292
 
255
293
  export default tabListCSS;
@@ -135,8 +135,13 @@ export class BdTabList extends LitElement {
135
135
  const last = this.tabs.length - 1;
136
136
  if (last < 0) return;
137
137
 
138
+ /* The arrows follow the strip as it is drawn: on a right-to-left page the
139
+ next tab is to the left, so ArrowLeft moves to it. */
140
+ const rtl = this.matches(":dir(rtl)");
141
+ const key = rtl ? { ArrowRight: "ArrowLeft", ArrowLeft: "ArrowRight" }[event.key] ?? event.key : event.key;
142
+
138
143
  let next;
139
- switch (event.key) {
144
+ switch (key) {
140
145
  case "ArrowRight": next = this.selected === last ? 0 : this.selected + 1; break;
141
146
  case "ArrowLeft": next = this.selected === 0 ? last : this.selected - 1; break;
142
147
  case "Home": next = 0; break;
@@ -166,7 +171,7 @@ export class BdTabList extends LitElement {
166
171
  aria-selected=${isSelected ? "true" : "false"}
167
172
  aria-controls=${this.panelId || nothing}
168
173
  tabindex=${isSelected ? "0" : "-1"}
169
- class="bd-tab-button ${isSelected ? "bd-selected" : ""}"
174
+ class="bd-tab-button"
170
175
  @click=${() => this._select(index)}
171
176
  >
172
177
  ${tab.icon
@@ -43,8 +43,8 @@ underline, and the WAI-ARIA tabs keyboard pattern. It owns no panel and no
43
43
  surrounding layout — the section using it decides what a panel is.
44
44
 
45
45
  It was extracted from \`<bd-tabs>\`, \`<bd-tabs-component>\` and
46
- \`<bd-tabs-component-family>\`, which each hand-rolled the same strip. Those three
47
- now compose this one.
46
+ \`<bd-tabs-component-family>\`, which each hand-rolled the same strip. \`<bd-tabs>\`
47
+ composes this one now; the other two are gone.
48
48
 
49
49
  ### Usage
50
50
  \`\`\`js
@@ -39,12 +39,29 @@ export default css`
39
39
  /* The tab strip itself lives in Components/Tab List (tabListCSS, included in
40
40
  static styles above). Only this section's own layout stays here. */
41
41
 
42
- /* Panel — full width, fara padding inline */
42
+ /* Panel — full width, fara padding inline. Every panel is rendered into the
43
+ one cell, so the row is the tallest panel's height and a tab switch moves
44
+ nothing below the section (see _cloneOf in tabs.js). minmax(0, 1fr) keeps
45
+ the track at the wrapper's width: an auto track would grow to the widest
46
+ panel's min-content and lay the visible panel out wider than the column. */
43
47
  .bd-panel-wrapper {
48
+ display: grid;
49
+ grid-template-columns: minmax(0, 1fr);
44
50
  width: 100%;
45
51
  box-sizing: border-box;
46
52
  }
47
53
 
54
+ .bd-panel {
55
+ grid-area: 1 / 1;
56
+ }
57
+
58
+ /* Out of sight, still in layout -- display: none would take the inactive
59
+ panels out of the height they are here to hold. inert keeps them out of
60
+ the tab order and the accessibility tree. */
61
+ .bd-panel[inert] {
62
+ visibility: hidden;
63
+ }
64
+
48
65
  /* No column rules. A tab panel's columns are bd-features' -- every panel in
49
66
  every story wraps its content in <bd-features>, which renders .bd-col,
50
67
  .col-icon-wrapper, .col-title-wrapper, .col-title and .col-description
@@ -1,7 +1,6 @@
1
1
  import { LitElement, html } from "lit";
2
2
  // Installs the design tokens into document scope; see src/tokens/tokens.js
3
3
  import "../../tokens/tokens.js";
4
- import { keyed } from "lit/directives/keyed.js";
5
4
  import "../features/features.js";
6
5
  import "../heading/heading.js";
7
6
  import "../highlight/highlight.js";
@@ -20,25 +19,70 @@ class BdTabPanel extends LitElement {
20
19
  }
21
20
  customElements.define("bd-tab-panel", BdTabPanel);
22
21
 
22
+ /** Every element under `node`, through every shadow root. */
23
+ function* composedTree(node) {
24
+ for (const root of [node, node.shadowRoot].filter(Boolean)) {
25
+ for (const el of root.querySelectorAll("*")) {
26
+ yield el;
27
+ if (el.shadowRoot) yield* composedTree(el.shadowRoot);
28
+ }
29
+ }
30
+ }
31
+
32
+ /* Holds a hidden panel still: its media paused and kept from autoplaying, and
33
+ every component that moves on its own -- this package spells that `paused`:
34
+ bd-hero, bd-logo-marquee, bd-motion-art, bd-pagination-dots -- paused.
35
+ Components render after they upgrade, so what they render is reached a
36
+ round later.
37
+
38
+ An embed is unloaded instead: it is a page from another origin, which no
39
+ script here can pause, so a bd-video-player whose YouTube URL asks for
40
+ autoplay played in a tab nobody had opened. A sizer is never shown, and a
41
+ frame's box is its own CSS, not its document's, so the panel's height
42
+ holds without it. Images and video stay: their size is their file's. */
43
+ function hold(el) {
44
+ if (el instanceof HTMLMediaElement) {
45
+ el.autoplay = false;
46
+ el.pause();
47
+ } else if (el instanceof HTMLIFrameElement) {
48
+ // srcdoc outranks src, so it goes first
49
+ el.removeAttribute("srcdoc");
50
+ if (el.getAttribute("src") !== "about:blank") el.src = "about:blank";
51
+ } else if (el.localName.includes("-") && "paused" in el) {
52
+ el.paused = true;
53
+ }
54
+ }
55
+
56
+ async function quiet(panel) {
57
+ for (let round = 0; round < 3; round++) {
58
+ const all = [...composedTree(panel)];
59
+ all.forEach(hold);
60
+ const pending = all.filter(el => el.isUpdatePending);
61
+ if (!pending.length) return;
62
+ await Promise.all(pending.map(el => el.updateComplete.catch(() => {})));
63
+ }
64
+ }
65
+
23
66
  class BdTabs extends LitElement {
24
67
  static properties = {
25
- title : { type: String },
26
- subtitle : { type: String },
27
- highlightText : { type: String, attribute: "highlight-text" },
28
- selectedTab : { type: Number, state: true },
29
- _panelMinHeight: { type: Number, state: true },
30
- bgBlue : { type: Boolean, reflect: true, attribute: "bg-blue" } };
68
+ title : { type: String },
69
+ subtitle : { type: String },
70
+ highlightText: { type: String, attribute: "highlight-text" },
71
+ selectedTab : { type: Number, state: true },
72
+ bgBlue : { type: Boolean, reflect: true, attribute: "bg-blue" }
73
+ };
31
74
 
32
75
  static styles = [ensembleCSS, tabListCSS, tabsCSS];
33
76
 
34
77
  constructor() {
35
78
  super();
36
- this.title = "";
37
- this.subtitle = "";
38
- this.highlightText = "";
39
- this.selectedTab = 0;
40
- this._panelMinHeight = 0;
41
- this.bgBlue = false;
79
+ this.title = "";
80
+ this.subtitle = "";
81
+ this.highlightText = "";
82
+ this.selectedTab = 0;
83
+ this.bgBlue = false;
84
+ this._clones = new WeakMap();
85
+ this._sizers = [];
42
86
  }
43
87
 
44
88
  _getPanels() {
@@ -49,37 +93,70 @@ class BdTabs extends LitElement {
49
93
  this.selectedTab = index;
50
94
  }
51
95
 
52
- async firstUpdated() {
53
- await this.updateComplete;
54
- await this._measureAllPanels();
96
+ /**
97
+ * Every panel is rendered, all of them in one grid cell, so the wrapper is
98
+ * as tall as the tallest panel and switching tabs moves nothing below it.
99
+ * The inactive ones are `inert` and hidden (tabs.css.js), which keeps them
100
+ * out of the tab order and the accessibility tree while they still take
101
+ * part in layout.
102
+ *
103
+ * This replaces measuring. The component used to select every tab in turn
104
+ * on load, read each panel's height two frames later and pin the tallest as
105
+ * a min-height: the strip visibly cycled through its tabs as the page
106
+ * opened, and the number was never taken again, so a font arriving or a
107
+ * resize that rewrapped a panel left it wrong. The grid answers the same
108
+ * question at every layout.
109
+ *
110
+ * A panel is a copy of its bd-tab-panel child, and a hidden one is only
111
+ * there for its height: a sizer, never shown. It is held still (quiet()),
112
+ * because hidden is not stopped -- a video in it would play from the moment
113
+ * the page opened, and an intro that waits to be on screen would run where
114
+ * nobody sees it and be over by the time the tab was opened. Opening a tab
115
+ * swaps its sizer for a fresh copy, so what it holds starts then, as on a
116
+ * page; leaving it swaps the copy back for a sizer, so its accordions return
117
+ * to their authored state and its video stops, which is what leaving did
118
+ * when only the active panel was in the DOM. A copy is kept while its panel
119
+ * stays as it is, so a re-render does not rebuild the panel being read.
120
+ */
121
+ _cloneOf(panel, live) {
122
+ let copy = this._clones.get(panel);
123
+ if (copy?.live !== live) {
124
+ copy = { live, node: live ? panel.cloneNode(true) : this._sizer(panel) };
125
+ this._clones.set(panel, copy);
126
+ if (!live) this._sizers.push(copy.node);
127
+ }
128
+ return copy.node;
55
129
  }
56
130
 
57
- async _measureAllPanels() {
58
- const panels = this._getPanels();
59
- const wrapper = this.renderRoot.querySelector(".bd-panel-wrapper");
60
- if (!wrapper || !panels.length) return;
61
-
62
- const originalTab = this.selectedTab;
63
- let maxHeight = 0;
64
-
65
- for (let i = 0; i < panels.length; i++) {
66
- this.selectedTab = i;
67
- await this.updateComplete;
68
- await new Promise(r => requestAnimationFrame(r));
69
- await new Promise(r => requestAnimationFrame(r));
70
-
71
- const h = wrapper.scrollHeight;
72
- if (h > maxHeight) maxHeight = h;
73
- }
131
+ /* A sizer is a tree of its own: the copy goes into a shadow root on a plain
132
+ div. Beside the live panel in this root it was part of one tree with it,
133
+ and whatever a tree groups was grouped across panels -- an ungrouped
134
+ bd-radio finds its group by name in its root, so a panel's radios joined
135
+ the same-name radios of every hidden one: the visible set lost its tab
136
+ stop to a checked radio nobody could see, the arrow keys selected radios
137
+ in inert panels, and a choice in one panel cleared another's default.
138
+ Nothing in this root styles a panel's content (tabs.css.js), and what the
139
+ content inherits -- the type, the ensemble's neutralisers -- crosses a
140
+ shadow boundary, so a sizer is laid out as its panel is.
141
+
142
+ The copy is held still before it is ever connected: connected first, its
143
+ frames started loading and its videos fetching for a tab nobody opened,
144
+ and only then did quiet() blank them. quiet() still follows, for what the
145
+ copy's components render once they are on the page. */
146
+ _sizer(panel) {
147
+ const sizer = document.createElement("div");
148
+ const copy = panel.cloneNode(true);
149
+ [copy, ...copy.querySelectorAll("*")].forEach(hold);
150
+ sizer.attachShadow({ mode: "open" }).append(copy);
151
+ return sizer;
152
+ }
74
153
 
75
- this.selectedTab = originalTab;
76
- await this.updateComplete;
77
- this._panelMinHeight = maxHeight;
154
+ updated() {
155
+ for (const sizer of this._sizers.splice(0)) quiet(sizer);
78
156
  }
79
157
 
80
158
  render() {
81
- const panels = this._getPanels();
82
- const activePanel = panels[this.selectedTab];
159
+ const panels = this._getPanels();
83
160
 
84
161
  return html`
85
162
  <div class="bd-ensemble bd-tabs-component">
@@ -105,9 +182,10 @@ class BdTabs extends LitElement {
105
182
  role="tabpanel"
106
183
  aria-labelledby="tab-btn-${this.selectedTab}"
107
184
  class="bd-panel-wrapper"
108
- style="${this._panelMinHeight ? `min-height: ${this._panelMinHeight}px;` : ""}"
109
185
  >
110
- ${keyed(this.selectedTab, activePanel ? activePanel.cloneNode(true) : "")}
186
+ ${panels.map((panel, index) => html`
187
+ <div class="bd-panel" ?inert=${index !== this.selectedTab}>${this._cloneOf(panel, index === this.selectedTab)}</div>
188
+ `)}
111
189
  </div>
112
190
 
113
191
  </div>
@@ -115,4 +193,4 @@ class BdTabs extends LitElement {
115
193
  }
116
194
  }
117
195
 
118
- customElements.define("bd-tabs", BdTabs);
196
+ customElements.define("bd-tabs", BdTabs);
@@ -3,6 +3,9 @@ import { css } from "lit";
3
3
  export default css`
4
4
  :host {
5
5
  display: block;
6
+ /* A terminal transcript reads left to right on any page: it is code, and
7
+ its prompt, gutter and cursor are drawn for that direction. */
8
+ direction: ltr;
6
9
  font-family: var(--typography-fontFamily-mono);
7
10
  color: var(--color-text-on-media);
8
11
 
@@ -342,7 +345,9 @@ export default css`
342
345
 
343
346
  .bd-terminalmsg-l-row-text {
344
347
  color: var(--color-text-on-media);
345
- word-break: break-word;
348
+ /* the standard spelling of word-break's deprecated break-word value:
349
+ break a long token anywhere rather than overflow the row */
350
+ overflow-wrap: anywhere;
346
351
  }
347
352
 
348
353
  .bd-terminalmsg-badge {