@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
@@ -42,12 +42,12 @@ It includes:
42
42
 
43
43
  ### Badge object shape
44
44
  \`\`\`js
45
- { id: string, label: string, type: "red" | "dark", format: "svg", src: string }
45
+ { id: string, label: string, type: "red" | "dark", tag: string } // tag: the badge's icon element, e.g. "bd-pc-mag-icon"
46
46
  \`\`\`
47
47
 
48
48
  ### Feature object shape
49
49
  \`\`\`js
50
- { icon: "brain" | "chart", title: string, description: string }
50
+ { tag: string, title: string, description: string } // tag: "bd-machine-learning-icon" or "bd-analysis-icon"
51
51
  \`\`\`
52
52
  `
53
53
  }
@@ -333,12 +333,12 @@ export const CustomFeatures = {
333
333
  ...defaultArgs,
334
334
  features: [
335
335
  {
336
- icon : "brain",
336
+ tag : "bd-machine-learning-icon",
337
337
  title : "AI-Powered Threat Detection",
338
338
  description: "Our next-generation AI engine analyses over 500 billion security events per day, identifying and neutralising threats before they can cause harm to your system."
339
339
  },
340
340
  {
341
- icon : "chart",
341
+ tag : "bd-analysis-icon",
342
342
  title : "Real-Time Protection",
343
343
  description: "Continuous monitoring of all active processes, network connections, and file system changes ensures that threats are caught the moment they appear — with zero performance impact."
344
344
  }
@@ -348,7 +348,7 @@ export const CustomFeatures = {
348
348
  parameters: {
349
349
  docs: {
350
350
  description: {
351
- story: "Custom feature card content. The `icon` field accepts `'brain'` (maps to `/assets/machine-learning.svg`) or `'chart'` (maps to `/assets/analysis.svg`)."
351
+ story: "Custom feature card content. Each feature's `tag` names its icon element: `bd-machine-learning-icon` or `bd-analysis-icon`."
352
352
  }
353
353
  }
354
354
  }
@@ -0,0 +1,128 @@
1
+ /**
2
+ * Whole-width slides in a scroll-snap scroller: the two awards carousels.
3
+ *
4
+ * bd-awards-spotlight and bd-awards-flex used to move their slides with an
5
+ * inline translateX on a track inside an overflow: hidden window, so only the
6
+ * dots could move them: a phone could not swipe, a trackpad could not scroll,
7
+ * and in a right-to-left page the slides ran the wrong way. The window is a
8
+ * scroller now (overflow-x, scroll-snap-type, one stop a slide) and the
9
+ * browser moves it for every input it has, the way bd-carousel-section's
10
+ * track already works.
11
+ *
12
+ * What is left for script is the two-way link with the dots:
13
+ * - the scroller settles on a slide -> the host is told which (onSlide)
14
+ * - the host's current slide changes (a dot, autoplay) -> go() scrolls there
15
+ *
16
+ * Every slide is the scroller's own width, so a slide's index is how many
17
+ * widths the scroller has travelled from its start. scrollLeft runs negative
18
+ * in a right-to-left scroller, which the absolute value and the sign in go()
19
+ * account for.
20
+ */
21
+ export class ScrollSlides {
22
+ /**
23
+ * @param {import('lit').ReactiveControllerHost & HTMLElement} host
24
+ * @param {{ scroller: string, onSlide: (index: number) => void }} options
25
+ * scroller -- a selector in the host's render root;
26
+ * onSlide -- the slide a visitor's scroll came to rest on.
27
+ */
28
+ constructor(host, { scroller, onSlide }) {
29
+ this.host = host;
30
+ this._selector = scroller;
31
+ this._onSlide = onSlide;
32
+ this._el = null;
33
+ /* The slide go() asked for, while the smooth scroll there is on its way:
34
+ the slides it passes are not the visitor's choice. -1 when none. */
35
+ this._seeking = -1;
36
+ this._frame = 0;
37
+ this._onScroll = () => {
38
+ cancelAnimationFrame(this._frame);
39
+ this._frame = requestAnimationFrame(() => this._read());
40
+ };
41
+ // a visitor taking hold of the scroller ends any scroll go() started
42
+ this._onGrab = () => { this._seeking = -1; };
43
+ /* A go() asked of a scroller with no width -- hidden when it was asked --
44
+ cannot scroll, so it waits, and runs once the scroller has a width.
45
+ Only that one: any other difference between the slide shown and the
46
+ last one asked for is a visitor's scroll the host has yet to hear of. */
47
+ this._wanted = 0;
48
+ this._pending = false;
49
+ this._resize = new ResizeObserver(() => {
50
+ if (this._pending && this._el?.clientWidth) this.go(this._wanted);
51
+ });
52
+ host.addController(this);
53
+ }
54
+
55
+ hostUpdated() {
56
+ const el = this.host.renderRoot.querySelector(this._selector);
57
+ if (el === this._el) return;
58
+ this._listen(false);
59
+ this._el = el;
60
+ this._listen(true);
61
+ }
62
+
63
+ /* Put back on the page -- moved, or re-inserted by a framework -- the host
64
+ need not render again, and the scroller it rendered is still there, so
65
+ it is listened to again now. Waiting for the next update left a swipe
66
+ moving nothing: no dot followed, and the slide it brought in stayed
67
+ inert. */
68
+ hostConnected() {
69
+ if (this.host.hasUpdated) this.hostUpdated();
70
+ }
71
+
72
+ hostDisconnected() {
73
+ this._listen(false);
74
+ this._el = null;
75
+ cancelAnimationFrame(this._frame);
76
+ }
77
+
78
+ _listen(on) {
79
+ const el = this._el;
80
+ if (!el) return;
81
+ const method = on ? "addEventListener" : "removeEventListener";
82
+ el[method]("scroll", this._onScroll, { passive: true });
83
+ for (const type of ["pointerdown", "touchstart", "wheel", "keydown"]) {
84
+ el[method](type, this._onGrab, { passive: true });
85
+ }
86
+ if (on) this._resize.observe(el);
87
+ else this._resize.unobserve(el);
88
+ }
89
+
90
+ /** The slide the scroller is nearest: whole widths from its start, either way round. */
91
+ get index() {
92
+ const el = this._el;
93
+ if (!el?.clientWidth) return 0;
94
+ return Math.round(Math.abs(el.scrollLeft) / el.clientWidth);
95
+ }
96
+
97
+ /** Bring slide `index` into the scroller -- smoothly, or at once under reduced motion (the stylesheet's scroll-behavior). */
98
+ go(index) {
99
+ const el = this._el;
100
+ this._wanted = index;
101
+ this._pending = false;
102
+ if (!el) return;
103
+ /* Compared with where the scroller is headed, not where it is: mid-glide
104
+ from slide 1 to 2 it is still nearest 1, so a dot asking for 1 was
105
+ dropped, the glide landed on 2, and the dots said 1 over a slide drawn
106
+ inert. */
107
+ if ((this._seeking === -1 ? this.index : this._seeking) === index) return;
108
+ /* With no width there is nowhere to scroll and no scroll to end the
109
+ seek, which would then hold every visitor's scroll off; _resize brings
110
+ the slide in once the scroller is shown. */
111
+ if (!el.clientWidth) {
112
+ this._pending = true;
113
+ return;
114
+ }
115
+ this._seeking = index;
116
+ const sign = getComputedStyle(el).direction === "rtl" ? -1 : 1;
117
+ el.scrollTo({ left: sign * index * el.clientWidth });
118
+ }
119
+
120
+ _read() {
121
+ const index = this.index;
122
+ if (this._seeking !== -1) {
123
+ if (index === this._seeking) this._seeking = -1;
124
+ return;
125
+ }
126
+ this._onSlide(index);
127
+ }
128
+ }
@@ -24,6 +24,8 @@ export default css`
24
24
  /* the properties that change, not all */
25
25
  transition: background-color var(--transition-duration-normal) var(--transition-easing-smooth),
26
26
  color var(--transition-duration-normal) var(--transition-easing-smooth);
27
+ /* Safari reads only the prefixed property */
28
+ -webkit-user-select: none;
27
29
  user-select: none;
28
30
  }
29
31
 
@@ -28,6 +28,8 @@ export default css`
28
28
  leading is control-label-small's tight, which holds a second line. */
29
29
  white-space: var(--bd-badge-white-space, nowrap);
30
30
  text-align: center;
31
+ /* Safari reads only the prefixed property */
32
+ -webkit-user-select: none;
31
33
  user-select: none;
32
34
  }
33
35
 
@@ -175,6 +177,19 @@ export default css`
175
177
  :host([mode='dot'][tone='error']) .badge { background: var(--status-error-accent); }
176
178
  :host([mode='dot'][tone='info']) .badge { background: var(--status-info-accent); }
177
179
 
180
+ /* A dot is nothing but its fill, and forced colours repaint every fill as
181
+ Canvas: the dot vanished. It opts out and is drawn in CanvasText. A
182
+ forced palette has no tones, so every tone draws the same dot; the text
183
+ beside it carries the meaning, as it must anyway. [tone] is spelled out
184
+ so this outranks the tone rules above. */
185
+ @media (forced-colors: active) {
186
+ :host([mode='dot']) .badge,
187
+ :host([mode='dot'][tone]) .badge {
188
+ forced-color-adjust: none;
189
+ background: CanvasText;
190
+ }
191
+ }
192
+
178
193
  /* ---- mode: count ----------------------------------------------------
179
194
  Digits are set tabular so a counter does not change width as it counts:
180
195
  measured, "12" and "99" both come out at the same width. The padding
@@ -1,4 +1,79 @@
1
- import { css } from "lit";
1
+ import { css, unsafeCSS } from "lit";
2
+ import { above, BREAKPOINTS } from "../shared/token-scales.js";
3
+
4
+ /* The columns follow the width the cards are laid out in, not the viewport's:
5
+ the column below is a container, so a grid in a narrow column stacks however
6
+ wide the screen is. Below sm the cards stack; from sm the pairs share a row
7
+ and an equal grid takes two; from md an equal grid takes its full count.
8
+
9
+ A count also has to leave every card min-card-width wide, so its step is the
10
+ wider of its breakpoint and that many cards plus their gaps. CSS cannot read
11
+ the attribute, so the step is computed: once here for the defaults, and by
12
+ bento-grid.js into a sheet of its own for a grid that changes one. Nothing
13
+ measures the grid -- the browser does, against these queries. */
14
+ export const TOTAL_UNITS = 24; // fine-grained tracks the weighted pairs span
15
+
16
+ /* The gap between the cards, as the length it is. The track's gap is a
17
+ --spacing-* step, which is rem and grows with the reader's text; the steps
18
+ used to add it as 16, 20 or 24px, so at a larger root size a count met
19
+ before its cards had room -- three at 260 met at 828px, where a 200% root's
20
+ 48px gaps left each card 244. The widest step, the md gap, is counted at
21
+ every count: no step lands below md with more than two cards, and for two
22
+ the sm breakpoint is the larger term either way, so no default moves. */
23
+ /* no token: a container query cannot read a custom property, so the step is
24
+ restated as its rem -- --spacing-24 */
25
+ const GAP = "1.5rem";
26
+
27
+ /* When `count` cards fit: the breakpoint, and room for that many cards of
28
+ min-card-width with the gaps between them. */
29
+ const stepFor = (count, minCardWidth, breakpoint) =>
30
+ `(width >= ${BREAKPOINTS[breakpoint]}px) and (width >= calc(${count * minCardWidth}px + ${count - 1} * ${GAP}))`;
31
+
32
+ export const BENTO_DEFAULTS = { maxColumns: 2, equalColumns: 3, minCardWidth: 260 };
33
+
34
+ /* Every rule restates the one-column start, so a sheet adopted after this one
35
+ replaces the defaults at every width rather than adding to them. */
36
+ export const bentoColumnRules = ({ maxColumns, equalColumns, minCardWidth }) => {
37
+ const weighted = `:host(:not([variant="equal"]))`;
38
+ const equal = `:host([variant="equal"])`;
39
+ let rules = `
40
+ ${weighted} .bd-bentogrid-track,
41
+ ${equal} .bd-bentogrid-track {
42
+ grid-template-columns: minmax(0, 1fr);
43
+ }
44
+
45
+ ${weighted} ::slotted(bd-bento-item),
46
+ ${equal} ::slotted(bd-bento-item) {
47
+ grid-column: auto;
48
+ }
49
+ `;
50
+
51
+ if (maxColumns >= 2) {
52
+ rules += `
53
+ @container bento ${stepFor(2, minCardWidth, "sm")} {
54
+ ${weighted} .bd-bentogrid-track {
55
+ grid-template-columns: repeat(${TOTAL_UNITS}, minmax(0, 1fr));
56
+ }
57
+
58
+ ${weighted} ::slotted(bd-bento-item) {
59
+ grid-column: span var(--bd-bento-span, ${TOTAL_UNITS});
60
+ }
61
+ }
62
+ `;
63
+ }
64
+
65
+ for (let count = 2; count <= equalColumns; count += 1) {
66
+ rules += `
67
+ @container bento ${stepFor(count, minCardWidth, count === 2 ? "sm" : "md")} {
68
+ ${equal} .bd-bentogrid-track {
69
+ grid-template-columns: repeat(${count}, minmax(0, 1fr));
70
+ }
71
+ }
72
+ `;
73
+ }
74
+
75
+ return rules;
76
+ };
2
77
 
3
78
  export default css`
4
79
  :host {
@@ -7,6 +82,10 @@ export default css`
7
82
  box-sizing: border-box;
8
83
  }
9
84
 
85
+ .bd-ensemble {
86
+ container: bento / inline-size;
87
+ }
88
+
10
89
  /* === BACKGROUND VARIANT — section-level tint on the column (header +
11
90
  track), not per-card, so the panel lands on the page edges every other
12
91
  section uses. === */
@@ -51,13 +130,10 @@ export default css`
51
130
  /* === GRID === */
52
131
  .bd-bentogrid-track {
53
132
  display: grid;
54
- grid-template-columns: repeat(var(--bd-bento-total-units, 24), minmax(0, 1fr));
55
- /* The fallback names the step rather than repeating its value: --spacing-24
133
+ /* The steps name the scale rather than repeating its values: --spacing-24
56
134
  IS 24px at the default root size, but in rem, so it grows when the reader
57
- enlarges their text and 24px does not. Identical at 16px root, which is
58
- why nothing looked wrong and no rule could see it -- the declaration
59
- reads a legitimate var(). */
60
- gap: var(--bd-bento-gap, var(--spacing-24));
135
+ enlarges their text and 24px does not. */
136
+ gap: var(--bd-bento-gap, var(--spacing-16));
61
137
  /* auto, or 1fr when bento-grid.js finds a set of brand cards: every row
62
138
  then takes the tallest row's height, so a full-row card matches the
63
139
  pair above it rather than the lines its wider copy column wraps to */
@@ -65,13 +141,31 @@ export default css`
65
141
  width: 100%;
66
142
  }
67
143
 
144
+ @container bento ${unsafeCSS(above("sm"))} {
145
+ .bd-bentogrid-track {
146
+ gap: var(--bd-bento-gap, var(--spacing-20));
147
+ }
148
+ }
149
+
150
+ @container bento ${unsafeCSS(above("md"))} {
151
+ .bd-bentogrid-track {
152
+ gap: var(--bd-bento-gap, var(--spacing-24));
153
+ }
154
+ }
155
+
156
+ /* One column until a pair has room, and a stacked grid is a single track:
157
+ 24 units carry 23 gaps, whose own minimum -- 368px at the small gap -- is
158
+ wider than a phone. The equal grid used to keep them there and ran 25px
159
+ past a 375px screen. */
160
+ ${unsafeCSS(bentoColumnRules(BENTO_DEFAULTS))}
161
+
68
162
  ::slotted(bd-bento-item) {
69
- grid-column: span var(--bd-bento-span, 24);
70
163
  min-width: 0;
71
164
  }
72
165
 
73
- /* featured items always take the full row width */
74
- ::slotted(bd-bento-item[priority="featured"]) {
75
- grid-column: span var(--bd-bento-total-units, 24) !important;
166
+ /* A featured item takes the whole row, paired or not. Paired, its span is
167
+ already the row's (bento-grid.js); the equal grid has no spans to set. */
168
+ :host([variant="equal"]) ::slotted(bd-bento-item[priority="featured"]) {
169
+ grid-column: 1 / -1;
76
170
  }
77
171
  `;
@@ -2,57 +2,21 @@ import { LitElement, html, nothing } from "lit";
2
2
  import { tokens } from "../../tokens/tokens.js";
3
3
  import "../heading/heading.js";
4
4
  import "../paragraph/paragraph.js";
5
- import bentoGridCSS from "./bento-grid.css.js";
5
+ import bentoGridCSS, { BENTO_DEFAULTS, TOTAL_UNITS, bentoColumnRules } from "./bento-grid.css.js";
6
6
  import { ensembleCSS } from "../shared/ensemble.css.js";
7
- import { above } from "../shared/token-scales.js";
8
7
  import "./bento-item.js";
9
8
 
10
- const BREAKPOINT_WIDTHS = { xl: 1280, lg: 960, md: 640 };
11
- const DEFAULT_GAP = { xl: 24, lg: 24, md: 20, sm: 16 };
12
- const TOTAL_UNITS = 24; // fine-grained grid columns used purely for weighted spans
13
-
14
- function resolveBreakpoint(width, maxColumns, minCardWidth) {
15
- const bp =
16
- width >= BREAKPOINT_WIDTHS.xl
17
- ? "xl" :
18
- width >= BREAKPOINT_WIDTHS.lg
19
- ? "lg" :
20
- width >= BREAKPOINT_WIDTHS.md ? "md" : "sm";
21
-
22
- let columns = bp === "sm" ? 1 : bp === "md" ? 2 : Math.max(1, Math.min(2, maxColumns));
23
- const gap = DEFAULT_GAP[bp];
24
-
25
- while (columns > 1) {
26
- const cardWidth = (width - gap * (columns - 1)) / columns;
27
- if (cardWidth >= minCardWidth) break;
28
- columns -= 1;
9
+ /* One sheet per set of numbers, shared by every grid that asks for it. */
10
+ const columnSheets = new Map();
11
+ const columnSheetFor = (options) => {
12
+ const key = JSON.stringify(options);
13
+ if (!columnSheets.has(key)) {
14
+ const sheet = new CSSStyleSheet();
15
+ sheet.replaceSync(bentoColumnRules(options));
16
+ columnSheets.set(key, sheet);
29
17
  }
30
-
31
- return { bp, columns, gap };
32
- }
33
-
34
- // Same breakpoint logic as resolveBreakpoint, but allows more than 2
35
- // columns (up to maxColumns) since the "equal" variant is a plain grid
36
- // with no wide/narrow pairing to worry about.
37
- function resolveEqualColumns(width, maxColumns, minCardWidth) {
38
- const bp =
39
- width >= BREAKPOINT_WIDTHS.xl
40
- ? "xl" :
41
- width >= BREAKPOINT_WIDTHS.lg
42
- ? "lg" :
43
- width >= BREAKPOINT_WIDTHS.md ? "md" : "sm";
44
-
45
- let columns = bp === "sm" ? 1 : bp === "md" ? Math.min(2, maxColumns) : Math.max(1, maxColumns);
46
- const gap = DEFAULT_GAP[bp];
47
-
48
- while (columns > 1) {
49
- const cardWidth = (width - gap * (columns - 1)) / columns;
50
- if (cardWidth >= minCardWidth) break;
51
- columns -= 1;
52
- }
53
-
54
- return { bp, columns, gap };
55
- }
18
+ return columnSheets.get(key);
19
+ };
56
20
 
57
21
  class BentoGrid extends LitElement {
58
22
  static properties = {
@@ -68,16 +32,14 @@ class BentoGrid extends LitElement {
68
32
  // _applyWeights below. "equal" — every card gets the same width, laid
69
33
  // out in a plain N-column grid (see equalColumns) with no pairing.
70
34
  variant : { type: String, reflect: true },
71
- // Column count for variant="equal" at the widest breakpoint (xl/lg);
72
- // narrows to min(2, this) at md, and 1 at sm, same responsive pattern
73
- // as the weighted variant. Ignored when variant="weighted".
35
+ // Column count for variant="equal" once the grid is md wide; min(2, this)
36
+ // from sm, and 1 below -- the grid's own width, not the viewport's, the
37
+ // same steps as the weighted pairs. Ignored when variant="weighted".
74
38
  equalColumns: { type: Number, attribute: "equal-columns" },
75
39
  // "none" (default, transparent) | "tint" (light blue wash behind the
76
40
  // whole grid, including header text) — a section-level background, not
77
41
  // per-card (bd-bento-item already has its own `tone="tint"` for that).
78
- background : { type: String, reflect: true },
79
- _columns : { state: true },
80
- _gap : { state: true }
42
+ background : { type: String, reflect: true }
81
43
  };
82
44
 
83
45
  static styles = [tokens, ensembleCSS, bentoGridCSS];
@@ -93,21 +55,13 @@ class BentoGrid extends LitElement {
93
55
  this.variant = "weighted";
94
56
  this.equalColumns = 3;
95
57
  this.background = "none";
96
- this._columns = 2;
97
- this._gap = 24;
98
- this._resizeObserver = null;
99
58
  }
100
59
 
101
- connectedCallback() {
102
- super.connectedCallback();
103
- this._resizeObserver = new ResizeObserver(() => this._relayout());
104
- this._resizeObserver.observe(this);
105
- this._relayout();
106
- }
107
-
108
- disconnectedCallback() {
109
- super.disconnectedCallback();
110
- this._resizeObserver?.disconnect();
60
+ updated(changed) {
61
+ if (changed.has("wideShare")) this._applyWeights();
62
+ if (["maxColumns", "equalColumns", "minCardWidth"].some((name) => changed.has(name))) {
63
+ this._adoptColumnRules();
64
+ }
111
65
  }
112
66
 
113
67
  get _items() {
@@ -165,15 +119,6 @@ class BentoGrid extends LitElement {
165
119
  }
166
120
  }
167
121
 
168
- // Every item gets the same span (TOTAL_UNITS / columns) — no pairing, no
169
- // "featured" full-width exception. Rounds if TOTAL_UNITS doesn't divide
170
- // evenly by columns; for common column counts (1, 2, 3, 4, 6, 8, 12, 24)
171
- // against TOTAL_UNITS=24 this is always exact.
172
- _applyEqualSpans(columns) {
173
- const span = Math.round(TOTAL_UNITS / Math.max(1, columns));
174
- this._items.forEach((item) => item.style.setProperty("--bd-bento-span", String(span)));
175
- }
176
-
177
122
  /* Brand cards are drawn as one set of equal bands: the full-row card is
178
123
  the pair's height, not shorter for having a wider copy column, and
179
124
  stacked cards match whatever their copy runs to. Only when every card is
@@ -189,58 +134,26 @@ class BentoGrid extends LitElement {
189
134
  else this.style.removeProperty("--bd-bento-row-height");
190
135
  }
191
136
 
192
- _relayout() {
193
- const width = this.clientWidth || 960;
194
- this.style.setProperty("--bd-bento-total-units", String(TOTAL_UNITS));
195
- this._applyRowHeight();
196
-
197
- /* Brand cards keep the tablet layout, one full row each, until the
198
- viewport reaches lg, like every other section on the page: from md to
199
- lg bento-item.css.js draws each one as a full-width row, and its paired
200
- art only starts at lg. A container-width pairing put two half cards
201
- side by side at 960-991px, where the 300 copy column ran under the art. */
202
- if (this._isBrandSet && !window.matchMedia?.(above("lg")).matches) {
203
- this._columns = 1;
204
- this._gap = DEFAULT_GAP.sm;
205
- this.style.setProperty("--bd-bento-gap", `${this._gap}px`);
206
- this.style.setProperty("--bd-bento-total-units", "1");
207
- this._items.forEach((item) => item.style.setProperty("--bd-bento-span", "1"));
208
- return;
209
- }
210
-
211
- if (this.variant === "equal") {
212
- const { columns, gap } = resolveEqualColumns(width, this.equalColumns, this.minCardWidth);
213
- this._columns = columns;
214
- this._gap = gap;
215
- this.style.setProperty("--bd-bento-gap", `${gap}px`);
216
- this._applyEqualSpans(columns);
217
- return;
218
- }
219
-
220
- const { columns, gap } = resolveBreakpoint(width, this.maxColumns, this.minCardWidth);
221
- this._columns = columns;
222
- this._gap = gap;
223
- this.style.setProperty("--bd-bento-gap", `${gap}px`);
224
-
225
- if (columns <= 1) {
226
- /* Collapse the subdivision, not just the spans. A 24-unit track carries
227
- 23 internal gaps, so its own minimum width is 23 * gap -- 368px at the
228
- small gap -- whatever the viewport is: measured, the grid overflowed
229
- 320px by 64px and 375px by 9px for that reason alone. In one column
230
- the units buy nothing, because every item spans the whole row either
231
- way, so the track becomes a single column and the floor goes with it. */
232
- this.style.setProperty("--bd-bento-total-units", "1");
233
- this._items.forEach((item) => item.style.setProperty("--bd-bento-span", "1"));
234
- return;
235
- }
236
-
237
- this.style.setProperty("--bd-bento-total-units", String(TOTAL_UNITS));
238
-
239
- this._applyWeights();
137
+ /* The column steps for the default numbers are in bento-grid.css.js. A
138
+ grid that changes one adopts the same rules computed from its own, after
139
+ the defaults, and drops them again when it changes back. */
140
+ _adoptColumnRules() {
141
+ const options = {
142
+ maxColumns : Math.min(2, this.maxColumns),
143
+ equalColumns: Math.max(1, this.equalColumns),
144
+ minCardWidth: this.minCardWidth
145
+ };
146
+ const isDefault = Object.keys(options).every((name) => options[name] === BENTO_DEFAULTS[name]);
147
+ const root = this.renderRoot;
148
+ const sheets = root.adoptedStyleSheets.filter((sheet) => ![...columnSheets.values()].includes(sheet));
149
+ root.adoptedStyleSheets = isDefault ? sheets : [...sheets, columnSheetFor(options)];
240
150
  }
241
151
 
152
+ /* Spans and row heights follow the cards and their order, never the width,
153
+ so they are set when the cards change. */
242
154
  _onSlotChange() {
243
- this._relayout();
155
+ this._applyRowHeight();
156
+ this._applyWeights();
244
157
  }
245
158
 
246
159
  render() {
@@ -24,11 +24,12 @@ render its own header block (eyebrow + title + description) above the cards, so
24
24
  whole "Protection" section — heading and grid — is a single component.
25
25
 
26
26
  Zero configuration needed for the grid itself:
27
- - Measures its own width and resolves 1 or 2 columns automatically (2 max, never more).
27
+ - Resolves 1 or 2 columns from its own width, not the viewport's (2 max, never more):
28
+ the grid is a size container, so it stacks in a narrow column on any screen.
28
29
  - Pairs items two at a time in DOM order; within each pair, the wide/narrow side
29
30
  follows a repeating 3-pair cycle (never a flat 50/50).
30
31
  - \`priority="featured"\` always takes the full row width by itself and never pairs.
31
- - Recalculates automatically on resize and whenever items are added/removed.
32
+ - Follows resizes through container queries, and re-pairs whenever items are added/removed.
32
33
 
33
34
  ### Header block
34
35