@repobit/dex-system-design 2.5.1 → 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 +84 -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 +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 +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
@@ -1,13 +1,26 @@
1
1
  import { css, unsafeCSS } from "lit";
2
2
  import { below } from "../shared/token-scales.js";
3
3
 
4
+ /* The card at its phone inset and height: said once, asked twice (below). */
5
+ const narrowCard = css`
6
+ .bd-box {
7
+ padding: var(--spacing-0) var(--spacing-20);
8
+ min-height: 300px;
9
+ max-width: calc(100cqi - 2 * var(--spacing-20));
10
+ }
11
+
12
+ .bd-carousel-icon {
13
+ bottom: var(--spacing-10);
14
+ }
15
+ `;
16
+
17
+ const narrowCardMedia = css`@media (max-width: 480px) { ${narrowCard} }`;
18
+
4
19
  export default css`
5
20
  :host {
6
21
  display: block;
7
22
  }
8
23
 
9
-
10
- p{ font-size: 40px;}
11
24
  .bd-carousel {
12
25
  display: block;
13
26
  align-items: center;
@@ -19,11 +32,15 @@ export default css`
19
32
  max-width: 100%;
20
33
  flex-direction: column;
21
34
  }
35
+ /* While a mouse drags the track (_enableMouseDrag) it follows the pointer
36
+ pixel for pixel, so neither the snap nor the smooth scroll-behavior may
37
+ come between them; the drag settles on a stop itself on release. */
22
38
  .bd-carousel-track.dragging {
23
39
  cursor: grabbing;
24
- user-select: none;
40
+ scroll-snap-type: none;
41
+ scroll-behavior: auto;
25
42
  }
26
-
43
+
27
44
  /* No .bd-section-title rule. The title is a bd-h at visual-level="h3", so
28
45
  the heading-h3 role carries the whole of its type -- the three
29
46
  declarations that stood here spelled out that role's size and weight by
@@ -31,8 +48,7 @@ export default css`
31
48
  render at the browser's default leading and with the browser's default h2
32
49
  margins. LightCarousel and CardFeatures declare no such rule either. */
33
50
  .bd-box:focus-visible,
