@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.
- package/CHANGELOG.md +91 -0
- package/README.md +2 -1
- package/package.json +14 -27
- package/schemas/component-manifest.json +233 -33
- package/schemas/manifest-omissions.json +23 -0
- package/src/components/accordion/accordion-bg.css.js +39 -30
- package/src/components/accordion/accordion-bg.js +17 -28
- package/src/components/accordion/accordion-bg.stories.js +5 -0
- package/src/components/accordion/accordion-panel.js +24 -0
- package/src/components/accordion/accordion.css.js +105 -111
- package/src/components/accordion/accordion.js +23 -37
- package/src/components/accordion/accordion.stories.js +5 -1
- package/src/components/anchor/anchor-nav.css.js +131 -53
- package/src/components/anchor/anchor-nav.js +276 -201
- package/src/components/annotation/annotation.css.js +7 -4
- package/src/components/architecture.stories.js +8 -7
- package/src/components/audience-card/audience-card.css.js +30 -4
- package/src/components/audience-card/audience-card.js +8 -13
- package/src/components/awards/awards-flex.css.js +23 -6
- package/src/components/awards/awards-flex.js +21 -6
- package/src/components/awards/awards-spotlight.css.js +25 -5
- package/src/components/awards/awards-spotlight.js +19 -7
- package/src/components/awards/awards.css.js +20 -8
- package/src/components/awards/awards.js +30 -91
- package/src/components/awards/awards.stories.js +5 -5
- package/src/components/awards/scroll-slides.js +128 -0
- package/src/components/back/back.css.js +2 -0
- package/src/components/badge/badge.css.js +15 -0
- package/src/components/bento-grid/bento-grid.css.js +105 -11
- package/src/components/bento-grid/bento-grid.js +37 -124
- package/src/components/bento-grid/bento-grid.stories.js +3 -2
- package/src/components/bento-grid/bento-item.css.js +71 -32
- package/src/components/bento-grid/bento-item.js +1 -30
- package/src/components/blockquote/blockquote.css.js +2 -2
- package/src/components/breadcrumb/breadcrumb.css.js +10 -9
- package/src/components/breadcrumb/breadcrumb.js +35 -34
- package/src/components/button/button.css.js +42 -17
- package/src/components/button/button.js +84 -3
- package/src/components/button/button.stories.js +17 -0
- package/src/components/card-features/card-features.css.js +23 -2
- package/src/components/card-features/card-features.js +6 -48
- package/src/components/cards/card.css.js +43 -14
- package/src/components/cards/card.js +43 -177
- package/src/components/cards/card.stories.js +8 -10
- package/src/components/carousel/carousel.css.js +101 -70
- package/src/components/carousel/carousel.js +107 -71
- package/src/components/carousel/carousel.stories.js +18 -16
- package/src/components/checkbox/checkbox.css.js +26 -9
- package/src/components/checkbox/checkbox.js +73 -39
- package/src/components/checkbox/checkbox.stories.js +35 -18
- package/src/components/compare/compare.css.js +68 -10
- package/src/components/compare/compare.js +40 -103
- package/src/components/compare/compare.stories.js +1 -1
- package/src/components/compatibility-table/compatibility-table.css.js +70 -37
- package/src/components/compatibility-table/compatibility-table.js +47 -40
- package/src/components/compatibility-table/compatibility-table.stories.js +78 -1
- package/src/components/display/display.css.js +7 -0
- package/src/components/dropdown/dropdown.css.js +20 -3
- package/src/components/dropdown/dropdown.js +57 -21
- package/src/components/dropdown/dropdown.stories.js +31 -9
- package/src/components/features/features.css.js +56 -21
- package/src/components/features/features.js +7 -117
- package/src/components/fieldset/fieldset.stories.js +68 -0
- package/src/components/footer/footer-images.js +34 -0
- package/src/components/footer/footer-links-group.css.js +10 -10
- package/src/components/footer/footer-locale.js +47 -0
- package/src/components/footer/footer-lp.js +27 -114
- package/src/components/footer/footer-lp.stories.js +2 -2
- package/src/components/footer/footer-nav-menu.css.js +2 -2
- package/src/components/footer/footer-nav-menu.js +8 -3
- package/src/components/footer/footer.css.js +228 -197
- package/src/components/footer/footer.js +109 -187
- package/src/components/footer/footer.stories.js +14 -4
- package/src/components/grid/grid.css.js +56 -20
- package/src/components/grid/grid.js +20 -15
- package/src/components/grid/grid.stories.js +39 -11
- package/src/components/header/header-code.css.js +20 -11
- package/src/components/header/header-code.js +1 -1
- package/src/components/header/header.css.js +20 -14
- package/src/components/header/header.js +6 -7
- package/src/components/header/header.stories.js +29 -24
- package/src/components/heading/heading.css.js +11 -0
- package/src/components/hero/hero.js +10 -2
- package/src/components/highlight/highlight.css.js +30 -6
- package/src/components/icons/arrow-icon.js +4 -1
- package/src/components/icons/arrow-right-icon.js +5 -1
- package/src/components/icons/icon-element.js +18 -0
- package/src/components/image/image.js +29 -9
- package/src/components/image/image.stories.js +38 -2
- package/src/components/input/custom-form.stories.js +38 -7
- package/src/components/input/input-clipboard.css.js +15 -1
- package/src/components/input/input-clipboard.js +84 -21
- package/src/components/input/input.js +27 -7
- package/src/components/install-options/install-options.css.js +26 -6
- package/src/components/install-options/install-options.js +32 -8
- package/src/components/label/label.css.js +1 -1
- package/src/components/light-carousel/light-carousel.css.js +100 -48
- package/src/components/light-carousel/light-carousel.js +43 -5
- package/src/components/link/link.css.js +15 -15
- package/src/components/link/link.js +17 -1
- package/src/components/link/link.stories.js +20 -7
- package/src/components/list/list.css.js +3 -3
- package/src/components/logo-marquee/logo-marquee.css.js +12 -1
- package/src/components/logo-marquee/logo-marquee.js +33 -8
- package/src/components/logo-marquee/logo-marquee.stories.js +10 -4
- package/src/components/modal/modal.css.js +74 -40
- package/src/components/modal/modal.js +85 -74
- package/src/components/modal/modal.stories.js +27 -14
- package/src/components/motion-art/motion-art.js +67 -1
- package/src/components/page-switcher/page-switcher.css.js +27 -9
- package/src/components/page-switcher/page-switcher.js +11 -8
- package/src/components/partner-banner/partner-banner.css.js +2 -0
- package/src/components/picture/picture.css.js +4 -4
- package/src/components/picture/picture.js +13 -3
- package/src/components/picture/picture.stories.js +28 -2
- package/src/components/post-card/post-card.css.js +18 -3
- package/src/components/pricing-cards/adopt-styles.js +16 -0
- package/src/components/pricing-cards/new-pricing-card.js +2 -4
- package/src/components/pricing-cards/new-pricing-card.stories.js +20 -22
- package/src/components/pricing-cards/pricing-card-actions.css.js +8 -12
- package/src/components/pricing-cards/pricing-card-actions.js +26 -13
- package/src/components/pricing-cards/pricing-card-container.css.js +4 -3
- package/src/components/pricing-cards/pricing-card-container.js +10 -4
- package/src/components/pricing-cards/pricing-card-header.css.js +5 -4
- package/src/components/pricing-cards/pricing-card-header.js +18 -31
- package/src/components/pricing-cards/pricing-card-pricing.css.js +84 -61
- package/src/components/pricing-cards/pricing-card-pricing.js +38 -24
- package/src/components/pricing-cards/pricing-card-show-more.js +8 -3
- package/src/components/pricing-cards/pricing-card.css.js +75 -41
- package/src/components/pricing-cards/pricing-card.js +356 -308
- package/src/components/progress/progress.css.js +58 -13
- package/src/components/progress/progress.js +13 -10
- package/src/components/progress/progress.stories.js +9 -7
- package/src/components/radio/radio-group.css.js +42 -0
- package/src/components/radio/radio-group.js +89 -0
- package/src/components/radio/radio.css.js +63 -6
- package/src/components/radio/radio.js +173 -140
- package/src/components/radio/radio.stories.js +99 -44
- package/src/components/radio/toggle-radio.js +44 -0
- package/src/components/review/review-grid.css.js +5 -1
- package/src/components/review/review-grid.js +2 -0
- package/src/components/review/review.js +13 -0
- package/src/components/shared/announcer.js +37 -0
- package/src/components/shared/fill-width.css.js +29 -0
- package/src/components/shared/form-control.js +194 -0
- package/src/components/shared/form-field.css.js +31 -3
- package/src/components/shared/token-scales.js +75 -26
- package/src/components/spotlight-section/spotlight-section.js +2 -2
- package/src/components/stat/stat-highlight.js +1 -1
- package/src/components/stat/stat.css.js +18 -3
- package/src/components/switch/switch.css.js +58 -5
- package/src/components/switch/switch.js +53 -5
- package/src/components/switch/switch.stories.js +30 -8
- package/src/components/tab-list/tab-list.css.js +51 -13
- package/src/components/tab-list/tab-list.js +7 -2
- package/src/components/tab-list/tab-list.stories.js +2 -2
- package/src/components/tabs/tabs.css.js +18 -1
- package/src/components/tabs/tabs.js +119 -41
- package/src/components/terminal/terminal-message.css.js +6 -1
- package/src/components/termsOfUse/terms.css.js +4 -2
- package/src/components/textarea/textarea.js +22 -7
- package/src/components/textarea/textarea.stories.js +12 -9
- package/src/components/trust-panel/trust-panel.css.js +13 -3
- package/src/components/ultimate-security-demo.stories.js +5 -5
- package/src/components/video/video.css.js +5 -0
- package/src/components/video/video.js +5 -0
- package/src/components/video/video.stories.js +12 -0
- package/src/components/video-player/video-player.css.js +20 -8
- package/src/components/video-player/video-player.js +74 -20
- package/src/components/video-player/video-player.stories.js +17 -3
- package/src/tokens/brands.stories.js +1 -1
- package/src/tokens/themes/index.js +2 -2
- package/src/tokens/typography.stories.js +4 -3
- package/src/vendor/motion-art/README.md +4 -1
- package/src/components/footer/footer-lp.css.js +0 -159
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { html } from "lit";
|
|
2
|
+
// Installs the design tokens into document scope; see src/tokens/tokens.js
|
|
3
|
+
import "../../tokens/tokens.js";
|
|
4
|
+
import radioCSS from "./radio.css.js";
|
|
5
|
+
import { BdCheckbox } from "../checkbox/checkbox.js";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Toggles independently despite looking like a radio, which is why it is a
|
|
9
|
+
* checkbox underneath. It duplicates bd-checkbox with a circular skin, and a
|
|
10
|
+
* round control that does not behave exclusively misleads people — it should
|
|
11
|
+
* be retired in favour of bd-checkbox. Kept working here because it is a
|
|
12
|
+
* published element with stories against it.
|
|
13
|
+
*
|
|
14
|
+
* It was a <div role="checkbox"> with its own tabindex and its own Space and
|
|
15
|
+
* Enter handling. It is bd-checkbox now, drawn as a circle: the same native
|
|
16
|
+
* checkbox underneath, so the browser supplies the role, the checked and
|
|
17
|
+
* disabled states, Space and the disabled tab order, and everything a form
|
|
18
|
+
* does with it -- submit, reset, required, <fieldset disabled>, Enter
|
|
19
|
+
* submitting rather than toggling -- is bd-checkbox's, written once
|
|
20
|
+
* (shared/form-control.js). Only the drawing is its own: the circle, and no
|
|
21
|
+
* indeterminate mark.
|
|
22
|
+
*/
|
|
23
|
+
class BdToggleRadio extends BdCheckbox {
|
|
24
|
+
static styles = [radioCSS];
|
|
25
|
+
|
|
26
|
+
render() {
|
|
27
|
+
return html`
|
|
28
|
+
<label class="bd-radio">
|
|
29
|
+
<input
|
|
30
|
+
type="checkbox"
|
|
31
|
+
.checked=${this.checked}
|
|
32
|
+
?disabled=${this.disabled || this._formDisabled}
|
|
33
|
+
?required=${this.required}
|
|
34
|
+
@change=${this._onChange}
|
|
35
|
+
@keydown=${this._onKeydown}
|
|
36
|
+
/>
|
|
37
|
+
<span class="box" part="box"><span class="dot"></span></span>
|
|
38
|
+
<span class="label" part="label"><slot>${this.label}</slot></span>
|
|
39
|
+
</label>
|
|
40
|
+
`;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
customElements.define("bd-toggle-radio", BdToggleRadio);
|
|
@@ -6,6 +6,10 @@ export default css`
|
|
|
6
6
|
display: block;
|
|
7
7
|
width: 100%;
|
|
8
8
|
box-sizing: border-box;
|
|
9
|
+
/* The grid's own width decides when its cards stack, not the screen's:
|
|
10
|
+
across the page the two are the same, in a narrower column the cards
|
|
11
|
+
stack with it. */
|
|
12
|
+
container-type: inline-size;
|
|
9
13
|
}
|
|
10
14
|
|
|
11
15
|
.bd-reviewgrid-title {
|
|
@@ -31,7 +35,7 @@ export default css`
|
|
|
31
35
|
}
|
|
32
36
|
|
|
33
37
|
/* below lg, as install-options: three cards stack across 900-991 too. */
|
|
34
|
-
@
|
|
38
|
+
@container ${unsafeCSS(below('lg'))} {
|
|
35
39
|
.bd-reviewgrid-grid {
|
|
36
40
|
grid-template-columns: 1fr;
|
|
37
41
|
}
|
|
@@ -24,6 +24,8 @@ class BdReviewGrid extends LitElement {
|
|
|
24
24
|
return [...this.children].filter((el) => el.tagName === "BD-REVIEW");
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
+
/* The grid is a list (role="list" below), and each bd-review in it says it
|
|
28
|
+
is one of its items itself (review.js). */
|
|
27
29
|
_onSlotChange() {
|
|
28
30
|
const count = this._items.length;
|
|
29
31
|
this._columns = count <= 0 ? 1 : Math.min(count, 3);
|
|
@@ -30,9 +30,22 @@ class BdReview extends LitElement {
|
|
|
30
30
|
|
|
31
31
|
constructor() {
|
|
32
32
|
super();
|
|
33
|
+
this._internals = this.attachInternals();
|
|
33
34
|
this.variant = "tint";
|
|
34
35
|
}
|
|
35
36
|
|
|
37
|
+
/* In a bd-review-grid, a review is one item of the grid's list -- a list
|
|
38
|
+
whose children are not list items is announced as an empty list, or not
|
|
39
|
+
at all (axe: aria-required-children). The role is the element's own,
|
|
40
|
+
through ElementInternals, as bd-breadcrumb-item's is: the grid used to
|
|
41
|
+
write role="listitem" onto the page's markup, where it stayed after the
|
|
42
|
+
review left the list. A role the page writes on the element still wins,
|
|
43
|
+
and outside a grid a review is no item of anything. */
|
|
44
|
+
connectedCallback() {
|
|
45
|
+
super.connectedCallback();
|
|
46
|
+
this._internals.role = this.parentElement?.localName === "bd-review-grid" ? "listitem" : null;
|
|
47
|
+
}
|
|
48
|
+
|
|
36
49
|
render() {
|
|
37
50
|
return html`
|
|
38
51
|
<div class="bd-review-card">
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a component says through its one live region: bd-install-options'
|
|
3
|
+
* "Copied" and the clipboard field's paste result.
|
|
4
|
+
*
|
|
5
|
+
* The region is rendered from the start -- a region inserted holding its
|
|
6
|
+
* text is, to many screen readers, not a change (see bd-spinner) -- and each
|
|
7
|
+
* message empties it first and fills it a moment later, so the same message
|
|
8
|
+
* twice is a change as well. The host renders `status` in an element with
|
|
9
|
+
* role="status":
|
|
10
|
+
*
|
|
11
|
+
* this._announcer = new Announcer(this);
|
|
12
|
+
* this._announcer.say("Copied");
|
|
13
|
+
* html`<span role="status">${this._announcer.status}</span>`
|
|
14
|
+
*/
|
|
15
|
+
export class Announcer {
|
|
16
|
+
constructor(host) {
|
|
17
|
+
this.host = host;
|
|
18
|
+
this.status = "";
|
|
19
|
+
this._timer = 0;
|
|
20
|
+
host.addController(this);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
say(message) {
|
|
24
|
+
clearTimeout(this._timer);
|
|
25
|
+
this._set("");
|
|
26
|
+
this._timer = setTimeout(() => this._set(message), 100);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
_set(message) {
|
|
30
|
+
this.status = message;
|
|
31
|
+
this.host.requestUpdate();
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
hostDisconnected() {
|
|
35
|
+
clearTimeout(this._timer);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { unsafeCSS } from "lit";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The width a size container's host takes: all of its column, less its own
|
|
5
|
+
* margins.
|
|
6
|
+
*
|
|
7
|
+
* An element with `container-type: inline-size` contributes nothing to its
|
|
8
|
+
* own intrinsic width, so where its parent sizes it to its content -- a flex
|
|
9
|
+
* row, a grid placing items at start -- it measures 0. These hosts used to
|
|
10
|
+
* answer that with `width: 100%`, which fills the containing block and
|
|
11
|
+
* ignores the host's margins: a page writing `margin-inline: 24px` on one got
|
|
12
|
+
* a box 48px wider than its column, scrolling the page sideways on a phone.
|
|
13
|
+
*
|
|
14
|
+
* `stretch` is the width a block takes by default -- the containing block
|
|
15
|
+
* less the margins -- asked for explicitly, so it holds in a flex row or a
|
|
16
|
+
* grid cell too. It is newer than the Widely available target, so it is
|
|
17
|
+
* behind @supports with 100% before it, and its prefixed spellings come
|
|
18
|
+
* first, Gecko's and then WebKit's, so the standard one wins where more than
|
|
19
|
+
* one is read (CLAUDE.md, Browser support).
|
|
20
|
+
*
|
|
21
|
+
* :host { display: block; container-type: inline-size; }
|
|
22
|
+
* ${hostFillsWidth()}
|
|
23
|
+
*/
|
|
24
|
+
const KEYWORDS = ["-moz-available", "-webkit-fill-available", "stretch"];
|
|
25
|
+
|
|
26
|
+
export const hostFillsWidth = () => unsafeCSS([
|
|
27
|
+
":host { width: 100%; }",
|
|
28
|
+
...KEYWORDS.map(keyword => `@supports (width: ${keyword}) { :host { width: ${keyword}; } }`)
|
|
29
|
+
].join("\n"));
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What makes a bd-* control take part in a <form>.
|
|
3
|
+
*
|
|
4
|
+
* Every control in this package renders its native element inside a shadow
|
|
5
|
+
* root, and a native control there has no form owner: the <form> around the
|
|
6
|
+
* element could not see it. A form submitted none of them, reset none of them
|
|
7
|
+
* and let a required one through empty. Form-associated custom elements are
|
|
8
|
+
* the platform's answer -- Baseline Widely available since 2023 -- so the
|
|
9
|
+
* host joins the form itself through ElementInternals, the way the guide in
|
|
10
|
+
* .claude/skills/modern-web-guidance/guides/html/form-associated-custom-elements.md
|
|
11
|
+
* lays out, with no hidden input.
|
|
12
|
+
*
|
|
13
|
+
* This is the part every control shares: the opt-in, the internals, the
|
|
14
|
+
* read-only surface a native control has (form, validity, checkValidity...),
|
|
15
|
+
* and the two states a control cannot see from inside its shadow root -- a
|
|
16
|
+
* <fieldset disabled> around it, and a submit that failed. What a control
|
|
17
|
+
* submits, when it is valid and what reset puts back are its own.
|
|
18
|
+
*
|
|
19
|
+
* class BdThing extends FormControl(LitElement) { ... }
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/* For `name`, which reflects: FACE submits under the host's name ATTRIBUTE, so
|
|
23
|
+
a name set as a property -- what every framework binding does -- has to
|
|
24
|
+
reach it. An empty name submits nothing either way, so it is left off the
|
|
25
|
+
element rather than written as name="" on every control on the page. */
|
|
26
|
+
export const omitEmpty = { toAttribute: value => value || null };
|
|
27
|
+
|
|
28
|
+
/* The input types that block implicit submission (HTML, "implicit
|
|
29
|
+
submission"): a form with no submit button submits on Enter only while it
|
|
30
|
+
has at most one field of these. A text field here says which type it is
|
|
31
|
+
through its own `type`, so it is counted the same way. */
|
|
32
|
+
const BLOCKS_IMPLICIT_SUBMISSION = new Set([
|
|
33
|
+
'text', 'search', 'url', 'tel', 'email', 'password', 'date', 'month', 'week', 'time',
|
|
34
|
+
'datetime-local', 'number'
|
|
35
|
+
]);
|
|
36
|
+
|
|
37
|
+
export const FormControl = Base => class extends Base {
|
|
38
|
+
static formAssociated = true;
|
|
39
|
+
|
|
40
|
+
static properties = {
|
|
41
|
+
/* Disabled as the form sees it: the control's own `disabled`, or a
|
|
42
|
+
<fieldset disabled> it sits in. The platform reports both through
|
|
43
|
+
formDisabledCallback. It is kept here and never written to the host's
|
|
44
|
+
attribute, or a fieldset re-enabled later could not re-enable it. */
|
|
45
|
+
_formDisabled: { state: true },
|
|
46
|
+
/* A submit has been tried and found this control invalid. A native
|
|
47
|
+
control turns :user-invalid then, but the native element in here has
|
|
48
|
+
no form owner, so it never learns of the attempt; the `invalid` event
|
|
49
|
+
the form fires at the host is how it hears. checkValidity() fires the
|
|
50
|
+
same event, so a silent check counts too. Reset clears it. */
|
|
51
|
+
_attempted : { state: true }
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
constructor() {
|
|
55
|
+
super();
|
|
56
|
+
this._internals = this.attachInternals();
|
|
57
|
+
this._formDisabled = false;
|
|
58
|
+
this._attempted = false;
|
|
59
|
+
this.addEventListener('invalid', () => { this._attempted = true; });
|
|
60
|
+
/* An outside activation is passed on to the native control, whose own
|
|
61
|
+
click then reaches this element like any other. This one stops here, so
|
|
62
|
+
a click listener on the element hears one click, not two -- one
|
|
63
|
+
el.click() is one click on a native control. Registered in the
|
|
64
|
+
constructor, it runs before any listener the page adds. */
|
|
65
|
+
this.addEventListener('click', e => {
|
|
66
|
+
if (e.composedPath()[0] !== this || !this._fromOutside(e)) return;
|
|
67
|
+
e.stopImmediatePropagation();
|
|
68
|
+
this._activate();
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/* A click on the host itself, not on anything inside it, is one of three
|
|
73
|
+
things. A <label for> pointing at this element sends one carrying the
|
|
74
|
+
label's position, and el.click() an untrusted one: the two ways a native
|
|
75
|
+
control is activated from outside, and both activate this one. The third
|
|
76
|
+
is a real click inside the host's own box but on nothing in it -- the
|
|
77
|
+
slack beside a short label when a column stretches the host -- and that
|
|
78
|
+
did nothing before and still does not, or a wide row would toggle from
|
|
79
|
+
across the page. */
|
|
80
|
+
_fromOutside(e) {
|
|
81
|
+
if (!e.isTrusted) return true;
|
|
82
|
+
const r = this.getBoundingClientRect();
|
|
83
|
+
return e.clientX < r.left || e.clientX > r.right || e.clientY < r.top || e.clientY > r.bottom;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** The native element inside; each control says which. */
|
|
87
|
+
get _control() {
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** What an outside activation does: a field takes focus, a checkable control overrides this to toggle. */
|
|
92
|
+
_activate() {
|
|
93
|
+
this._control?.focus();
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
get form() { return this._internals.form; }
|
|
97
|
+
get labels() { return this._internals.labels; }
|
|
98
|
+
get validity() { return this._internals.validity; }
|
|
99
|
+
get validationMessage() { return this._internals.validationMessage; }
|
|
100
|
+
get willValidate() { return this._internals.willValidate; }
|
|
101
|
+
checkValidity() { return this._internals.checkValidity(); }
|
|
102
|
+
reportValidity() { return this._internals.reportValidity(); }
|
|
103
|
+
|
|
104
|
+
/* Enter in a native text field, checkbox, radio or switch submits its
|
|
105
|
+
form -- implicit submission: the form's default button is clicked, or,
|
|
106
|
+
with none, the form is submitted, unless more than one of its fields
|
|
107
|
+
blocks that (BLOCKS_IMPLICIT_SUBMISSION above). Enter never toggles;
|
|
108
|
+
Space does. The native control in here has no form, so the host does it.
|
|
109
|
+
The default button is the form's first submit button, and a bd-button
|
|
110
|
+
with type="submit" is one: it is in form.elements and its type says so.
|
|
111
|
+
A disabled default button means no submission, as natively. */
|
|
112
|
+
_submitImplicitly() {
|
|
113
|
+
const form = this.form;
|
|
114
|
+
if (!form) return;
|
|
115
|
+
const elements = [...form.elements];
|
|
116
|
+
const button = elements.find(el => el.type === 'submit' || el.type === 'image');
|
|
117
|
+
if (button) {
|
|
118
|
+
if (!button.matches(':disabled')) button.click();
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
const blocking = elements.filter(el => BLOCKS_IMPLICIT_SUBMISSION.has(el.type)).length;
|
|
122
|
+
if (blocking <= 1) form.requestSubmit();
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
formDisabledCallback(disabled) {
|
|
126
|
+
this._formDisabled = disabled;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
formResetCallback() {
|
|
130
|
+
this._attempted = false;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/* The native control already knows whether it is valid, and says so in the
|
|
134
|
+
browser's own words and language, so the host repeats it rather than
|
|
135
|
+
re-deriving it. The control is the anchor: reportValidity() and a failed
|
|
136
|
+
submit focus it and point the message at it. A disabled control is out
|
|
137
|
+
of validation altogether, and says so with an empty message that
|
|
138
|
+
setValidity() would refuse; the host is disabled with it. */
|
|
139
|
+
_mirrorValidity(control) {
|
|
140
|
+
if (!control?.willValidate || control.validity.valid) {
|
|
141
|
+
this._internals.setValidity({});
|
|
142
|
+
} else {
|
|
143
|
+
this._internals.setValidity(control.validity, control.validationMessage, control);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* What a control holding a typed or chosen value adds to FormControl --
|
|
150
|
+
* bd-custom-input, the clipboard field, bd-textarea, bd-custom-dropdown.
|
|
151
|
+
*
|
|
152
|
+
* The `value` property is the current value and the value ATTRIBUTE is the
|
|
153
|
+
* default a reset returns to, as on a native field. A reset also rebuilds the
|
|
154
|
+
* native control -- the subclass keys it on `_resets` -- because it has to
|
|
155
|
+
* forget that the reader touched it (:user-invalid), and only the form it
|
|
156
|
+
* belongs to could tell it that; the control in here has none.
|
|
157
|
+
*
|
|
158
|
+
* class BdField extends ValueControl(LitElement) { ... }
|
|
159
|
+
*/
|
|
160
|
+
export const ValueControl = Base => class extends FormControl(Base) {
|
|
161
|
+
static properties = {
|
|
162
|
+
_resets: { state: true }
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
constructor() {
|
|
166
|
+
super();
|
|
167
|
+
this._resets = 0;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/* What a form sees: the value, and whether the native control finds it
|
|
171
|
+
valid -- required, type, and anything else it checks -- in its own
|
|
172
|
+
words. Called after every update, and before a field's own events, so a
|
|
173
|
+
handler asking the form gets the answer for what was just typed. */
|
|
174
|
+
_sync() {
|
|
175
|
+
this._internals.setFormValue(this.value);
|
|
176
|
+
this._mirrorValidity(this._control);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
formResetCallback() {
|
|
180
|
+
super.formResetCallback();
|
|
181
|
+
this.value = this.getAttribute('value') ?? '';
|
|
182
|
+
this._resets++;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
formStateRestoreCallback(state) {
|
|
186
|
+
this.value = state;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/* Enter in a one-line field submits its form, as from a native <input>.
|
|
190
|
+
Not mid-composition: there Enter commits the IME's candidate. */
|
|
191
|
+
_onFieldKeydown(e) {
|
|
192
|
+
if (e.key === 'Enter' && !e.isComposing) this._submitImplicitly();
|
|
193
|
+
}
|
|
194
|
+
};
|
|
@@ -71,7 +71,7 @@ export const formFieldCSS = css`
|
|
|
71
71
|
|
|
72
72
|
.form-label__required {
|
|
73
73
|
color: var(--form-label-required-color);
|
|
74
|
-
margin-
|
|
74
|
+
margin-inline-start: var(--form-label-required-marginLeft);
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
/* ---- the control ------------------------------------------------------
|
|
@@ -176,12 +176,28 @@ export const formFieldCSS = css`
|
|
|
176
176
|
showing. text-muted gives 5.95 and 6.25. The plain field keeps
|
|
177
177
|
text-subtle (4.81). */
|
|
178
178
|
.form-input--error::placeholder,
|
|
179
|
+
.form-input-bd:where(:user-invalid)::placeholder,
|
|
180
|
+
.form-input--attempted:where(:invalid)::placeholder,
|
|
179
181
|
.form-input--success::placeholder {
|
|
180
182
|
color: var(--color-text-muted);
|
|
181
183
|
}
|
|
182
184
|
|
|
183
|
-
/* ---- states -----------------------------------------------------------
|
|
184
|
-
|
|
185
|
+
/* ---- states -----------------------------------------------------------
|
|
186
|
+
Error is what the browser finds, not only a flag. A control that fails
|
|
187
|
+
its own constraints -- required and empty, an email that is not one --
|
|
188
|
+
shows it once the reader has finished with it (:user-invalid: changed,
|
|
189
|
+
then left) or once a submit has been tried (--attempted, which the host
|
|
190
|
+
sets on the form's invalid event: the control in here has no form owner,
|
|
191
|
+
so :user-invalid never hears of the submit). Before either, an empty
|
|
192
|
+
required field is not yet an error, which is the point of :user-invalid.
|
|
193
|
+
|
|
194
|
+
The invalid prop still forces the state, for what only the page
|
|
195
|
+
knows -- a server's answer. :where() holds all three at one class's
|
|
196
|
+
weight, so the focus border above still wins while the reader is
|
|
197
|
+
correcting the field, as it always has for the prop. */
|
|
198
|
+
.form-input--error,
|
|
199
|
+
.form-input-bd:where(:user-invalid),
|
|
200
|
+
.form-input--attempted:where(:invalid) {
|
|
185
201
|
background-color: var(--form-input-error-backgroundColor);
|
|
186
202
|
border-color: var(--form-input-error-borderColor);
|
|
187
203
|
}
|
|
@@ -218,6 +234,18 @@ export const formFieldCSS = css`
|
|
|
218
234
|
color: var(--form-help-text-error-color);
|
|
219
235
|
}
|
|
220
236
|
|
|
237
|
+
/* Rules of their own: :has() is not forgiving, so a browser that does not
|
|
238
|
+
know :user-invalid drops the whole rule it sits in -- in a list with the
|
|
239
|
+
class above, it took the invalid prop's help-text colour with it, and
|
|
240
|
+
beside the attempted case it would take that too. */
|
|
241
|
+
.input-container:has(.form-input--attempted:invalid) .form-help-text--default {
|
|
242
|
+
color: var(--form-help-text-error-color);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
.input-container:has(.form-input-bd:user-invalid) .form-help-text--default {
|
|
246
|
+
color: var(--form-help-text-error-color);
|
|
247
|
+
}
|
|
248
|
+
|
|
221
249
|
.form-help-text--success {
|
|
222
250
|
color: var(--form-help-text-success-color);
|
|
223
251
|
}
|
|
@@ -227,14 +227,14 @@ export const spacingShorthand = value => {
|
|
|
227
227
|
|
|
228
228
|
WHY THE HELPER OWNS THE COMPLEMENT.
|
|
229
229
|
|
|
230
|
-
A breakpoint is one number, but it has two
|
|
231
|
-
|
|
230
|
+
A breakpoint is one number, but it has two sides, and writing the second
|
|
231
|
+
one by hand is how the boundary drifts. `min-width: 768px` and
|
|
232
232
|
`max-width: 768px` are both true at exactly 768px, so a component that
|
|
233
|
-
|
|
234
|
-
desktop styling at that one width
|
|
235
|
-
|
|
236
|
-
`@media (min-width: 768px) and (max-width: 1024px)` at another
|
|
237
|
-
thirteen more files
|
|
233
|
+
spelled its mobile rule the obvious way applied both its mobile and its
|
|
234
|
+
desktop styling at that one width: pricing-card.css.js had
|
|
235
|
+
`@media (max-width: 768px)` at one rule and
|
|
236
|
+
`@media (min-width: 768px) and (max-width: 1024px)` at another, and
|
|
237
|
+
thirteen more files used the same `max-width: 768px` form.
|
|
238
238
|
|
|
239
239
|
The complement is derived here so that number is never typed. Do not write
|
|
240
240
|
767px, 991px or 1199px anywhere; write `below('md')`, `below('lg')`,
|
|
@@ -242,24 +242,24 @@ export const spacingShorthand = value => {
|
|
|
242
242
|
|
|
243
243
|
---
|
|
244
244
|
|
|
245
|
-
WHY
|
|
245
|
+
WHY RANGE SYNTAX, AND NO EPSILON.
|
|
246
246
|
|
|
247
|
-
|
|
247
|
+
`(width >= 768px)` and `(width < 768px)` are exact complements: every
|
|
248
|
+
width, fractional ones included, matches one of them and never both. A
|
|
249
|
+
viewport is not always a whole number of pixels -- browser zoom, some
|
|
248
250
|
Android densities and fractional device-pixel-ratios all produce widths
|
|
249
|
-
like 767.5px
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
251
|
+
like 767.5px -- and the min-/max- spelling could not say "narrower than"
|
|
252
|
+
without choosing a number below the breakpoint. `max-width: 767px` left
|
|
253
|
+
every width between 767 and 768 matched by neither side, and the
|
|
254
|
+
`max-width: 767.98px` this helper emitted until 2026-10-28 shrank that band
|
|
255
|
+
to a fiftieth of a pixel rather than closing it. The range form has no
|
|
256
|
+
number to choose.
|
|
255
257
|
|
|
256
|
-
|
|
257
|
-
|
|
258
|
+
Media query range syntax is Baseline Widely available (since 2023-03), so
|
|
259
|
+
it is used as is. The same conditions are valid in @container, where they
|
|
260
|
+
ask the container's width instead of the viewport's:
|
|
258
261
|
|
|
259
|
-
|
|
260
|
-
1199.98, 1399.98 and 1599.98 all round-trip — so no rounding is needed here. If a
|
|
261
|
-
value is ever added to the scale whose complement does not, this is where
|
|
262
|
-
the rounding belongs. */
|
|
262
|
+
@container ${below('sm')} { ... } */
|
|
263
263
|
|
|
264
264
|
export const BREAKPOINTS = {
|
|
265
265
|
xs : 0,
|
|
@@ -286,19 +286,19 @@ const step = name => {
|
|
|
286
286
|
/**
|
|
287
287
|
* "This breakpoint and wider."
|
|
288
288
|
*
|
|
289
|
-
* above('md') → (
|
|
289
|
+
* above('md') → (width >= 768px)
|
|
290
290
|
*
|
|
291
|
-
* `above('xs')` is `(
|
|
291
|
+
* `above('xs')` is `(width >= 0px)`, which is always true. That is a
|
|
292
292
|
* harmless no-op rather than an error, because it is the honest answer for
|
|
293
293
|
* the bottom of the scale — but a rule that needs no condition should have
|
|
294
294
|
* no media query.
|
|
295
295
|
*/
|
|
296
|
-
export const above = name => `(
|
|
296
|
+
export const above = name => `(width >= ${step(name)}px)`;
|
|
297
297
|
|
|
298
298
|
/**
|
|
299
299
|
* "Narrower than this breakpoint" — the exact complement of `above`.
|
|
300
300
|
*
|
|
301
|
-
* below('md') → (
|
|
301
|
+
* below('md') → (width < 768px)
|
|
302
302
|
*
|
|
303
303
|
* `below('xs')` throws: xs is 0, and no viewport is narrower than that, so
|
|
304
304
|
* the query could only ever be dead CSS.
|
|
@@ -308,7 +308,7 @@ export const below = name => {
|
|
|
308
308
|
if (value === 0) {
|
|
309
309
|
throw new Error(`below('${name}') has no meaning: no viewport is narrower than ${value}px. Did you mean above('${name}')?`);
|
|
310
310
|
}
|
|
311
|
-
return `(
|
|
311
|
+
return `(width < ${value}px)`;
|
|
312
312
|
};
|
|
313
313
|
|
|
314
314
|
/**
|
|
@@ -333,3 +333,52 @@ export const matchesBelow = name => {
|
|
|
333
333
|
if (typeof window === 'undefined' || typeof window.matchMedia !== 'function') return false;
|
|
334
334
|
return window.matchMedia(condition).matches;
|
|
335
335
|
};
|
|
336
|
+
|
|
337
|
+
/* ================================================================
|
|
338
|
+
ROLE STEPS
|
|
339
|
+
================================================================
|
|
340
|
+
bd-h and bd-p size their text from the role their level or variant names
|
|
341
|
+
-- `.bd-heading.h4` reads --typography-heading-h4-*, `variant="small"`
|
|
342
|
+
reads --typography-body-small-* -- and offer no other hook. A component
|
|
343
|
+
whose type steps down at a width used to re-render with another level or
|
|
344
|
+
variant, decided once from the screen at render time and stale after any
|
|
345
|
+
resize, and moving the document outline with it.
|
|
346
|
+
|
|
347
|
+
readAs() keeps the level and the variant and steps the size in CSS: inside
|
|
348
|
+
a query, it points the role the element names at another one, on that
|
|
349
|
+
element only.
|
|
350
|
+
|
|
351
|
+
@container ${below('md')} {
|
|
352
|
+
.card-title { ${readAs('heading-h4', 'heading-h5')} }
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
The declarations land on an element inside the component's own shadow
|
|
356
|
+
root, where no page style can reach or override them -- not on :host,
|
|
357
|
+
where a re-declared token would shadow the page's. A role name is written
|
|
358
|
+
by the component author, so an unknown one throws, as below() does. */
|
|
359
|
+
|
|
360
|
+
const ROLE_AXES = {
|
|
361
|
+
'heading-h1' : ['fontSize', 'fontWeight', 'lineHeight', 'letterSpacing', 'fontFamily'],
|
|
362
|
+
'heading-h2' : ['fontSize', 'fontWeight', 'lineHeight', 'letterSpacing', 'fontFamily'],
|
|
363
|
+
'heading-h3' : ['fontSize', 'fontWeight', 'lineHeight', 'letterSpacing', 'fontFamily'],
|
|
364
|
+
'heading-h4' : ['fontSize', 'fontWeight', 'lineHeight', 'letterSpacing', 'fontFamily'],
|
|
365
|
+
'heading-h5' : ['fontSize', 'fontWeight', 'lineHeight', 'letterSpacing', 'fontFamily'],
|
|
366
|
+
'heading-h6' : ['fontSize', 'fontWeight', 'lineHeight', 'letterSpacing', 'fontFamily'],
|
|
367
|
+
/* bd-p's variant rules read four axes; the family is the paragraph's own. */
|
|
368
|
+
'body-large' : ['fontSize', 'fontWeight', 'lineHeight', 'letterSpacing'],
|
|
369
|
+
'body-regular': ['fontSize', 'fontWeight', 'lineHeight', 'letterSpacing'],
|
|
370
|
+
'body-small' : ['fontSize', 'fontWeight', 'lineHeight', 'letterSpacing']
|
|
371
|
+
};
|
|
372
|
+
|
|
373
|
+
/** "Text set in role `from` reads as role `to` here." Declarations, for inside a rule. */
|
|
374
|
+
export const readAs = (from, to) => {
|
|
375
|
+
for (const role of [from, to]) {
|
|
376
|
+
if (!Object.hasOwn(ROLE_AXES, role)) {
|
|
377
|
+
throw new Error(`Unknown type role: ${role}. Expected one of ${Object.keys(ROLE_AXES).join(', ')}.`);
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
if (from.split('-')[0] !== to.split('-')[0]) {
|
|
381
|
+
throw new Error(`readAs('${from}', '${to}'): a heading role reads as a heading, a body role as a body role.`);
|
|
382
|
+
}
|
|
383
|
+
return ROLE_AXES[from].map(axis => `--typography-${from}-${axis}: var(--typography-${to}-${axis});`).join(' ');
|
|
384
|
+
};
|
|
@@ -48,7 +48,7 @@ class BdSpotlightSection extends LitElement {
|
|
|
48
48
|
|
|
49
49
|
${flipped
|
|
50
50
|
? html`
|
|
51
|
-
<bd-p
|
|
51
|
+
<bd-p variant="large" color="on-brand" class="bd-spotlightsection-title bd-spotlightsection-title--small">
|
|
52
52
|
<slot name="title">${this.title}</slot>
|
|
53
53
|
</bd-p>
|
|
54
54
|
`
|
|
@@ -76,7 +76,7 @@ class BdSpotlightSection extends LitElement {
|
|
|
76
76
|
</bd-h>
|
|
77
77
|
`
|
|
78
78
|
: html`
|
|
79
|
-
<bd-p
|
|
79
|
+
<bd-p variant="large" color="on-brand" class="bd-spotlightsection-description">
|
|
80
80
|
<slot name="description">${this.description}</slot>
|
|
81
81
|
</bd-p>
|
|
82
82
|
`
|
|
@@ -35,7 +35,7 @@ export class StatHighlight extends LitElement {
|
|
|
35
35
|
|
|
36
36
|
firstUpdated() {
|
|
37
37
|
const still = window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;
|
|
38
|
-
if (still
|
|
38
|
+
if (still) {
|
|
39
39
|
this._rolled = true;
|
|
40
40
|
return;
|
|
41
41
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { css, unsafeCSS } from "lit";
|
|
2
2
|
import { above } from "../shared/token-scales.js";
|
|
3
|
+
import { hostFillsWidth } from "../shared/fill-width.css.js";
|
|
3
4
|
|
|
4
5
|
/* A tile on surface/info: the value at display-md, the caption at body-small,
|
|
5
6
|
pinned to the foot. On the info tint the value's text-primary measures
|
|
@@ -75,10 +76,18 @@ export const statTileCSS = css`
|
|
|
75
76
|
Each digit is a reel of 0-9 in a one-line window, moved up by its own
|
|
76
77
|
value. */
|
|
77
78
|
export const statHighlightCSS = css`
|
|
79
|
+
/* The figure is held to the width it is given, so the host is a size
|
|
80
|
+
container and takes its column's whole width: its content gives it none,
|
|
81
|
+
and in a flex column that aligns its items to the start it would measure
|
|
82
|
+
0 and hold the figure at its floor. The width is the column less the
|
|
83
|
+
host's margins (shared/fill-width.css.js). */
|
|
78
84
|
:host {
|
|
79
85
|
display: block;
|
|
86
|
+
container-type: inline-size;
|
|
80
87
|
}
|
|
81
88
|
|
|
89
|
+
${hostFillsWidth()}
|
|
90
|
+
|
|
82
91
|
.highlight {
|
|
83
92
|
margin: 0;
|
|
84
93
|
text-align: start;
|
|
@@ -89,9 +98,15 @@ export const statHighlightCSS = css`
|
|
|
89
98
|
Regular is the nearest it does */
|
|
90
99
|
font-weight: var(--typography-fontWeight-normal);
|
|
91
100
|
letter-spacing: var(--typography-display-3xl-letterSpacing);
|
|
92
|
-
/* no token: the one-off
|
|
93
|
-
|
|
94
|
-
|
|
101
|
+
/* no token: the one-off figure the design sets; the display scale stops
|
|
102
|
+
at 128. The frames scale it with the page, not with its own column --
|
|
103
|
+
80 on a phone, about 107 in the tablet frame's 656 column, 180 in the
|
|
104
|
+
desktop frame's 588 half-column -- so the viewport stays the measure.
|
|
105
|
+
The column is the cap: never more of it than the desktop frame takes,
|
|
106
|
+
180 of 588. Uncapped, the story's $1.5B+ ran past its half of the page
|
|
107
|
+
column at 1060-1199 and 1283-1399, where the half holds at 428 and
|
|
108
|
+
518 while the viewport keeps growing. */
|
|
109
|
+
font-size: clamp(5rem, min(12.5vw, 100cqi * 180 / 588), 11.25rem);
|
|
95
110
|
/* no token: a reel of digits needs a line box exactly one digit tall, so
|
|
96
111
|
the window and the steps the reel moves by are the same length */
|
|
97
112
|
line-height: 1;
|