34
- .bd-plus-button:focus-visible,
35
- .bd-modal-content button:focus-visible {
51
+ .bd-plus-button:focus-visible {
36
52
  /* the one focus ring — see Foundations/Focus */
37
53
  /* forced-colors mode does not paint box-shadow, so the ring
38
54
  vanishes there; it does paint an outline, in a system colour. This one
@@ -55,12 +71,6 @@ export default css`
55
71
  bd-h puts on the element inside its own shadow root, so this stylesheet
56
72
  never reached it: measured 0 matches across 27 carousel sections and 102
57
73
  carousel items. */
58
- .bd-carousel-container {
59
- display: flex;
60
- flex-direction: column;
61
- gap: 1rem;
62
- padding: 1rem;
63
- }
64
74
  /* The dots: bd-pagination-dots, the package's one set of slide controls.
65
75
  Two <img role="button"> arrows stood here, painted by eight data-URI SVGs
66
76
  with the blues and the disabled grey baked in as hex -- invisible to every
@@ -73,18 +83,46 @@ export default css`
73
83
  padding-inline: var(--spacing-10);
74
84
  }
75
85
 
86
+ /* A scroller the browser drives: the wheel, a trackpad, touch and the
87
+ keyboard (arrows, once focus is on an item's +) all move it, and the snap
88
+ settles each of them on a stop. It was overflow-x: hidden, moved only by a
89
+ script writing scrollLeft from mouse and touch handlers, so none of those
90
+ reached it. */
76
91
  .bd-carousel-track {
77
92
  display: flex;
78
93
  gap: 2em;
79
94
  flex: 1;
80
95
  padding: var(--spacing-0) var(--spacing-20);
96
+ /* the stops start where the padding leaves the first item, so each is one
97
+ whole _step() from the last -- the arithmetic the dots count with */
98
+ scroll-padding-inline: var(--spacing-20);
81
99
  position: relative;
82
- overflow-x: hidden;
100
+ overflow-x: auto;
83
101
  overflow-y: hidden;
84
- z-index: var(--z-base);
102
+ /* a sideways swipe that reaches either end stops here, rather than
103
+ carrying on into the browser's back and forward gesture */
104
+ overscroll-behavior-x: contain;
105
+ /* No scrollbar: the dots say where the track is. Hidden the way
106
+ bd-light-carousel hides its own. */
107
+ scrollbar-width: none;
85
108
  scroll-snap-type: x mandatory;
86
- -webkit-overflow-scrolling: touch;
87
- transition: scroll-snap-align 0.6s cubic-bezier(0.23, 1, 0.32, 1);
109
+ /* a dot's jump glides; see the reduced-motion block for who it does not */
110
+ scroll-behavior: smooth;
111
+ z-index: var(--z-base);
112
+ /* The items size themselves against the track (see .bd-box): a card is
113
+ as wide as its track allows, and narrow when the track is, wherever
114
+ the section is placed. */
115
+ container-type: inline-size;
116
+ }
117
+ .bd-carousel-track::-webkit-scrollbar {
118
+ display: none;
119
+ }
120
+ /* Each item is a stop. The snap above had no aligned child to land on, so
121
+ it never snapped at all. Scoped to the track's slot: bd-carousel-item
122
+ adopts this stylesheet too, and a bare ::slotted(*) there would make every
123
+ paragraph inside an item a stop as well. */
124
+ .bd-carousel-track ::slotted(*) {
125
+ scroll-snap-align: start;
88
126
  }
89
127
 
90
128
  .bd-carousel-icon {
@@ -93,18 +131,17 @@ export default css`
93
131
  height: var(--spacing-40);
94
132
  width: var(--spacing-40);
95
133
  }
96
- .bd-carousel-modal-icon {
97
- position: relative;
98
- bottom: 15px;
99
- max-width: 100%;
100
- height: var(--spacing-40);
101
- width: var(--spacing-40);
102
- }
103
134
  .bd-box {
104
135
  flex: 0 0 auto;
105
136
  min-height: 217px;
106
137
  min-width: unset;
107
138
  width: 350px;
139
+ /* Never wider than the track: the 350 and the inset beside it are 414,
140
+ and a 343 phone track used to hold a 390 card with its + past the
141
+ track's edge at every stop. cqi rather than a percentage because the
142
+ item around this box is sized by it -- a percentage there would be
143
+ cyclic and read as none. */
144
+ max-width: calc(100cqi - 2 * var(--card-padding));
108
145
  background: var(--color-surface-container);
109
146
  /* --radius-2xl, the step the other ten cards take.
110
147
  bd-light-carousel made this exact move and wrote the argument for it:
@@ -146,8 +183,16 @@ export default css`
146
183
  match: measured zero .bd-modal / .bd-modal-content elements in every
147
184
  carousel story, including "Modal — Click + to Open". */
148
185
 
186
+ /* The +: a circle drawn by the button's own edge around bd-plus-icon,
187
+ which takes its ink from the button (currentColor), so every state is a
188
+ colour from the brand's roles and follows a partner's theme -- the
189
+ tertiary button's pairs: the brand edge and the action ink at rest, the
190
+ brand wash on hover, the action fill with the brand's own ink pressed.
191
+ It used to be three data: URIs, one a state, each painting %23006DFF
192
+ and %23F0F7FF baked into the drawing, which no token reaches: the one
193
+ place in the package that stayed Bitdefender blue under every brand
194
+ (plans/LATER.md entry 3). */
149
195
  .bd-plus-button {
150
- content: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" viewBox="0 0 40 40" fill="none"><circle cx="20" cy="20" r="19" stroke="%23006DFF" stroke-width="2"/><path d="M19 11H21V29H19V11Z" fill="%23006DFF"/><path d="M29 19V21L11 21L11 19L29 19Z" fill="%23006DFF"/></svg>');
151
196
  position: absolute;
152
197
  bottom: var(--spacing-10);
153
198
  right: var(--spacing-10);
@@ -156,24 +201,20 @@ export default css`
156
201
  display: flex;
157
202
  align-items: center;
158
203
  justify-content: center;
159
- border-radius: 50%;
204
+ border-radius: var(--radius-full);
160
205
  cursor: pointer;
161
- /* color, font-size: 30px and font-weight: bold stood here, styling the "+"
162
- this div contains (carousel.js:49). They painted nothing. The content:
163
- url() above REPLACES the element, so the text node is never laid out --
164
- measured in components-carousel--modal-trigger, the "+" range reports 0
165
- client rects while the box is 44x44 and computed color is still
166
- rgb(0, 109, 255).
167
- .
168
- Removing the color also retired --bd-blue-color, the last private alias
169
- plans/foundation-plan.md claimed had already been removed. What actually
170
- paints the mark is %23006DFF, baked into the data URI twice -- reachable
171
- by no token rule. plans/LATER.md entry 3. */
172
- }
173
- .bd-plus-button:hover {
174
- content: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" viewBox="0 0 40 40" fill="none"><circle cx="20" cy="20" r="19" fill="%23F0F7FF" stroke="%23006DFF" stroke-width="2"/><path d="M19 11H21V29H19V11Z" fill="%23006DFF"/><path d="M29 19V21L11 21L11 19L29 19Z" fill="%23006DFF"/></svg>');
175
- }
206
+ /* A <button> now, not a div with role="button" and its own keydown: that
207
+ opened the modal on Space while also scrolling the page, and again on
208
+ every key repeat. */
209
+ border: var(--border-width-2) solid var(--color-border-brand);
210
+ background: transparent;
211
+ color: var(--color-action-primary);
212
+ padding: 0;
213
+ }
176
214
 
215
+ .bd-plus-button:hover {
216
+ background: var(--status-brand-surface);
217
+ }
177
218
 
178
219
  /* A "bd-carousel-item::part(content)" rule stood here and was dead three
179
220
  times over. The items are light-DOM children of bd-carousel-section -- its
@@ -183,51 +224,41 @@ export default css`
183
224
  which everything inside it inherits. Measured: the item's box computes the
184
225
  IBM Plex Sans stack with this rule gone. */
185
226
 
186
- .bd-plus-button:active {
187
- content: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" viewBox="0 0 40 40" fill="none"><circle cx="20" cy="20" r="19" fill="%23006DFF" stroke="%23006DFF" stroke-width="2"/><path d="M19 11H21V29H19V11Z" fill="white"/><path d="M29 19V21L11 21L11 19L29 19Z" fill="white"/></svg>');
188
- }
227
+ .bd-plus-button:active {
228
+ background: var(--color-action-primary);
229
+ color: var(--color-brand-on-fill);
230
+ }
189
231
 
190
232
  @media ${unsafeCSS(below('md'))} {
191
233
  .bd-carousel-track {
192
234
  flex-wrap: nowrap;
193
- overflow-x: hidden;
194
235
  gap: 1em;
195
236
  padding: var(--spacing-0) var(--spacing-0);
196
- }
197
-
198
- .bd-box {
199
- max-width: 100%;
200
- margin: var(--spacing-0) auto;
201
- }
202
-
203
- .bd-modal-content {
204
- max-width: 90%;
205
- padding: 1.5em;
237
+ scroll-padding-inline: var(--spacing-0);
206
238
  }
207
239
  }
208
240
 
209
- @media (max-width: 480px) {
210
- .bd-box {
211
- padding: var(--spacing-0) var(--spacing-20);
212
- min-height: 300px;
213
- }
214
-
215
- .bd-modal-content {
216
- padding: 2em;
217
- }
218
-
219
- .bd-carousel-icon {
220
- bottom: var(--spacing-10);
221
- }
222
- }
241
+ /* A card in a track 480 wide or less: a phone's, or a narrow column's.
242
+ This asked the screen, which stands in for the track only while the
243
+ carousel fills a phone. It still asks the screen too, for an item set on
244
+ its own with no track around it (Foundations/Visual Alignment's card
245
+ family); in a track the two never disagree, since the track is never
246
+ wider than the screen. */
247
+ ${narrowCardMedia}
248
+ @container (width <= 480px) { ${narrowCard} }
223
249
 
224
- /* A reader who asked for less motion was still getting the track snap and the item lift. Twenty-three
250
+ /* A reader who asked for less motion was still getting the item lift. Twenty-three
225
251
  of the thirty animated directories in this package honour the query; this
226
252
  one did not. */
227
253
  @media (prefers-reduced-motion: reduce) {
228
- .bd-carousel-track,
229
254
  .bd-box {
230
255
  transition: none;
231
256
  }
257
+
258
+ /* A dot, or the end of a drag, moves the track with a jump rather than a
259
+ glide. This is what _goToPage used to ask matchMedia for. */
260
+ .bd-carousel-track {
261
+ scroll-behavior: auto;
262
+ }
232
263
  }
233
264
  `;
@@ -3,6 +3,7 @@ import { LitElement, html } from "lit";
3
3
  import "../../tokens/tokens.js";
4
4
  import carouselCSS from "../carousel/carousel.css.js";
5
5
  import "../heading/heading.js";
6
+ import "../icons/plus-icon.js";
6
7
  import "../modal/modal.js";
7
8
  import "../pagination-dots/pagination-dots.js";
8
9
  export class CarouselItem extends LitElement {
@@ -12,12 +13,6 @@ export class CarouselItem extends LitElement {
12
13
  modalText: { type: String }
13
14
  };
14
15
 
15
- _onKeydown(event) {
16
- if (event.key === "Enter" || event.key === " ") {
17
- this._openModal();
18
- }
19
- }
20
-
21
16
  _openModal() {
22
17
  this.dispatchEvent(
23
18
  new CustomEvent("open-modal", {
@@ -36,21 +31,19 @@ export class CarouselItem extends LitElement {
36
31
  return html`
37
32
  <div class="bd-box">
38
33
  ${this.icon
39
- ? html`<img src="${this.icon}" alt="icon" class="bd-carousel-icon" />`
34
+ ? html`<img src="${this.icon}" alt="" class="bd-carousel-icon" />`
40
35
  : ""}
41
36
  <div class="bd-content">
42
37
  <slot></slot>
43
38
  </div>
44
- <div
39
+ <button
40
+ type="button"
45
41
  class="bd-plus-button"
46
- role="button"
47
42
  aria-label="Open modal for ${this.title}"
48
43
  @click="${this._openModal}"
49
- @keydown="${this._onKeydown}"
50
- tabindex="0"
51
44
  >
52
- +
53
- </div>
45
+ <bd-plus-icon size="md"></bd-plus-icon>
46
+ </button>
54
47
  </div>
55
48
  `;
56
49
  }
@@ -109,7 +102,7 @@ class CustomCarousel extends LitElement {
109
102
  this.track.addEventListener("scroll", () => this._measure(), { passive: true });
110
103
  this.track.addEventListener("scrollend", () => { this._seeking = 0; this._measure(); });
111
104
  // a visitor taking hold of the track ends any scroll a control started
112
- for (const type of ["pointerdown", "touchstart", "wheel"]) {
105
+ for (const type of ["pointerdown", "touchstart", "wheel", "keydown"]) {
113
106
  this.track.addEventListener(type, () => { this._seeking = 0; }, { passive: true });
114
107
  }
115
108
 
@@ -125,7 +118,7 @@ class CustomCarousel extends LitElement {
125
118
  this.addEventListener("open-modal", (e) => {
126
119
  this.openModal(e.detail);
127
120
  });
128
- this.enableDragAndTouchScroll(this.track);
121
+ this._enableMouseDrag(this.track);
129
122
  }
130
123
 
131
124
  disconnectedCallback() {
@@ -178,78 +171,121 @@ class CustomCarousel extends LitElement {
178
171
  return;
179
172
  }
180
173
  this._pages = Math.ceil((max - 1) / step) + 1;
181
- const left = this.track.scrollLeft;
174
+ const left = this._travelled;
182
175
  const page = left >= max - 1 ? this._pages : Math.min(this._pages, Math.round(left / step) + 1);
183
176
  if (this._seeking && page !== this._seeking) return;
184
177
  this._seeking = 0;
185
178
  this._page = page;
186
179
  }
187
180
 
188
- _goToPage(n) {
181
+ /* Where stop n sits, as a distance from the track's start: a whole step per
182
+ stop, and the last at the track's end. */
183
+ _stop(n) {
189
184
  const max = this.track.scrollWidth - this.track.clientWidth;
190
- const reduce = window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;
185
+ return Math.min((n - 1) * this._step(), max);
186
+ }
187
+
188
+ /* How far the track has scrolled from its start. On a right-to-left page
189
+ the start is the right edge and scrollLeft runs from 0 down to minus the
190
+ overflow, so the distance is its size and a position written back takes
191
+ its sign; read as a plain number, every stop past the first sat at a
192
+ scrollLeft the track can never reach, and scrolling to one clamped to the
193
+ start. */
194
+ get _travelled() {
195
+ return Math.abs(this.track.scrollLeft);
196
+ }
197
+
198
+ _scrollToStop(n) {
199
+ const sign = getComputedStyle(this.track).direction === "rtl" ? -1 : 1;
200
+ this.track.scrollTo({ left: sign * this._stop(n) });
201
+ }
202
+
203
+ /* Smooth or instant is the track's scroll-behavior, which follows
204
+ prefers-reduced-motion; see carousel.css.js. */
205
+ _goToPage(n) {
191
206
  this._seeking = n;
192
207
  this._page = n;
193
- this.track.scrollTo({
194
- left : Math.min((n - 1) * this._step(), max),
195
- behavior: reduce ? "auto" : "smooth"
196
- });
208
+ this._scrollToStop(n);
197
209
  }
198
210
 
199
211
  openModal(item) {
200
212
  this.selectedItem = item;
213
+ this._shownItem = item;
201
214
  }
202
215
 
203
216
  closeModal() {
204
217
  this.selectedItem = null;
205
218
  }
206
219
 
207
- enableDragAndTouchScroll(element) {
208
- let isDown = false;
209
- let startX;
210
- let scrollLeft;
211
-
212
- element.addEventListener("mousedown", (e) => {
213
- isDown = true;
214
- element.classList.add("dragging");
215
- startX = e.pageX - element.offsetLeft;
216
- scrollLeft = element.scrollLeft;
220
+ /* Mouse drag, the one way of moving the track the browser does not give it:
221
+ wheel, trackpad, touch, pen and the keyboard all scroll it natively. The
222
+ docs promise click-and-drag, so it stays, as a thin layer over the
223
+ scroller -- a mouse press only, one pixel of track per pixel of pointer
224
+ (it was 1.5), and no snapping while the button is down, or every write to
225
+ scrollLeft would land on a stop. On release it settles on the nearest one.
226
+
227
+ This used to be mousedown and touchmove handlers writing scrollLeft over
228
+ a track that was overflow: hidden, which left the wheel, the trackpad and
229
+ the keyboard with nothing to move, and drove touch by script. */
230
+ _enableMouseDrag(track) {
231
+ let press = null;
232
+ let swallowClick = false;
233
+
234
+ track.addEventListener("pointerdown", (e) => {
235
+ if (e.pointerType !== "mouse" || e.button !== 0) return;
236
+ press = { id: e.pointerId, x: e.clientX, left: track.scrollLeft, dragging: false };
217
237
  });
218
238
 
219
- element.addEventListener("mouseleave", () => {
220
- isDown = false;
221
- element.classList.remove("dragging");
239
+ track.addEventListener("pointermove", (e) => {
240
+ if (press?.id !== e.pointerId) return;
241
+ // the button came up off the track before the press became a drag
242
+ if (!(e.buttons & 1)) { press = null; return; }
243
+ const dx = e.clientX - press.x;
244
+ if (!press.dragging) {
245
+ // a few pixels of travel first, so a click on + stays a click
246
+ if (Math.abs(dx) < 4) return;
247
+ press.dragging = true;
248
+ track.setPointerCapture(e.pointerId);
249
+ track.classList.add("dragging");
250
+ }
251
+ track.scrollLeft = press.left - dx;
222
252
  });
223
253
 
224
- element.addEventListener("mouseup", () => {
225
- isDown = false;
226
- element.classList.remove("dragging");
227
- });
254
+ const release = () => {
255
+ const dragged = press?.dragging;
256
+ press = null;
257
+ if (!dragged) return;
258
+ track.classList.remove("dragging");
259
+ this._settle();
260
+ // the click a drag ends with is not a click on the + or link under it;
261
+ // it comes in the same task as the pointerup, if it comes at all
262
+ swallowClick = true;
263
+ setTimeout(() => { swallowClick = false; });
264
+ };
265
+ for (const type of ["pointerup", "pointercancel", "lostpointercapture"]) {
266
+ track.addEventListener(type, release);
267
+ }
228
268
 
229
- element.addEventListener("mousemove", (e) => {
230
- if (!isDown) return;
269
+ track.addEventListener("click", (e) => {
270
+ if (!swallowClick) return;
231
271
  e.preventDefault();
232
- const x = e.pageX - element.offsetLeft;
233
- const walk = (x - startX) * 1.5;
234
- element.scrollLeft = scrollLeft - walk;
235
- });
236
-
237
- element.addEventListener("touchstart", (e) => {
238
- isDown = true;
239
- startX = e.touches[0].pageX - element.offsetLeft;
240
- scrollLeft = element.scrollLeft;
241
- });
272
+ e.stopPropagation();
273
+ }, { capture: true });
242
274
 
243
- element.addEventListener("touchend", () => {
244
- isDown = false;
245
- });
275
+ // a press is for moving the track, not for selecting copy or dragging an icon out
276
+ for (const type of ["selectstart", "dragstart"]) {
277
+ track.addEventListener(type, (e) => { if (press) e.preventDefault(); });
278
+ }
279
+ }
246
280
 
247
- element.addEventListener("touchmove", (e) => {
248
- if (!isDown) return;
249
- const x = e.touches[0].pageX - element.offsetLeft;
250
- const walk = (x - startX) * 1.5;
251
- element.scrollLeft = scrollLeft - walk;
252
- });
281
+ /* Where a drag leaves the track, the snap would take it: the nearest stop. */
282
+ _settle() {
283
+ const left = this._travelled;
284
+ let nearest = 1;
285
+ for (let n = 2; n <= this._pages; n++) {
286
+ if (Math.abs(this._stop(n) - left) < Math.abs(this._stop(nearest) - left)) nearest = n;
287
+ }
288
+ this._scrollToStop(nearest);
253
289
  }
254
290
 
255
291
  render() {
@@ -275,17 +311,17 @@ class CustomCarousel extends LitElement {
275
311
  </div>
276
312
  </div>
277
313
 
278
- ${this.selectedItem
279
- ? html`
280
- <bd-modal
281
- .open="${!!this.selectedItem}"
282
- .title="${this.selectedItem.title}"
283
- .modalText="${this.selectedItem.modalText}"
284
- .icon="${this.selectedItem.icon}"
285
- @close-modal="${this.closeModal}"
286
- ></bd-modal>
287
- `
288
- : ""}
314
+ <!-- Always rendered, and closed through open: a dialog closed is what
315
+ hands focus back to the + that opened it, and one removed while
316
+ open drops it on the page instead. It keeps the last item's copy
317
+ while it closes. -->
318
+ <bd-modal
319
+ .open="${!!this.selectedItem}"
320
+ .title="${this._shownItem?.title ?? ""}"
321
+ .modalText="${this._shownItem?.modalText ?? ""}"
322
+ .icon="${this._shownItem?.icon ?? ""}"
323
+ @close-modal="${this.closeModal}"
324
+ ></bd-modal>
289
325
  `;
290
326
  }
291
327
 
@@ -16,7 +16,7 @@ export default {
16
16
  ### Usage
17
17
  \`\`\`html
18
18
  <bd-carousel-section title="Security Features">
19
- <bd-carousel-item title="VPN" icon="/assets/analysis.svg" modalText="Our VPN protects your connection.">
19
+ <bd-carousel-item title="VPN" icon="/assets/device_protection.png" modalText="Our VPN protects your connection.">
20
20
  <p>Unlimited VPN included</p>
21
21
  </bd-carousel-item>
22
22
  </bd-carousel-section>
@@ -26,13 +26,15 @@ export default {
26
26
  - One dot per scroll stop: a stop is one item's width plus the gap, and the last is wherever the track ends
27
27
  - A dot scrolls there smoothly (instantly under \`prefers-reduced-motion\`)
28
28
  - When every item fits, there is nowhere to go and no controls render
29
- - Click and drag (mouse + touch) supported for scrolling; the dots follow any scroll
29
+ - The track is a native scroller: wheel, trackpad, touch and the keyboard move it, and it snaps to a stop; a mouse can click and drag it too. The dots follow any scroll
30
+ - No scrollbar is drawn; the dots say where the track is
30
31
  - Clicking \`+\` on an item fires \`open-modal\` custom event, caught by the carousel to show \`<bd-modal>\`
31
32
  - Modal closes via \`close-modal\` event
32
33
 
33
34
  ### Keyboard Support
34
35
  - The dots are real buttons
35
36
  - \`+\` button on items responds to Enter/Space
37
+ - Tabbing to an item's \`+\` scrolls that item into view; with focus there, the arrow keys scroll the track
36
38
  `
37
39
  }
38
40
  }
@@ -62,12 +64,12 @@ export default {
62
64
  };
63
65
 
64
66
  const sampleItems = [
65
- { title: 'VPN Protection', icon: '/assets/analysis.svg', modalText: 'Our VPN encrypts your internet traffic and hides your IP address.', content: 'Unlimited encrypted VPN traffic' },
66
- { title: 'Antivirus', icon: '/assets/analysis.svg', modalText: 'Real-time antivirus protection against all known and emerging threats.', content: 'Award-winning threat detection' },
67
- { title: 'Password Manager', icon: '/assets/analysis.svg', modalText: 'Store and autofill all your passwords securely across all devices.', content: 'Secure password vault' },
68
- { title: 'Parental Controls', icon: '/assets/analysis.svg', modalText: 'Monitor and control your children\'s online activity and screen time.', content: 'Advanced content filtering' },
69
- { title: 'Anti-Phishing', icon: '/assets/analysis.svg', modalText: 'Detects and blocks phishing websites before they can steal your data.', content: 'Real-time phishing protection' },
70
- { title: 'Webcam Protection', icon: '/assets/analysis.svg', modalText: 'Prevents unauthorized apps from accessing your webcam.', content: 'Webcam & mic access control' }
67
+ { title: 'VPN Protection', icon: '/assets/device_protection.png', modalText: 'Our VPN encrypts your internet traffic and hides your IP address.', content: 'Unlimited encrypted VPN traffic' },
68
+ { title: 'Antivirus', icon: '/assets/device_protection.png', modalText: 'Real-time antivirus protection against all known and emerging threats.', content: 'Award-winning threat detection' },
69
+ { title: 'Password Manager', icon: '/assets/device_protection.png', modalText: 'Store and autofill all your passwords securely across all devices.', content: 'Secure password vault' },
70
+ { title: 'Parental Controls', icon: '/assets/device_protection.png', modalText: 'Monitor and control your children\'s online activity and screen time.', content: 'Advanced content filtering' },
71
+ { title: 'Anti-Phishing', icon: '/assets/device_protection.png', modalText: 'Detects and blocks phishing websites before they can steal your data.', content: 'Real-time phishing protection' },
72
+ { title: 'Webcam Protection', icon: '/assets/device_protection.png', modalText: 'Prevents unauthorized apps from accessing your webcam.', content: 'Webcam & mic access control' }
71
73
  ];
72
74
 
73
75
  const renderItem = (item) => html`
@@ -85,7 +87,7 @@ export const Default = {
85
87
  ${sampleItems.map(renderItem)}
86
88
  </bd-carousel-section>
87
89
  `,
88
- parameters: { docs: { description: { story: '6-item carousel with title. Move with the dots under the track, or drag.' } } }
90
+ parameters: { docs: { description: { story: '6-item carousel with title. Move with the dots under the track, the wheel or a trackpad, the keyboard, or drag.' } } }
89
91
  };
90
92
 
91
93
  export const NoTitle = {
@@ -136,18 +138,18 @@ export const RichSlottedContent = {
136
138
  name : 'Rich Slotted Content',
137
139
  render: () => html`
138
140
  <bd-carousel-section title="Features">
139
- <bd-carousel-item title="VPN" icon="/assets/analysis.svg" modalText="Full VPN details here.">
141
+ <bd-carousel-item title="VPN" icon="/assets/device_protection.png" modalText="Full VPN details here.">
140
142
  <ul>
141
143
  <li>Unlimited bandwidth</li>
142
144
  <li>200+ server locations</li>
143
145
  <li>No-log policy</li>
144
146
  </ul>
145
147
  </bd-carousel-item>
146
- <bd-carousel-item title="Antivirus" icon="/assets/analysis.svg" modalText="Antivirus details here.">
148
+ <bd-carousel-item title="Antivirus" icon="/assets/device_protection.png" modalText="Antivirus details here.">
147
149
  <p>Real-time protection</p>
148
150
  <a href="#">Learn more</a>
149
151
  </bd-carousel-item>
150
- <bd-carousel-item title="Parental Controls" icon="/assets/analysis.svg" modalText="Parental control details.">
152
+ <bd-carousel-item title="Parental Controls" icon="/assets/device_protection.png" modalText="Parental control details.">
151
153
  <p>Safe browsing for kids</p>
152
154
  <p>Screen time management</p>
153
155
  </bd-carousel-item>
@@ -176,7 +178,7 @@ export const MobileView = {
176
178
  `,
177
179
  parameters: {
178
180
  viewport: { defaultViewport: 'mobile1' },
179
- docs : { description: { story: 'Carousel at 375px. Touch drag scrolling is supported.' } }
181
+ docs : { description: { story: 'Carousel at 375px. A swipe scrolls the track natively and it snaps to each item.' } }
180
182
  }
181
183
  };
182
184
 
@@ -185,7 +187,7 @@ export const Playground = {
185
187
  args: {
186
188
  title : 'Security Features',
187
189
  itemTitle: 'VPN Protection',
188
- itemIcon : '/assets/analysis.svg',
190
+ itemIcon : '/assets/device_protection.png',
189
191
  modalText: 'Our VPN encrypts your connection and protects your privacy.'
190
192
  },
191
193
  render: (args) => html`
@@ -193,10 +195,10 @@ export const Playground = {
193
195
  <bd-carousel-item title="${args.itemTitle}" icon="${args.itemIcon}" modalText="${args.modalText}">
194
196
  <p>Slotted content for this item.</p>
195
197
  </bd-carousel-item>
196
- <bd-carousel-item title="Antivirus" icon="/assets/analysis.svg" modalText="Real-time antivirus protection.">
198
+ <bd-carousel-item title="Antivirus" icon="/assets/device_protection.png" modalText="Real-time antivirus protection.">
197
199
  <p>Award-winning threat detection</p>
198
200
  </bd-carousel-item>
199
- <bd-carousel-item title="Parental Controls" icon="/assets/analysis.svg" modalText="Monitor your children's activity.">
201
+ <bd-carousel-item title="Parental Controls" icon="/assets/device_protection.png" modalText="Monitor your children's activity.">
200
202
  <p>Advanced content filtering</p>
201
203
  </bd-carousel-item>
202
204
  </bd-carousel-section>