@f-ewald/components 1.32.0 → 1.32.1
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/custom-elements.json +1 -1
- package/dist/radio-cards.d.ts +13 -9
- package/dist/radio-cards.d.ts.map +1 -1
- package/dist/radio-cards.js +22 -10
- package/dist/radio-cards.js.map +1 -1
- package/docs/radio-cards.md +17 -9
- package/llms.txt +14 -10
- package/package.json +1 -1
package/custom-elements.json
CHANGED
|
@@ -15978,7 +15978,7 @@
|
|
|
15978
15978
|
"declarations": [
|
|
15979
15979
|
{
|
|
15980
15980
|
"kind": "class",
|
|
15981
|
-
"description": "Single-select group of full-width cards, each with a label and optional\ndescription — for a handful of meaningfully different choices where the\ndescription matters. For many short, same-shaped options (a color swatch,\na basemap style), use `radio-pills` instead. Wraps native radio inputs for\nkeyboard/a11y and fires `change` rather than relying on form submission.\n\
|
|
15981
|
+
"description": "Single-select group of full-width cards, each with a label and optional\ndescription — for a handful of meaningfully different choices where the\ndescription matters. For many short, same-shaped options (a color swatch,\na basemap style), use `radio-pills` instead. Wraps native radio inputs for\nkeyboard/a11y and fires `change` rather than relying on form submission.\n\nAn unchecked card is treated as `ui-button`'s secondary variant: it reads\nthe same `--ui-button-secondary-background`/`-hover` and\n`-border`/`-hover` tokens, so a gradient theme applies to a card exactly\nlike it does to any button. The selected card's border/radio dot instead\nread `--ui-button-accent` (a solid stand-in, since `border-color`/\n`accent-color` can't render a gradient), and its background reads the\nshared `--ui-button-secondary-surface-muted` plus `--ui-button-highlight`,\nso a gradient theme tints it consistently with `button-group`/\n`pagination-nav`'s equivalents. That shared value is tuned for small\ncontrols, so a card — with far more area — blends it 45% toward\n`--ui-surface` rather than taking a second token: the tint stays the same\nhue and gradient, just lighter on light themes (and correspondingly\ndeeper on dark ones) than on a button.\n\n`layout` controls how cards flow (\"mixed\" wraps with per-option\n`fullWidth` rows, \"vertical\" stacks one per row, \"horizontal\" stays\nside-by-side at every width). `hideInput` visually hides the radio dot via\nthe same `sr-only` clip pattern as `ui-checkbox` — the native input stays\nin the DOM for keyboard/a11y, and the card's own border/tint carries the\nselected state instead.",
|
|
15982
15982
|
"name": "RadioCards",
|
|
15983
15983
|
"members": [
|
|
15984
15984
|
{
|
package/dist/radio-cards.d.ts
CHANGED
|
@@ -13,15 +13,19 @@ export interface RadioCardOption {
|
|
|
13
13
|
* a basemap style), use `radio-pills` instead. Wraps native radio inputs for
|
|
14
14
|
* keyboard/a11y and fires `change` rather than relying on form submission.
|
|
15
15
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
16
|
+
* An unchecked card is treated as `ui-button`'s secondary variant: it reads
|
|
17
|
+
* the same `--ui-button-secondary-background`/`-hover` and
|
|
18
|
+
* `-border`/`-hover` tokens, so a gradient theme applies to a card exactly
|
|
19
|
+
* like it does to any button. The selected card's border/radio dot instead
|
|
20
|
+
* read `--ui-button-accent` (a solid stand-in, since `border-color`/
|
|
21
|
+
* `accent-color` can't render a gradient), and its background reads the
|
|
22
|
+
* shared `--ui-button-secondary-surface-muted` plus `--ui-button-highlight`,
|
|
23
|
+
* so a gradient theme tints it consistently with `button-group`/
|
|
24
|
+
* `pagination-nav`'s equivalents. That shared value is tuned for small
|
|
25
|
+
* controls, so a card — with far more area — blends it 45% toward
|
|
26
|
+
* `--ui-surface` rather than taking a second token: the tint stays the same
|
|
27
|
+
* hue and gradient, just lighter on light themes (and correspondingly
|
|
28
|
+
* deeper on dark ones) than on a button.
|
|
25
29
|
*
|
|
26
30
|
* `layout` controls how cards flow ("mixed" wraps with per-option
|
|
27
31
|
* `fullWidth` rows, "vertical" stacks one per row, "horizontal" stays
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"radio-cards.d.ts","sourceRoot":"","sources":["../src/radio-cards.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAsB,MAAM,KAAK,CAAC;AAMrD,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,yEAAyE;IACzE,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAID
|
|
1
|
+
{"version":3,"file":"radio-cards.d.ts","sourceRoot":"","sources":["../src/radio-cards.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAsB,MAAM,KAAK,CAAC;AAMrD,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,yEAAyE;IACzE,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAID;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,qBACa,UAAW,SAAQ,UAAU;;IACxC,OAAgB,MAAM,4BA4IpB;IAEF,wCAAwC;IACR,OAAO,EAAE,eAAe,EAAE,CAAM;IAChE,gCAAgC;IACpB,KAAK,SAAM;IACvB,gDAAgD;IACnB,QAAQ,UAAS;IAC9C;;;;;;OAMG;IACS,MAAM,EAAE,UAAU,GAAG,YAAY,GAAG,OAAO,CAAW;IAClE,2FAA2F;IACrC,SAAS,UAAS;IAIxE,OAAO,CAAC,SAAS;IAMR,MAAM,yCAyBd;CACF;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,aAAa,EAAE,UAAU,CAAC;KAC3B;CACF"}
|
package/dist/radio-cards.js
CHANGED
|
@@ -17,15 +17,19 @@ let instanceCount = 0;
|
|
|
17
17
|
* a basemap style), use `radio-pills` instead. Wraps native radio inputs for
|
|
18
18
|
* keyboard/a11y and fires `change` rather than relying on form submission.
|
|
19
19
|
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
20
|
+
* An unchecked card is treated as `ui-button`'s secondary variant: it reads
|
|
21
|
+
* the same `--ui-button-secondary-background`/`-hover` and
|
|
22
|
+
* `-border`/`-hover` tokens, so a gradient theme applies to a card exactly
|
|
23
|
+
* like it does to any button. The selected card's border/radio dot instead
|
|
24
|
+
* read `--ui-button-accent` (a solid stand-in, since `border-color`/
|
|
25
|
+
* `accent-color` can't render a gradient), and its background reads the
|
|
26
|
+
* shared `--ui-button-secondary-surface-muted` plus `--ui-button-highlight`,
|
|
27
|
+
* so a gradient theme tints it consistently with `button-group`/
|
|
28
|
+
* `pagination-nav`'s equivalents. That shared value is tuned for small
|
|
29
|
+
* controls, so a card — with far more area — blends it 45% toward
|
|
30
|
+
* `--ui-surface` rather than taking a second token: the tint stays the same
|
|
31
|
+
* hue and gradient, just lighter on light themes (and correspondingly
|
|
32
|
+
* deeper on dark ones) than on a button.
|
|
29
33
|
*
|
|
30
34
|
* `layout` controls how cards flow ("mixed" wraps with per-option
|
|
31
35
|
* `fullWidth` rows, "vertical" stacks one per row, "horizontal" stays
|
|
@@ -95,7 +99,8 @@ let RadioCards = class RadioCards extends LitElement {
|
|
|
95
99
|
align-items: flex-start;
|
|
96
100
|
gap: 0.5rem;
|
|
97
101
|
box-sizing: border-box;
|
|
98
|
-
|
|
102
|
+
background: var(--ui-button-secondary-background, none);
|
|
103
|
+
border: 1px solid var(--ui-button-secondary-border, var(--ui-border, #e2e8f0));
|
|
99
104
|
border-radius: var(--ui-radius-sm, 0.25rem);
|
|
100
105
|
padding: 0.5rem 0.75rem;
|
|
101
106
|
cursor: pointer;
|
|
@@ -111,6 +116,13 @@ let RadioCards = class RadioCards extends LitElement {
|
|
|
111
116
|
);
|
|
112
117
|
font-size: var(--ui-font-size-sm, 0.75rem);
|
|
113
118
|
}
|
|
119
|
+
/* Unchecked cards are treated as ui-button's secondary variant (same
|
|
120
|
+
resting/hover gradient tokens), so a gradient theme applies here the
|
|
121
|
+
same way it does to every button — a card is not a special case. */
|
|
122
|
+
.card:hover:not(:has(input:disabled)):not(:has(input:checked)) {
|
|
123
|
+
background: var(--ui-button-secondary-background-hover, none);
|
|
124
|
+
border-color: var(--ui-button-secondary-border-hover, var(--ui-text-muted, #64748b));
|
|
125
|
+
}
|
|
114
126
|
/* Same single muted-surface variable as button-group/pagination-nav,
|
|
115
127
|
but blended toward the card's own surface: that value is tuned for a
|
|
116
128
|
small control, and across a card's much larger area it reads too
|
package/dist/radio-cards.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"radio-cards.js","sourceRoot":"","sources":["../src/radio-cards.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAUrC,IAAI,aAAa,GAAG,CAAC,CAAC;AAEtB;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEI,IAAM,UAAU,GAAhB,MAAM,UAAW,SAAQ,UAAU;IAAnC;;QAuIL,wCAAwC;QACR,YAAO,GAAsB,EAAE,CAAC;QAChE,gCAAgC;QACpB,UAAK,GAAG,EAAE,CAAC;QACvB,gDAAgD;QACnB,aAAQ,GAAG,KAAK,CAAC;QAC9C;;;;;;WAMG;QACS,WAAM,GAAwC,OAAO,CAAC;QAClE,2FAA2F;QACrC,cAAS,GAAG,KAAK,CAAC;QAE/D,UAAK,GAAG,eAAe,EAAE,aAAa,EAAE,CAAC;IAkCpD,CAAC;aAzLiB,WAAM,GAAG;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AAC,CAAC,OAAO;;;WAGjG,CACF;;KAEJ,CAAC;IACJ,CAAC;CACF,CAAA;AAlDiC;IAA/B,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;2CAAiC;AAEpD;IAAX,QAAQ,EAAE;yCAAY;AAEM;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;4CAAkB;AAQlC;IAAX,QAAQ,EAAE;0CAAuD;AAEZ;IAArD,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC;6CAAmB;AAtJ7D,UAAU;IADtB,aAAa,CAAC,aAAa,CAAC;GAChB,UAAU,CA0LtB","sourcesContent":["import { LitElement, css, html, nothing } from \"lit\";\nimport { customElement, property } from \"lit/decorators.js\";\nimport { classMap } from \"lit/directives/class-map.js\";\nimport { repeat } from \"lit/directives/repeat.js\";\nimport { tokens } from \"./tokens.js\";\n\nexport interface RadioCardOption {\n value: string;\n label: string;\n description?: string;\n /** In `layout=\"mixed\"`, forces this card onto its own full-width row. */\n fullWidth?: boolean;\n}\n\nlet instanceCount = 0;\n\n/**\n * Single-select group of full-width cards, each with a label and optional\n * description — for a handful of meaningfully different choices where the\n * description matters. For many short, same-shaped options (a color swatch,\n * a basemap style), use `radio-pills` instead. Wraps native radio inputs for\n * keyboard/a11y and fires `change` rather than relying on form submission.\n *\n * The selected card's border/radio dot read `--ui-button-accent` (a solid\n * stand-in, since `border-color`/`accent-color` can't render a gradient),\n * and its background reads the shared `--ui-button-secondary-surface-muted`\n * plus `--ui-button-highlight`, so a gradient theme tints it consistently\n * with `button-group`/`pagination-nav`'s equivalents. That shared value is\n * tuned for small controls, so a card — with far more area — blends it 45%\n * toward `--ui-surface` rather than taking a second token: the tint stays\n * the same hue and gradient, just lighter on light themes (and\n * correspondingly deeper on dark ones) than on a button.\n *\n * `layout` controls how cards flow (\"mixed\" wraps with per-option\n * `fullWidth` rows, \"vertical\" stacks one per row, \"horizontal\" stays\n * side-by-side at every width). `hideInput` visually hides the radio dot via\n * the same `sr-only` clip pattern as `ui-checkbox` — the native input stays\n * in the DOM for keyboard/a11y, and the card's own border/tint carries the\n * selected state instead.\n *\n * @element radio-cards\n * @fires change - A card was selected; detail: { value }.\n */\n@customElement(\"radio-cards\")\nexport class RadioCards extends LitElement {\n static override styles = [\n tokens,\n css`\n :host {\n display: block;\n }\n .options {\n display: flex;\n gap: 0.5rem;\n }\n .options.mixed {\n flex-wrap: wrap;\n }\n .options.mixed .card {\n flex: 1 1 11.25rem;\n }\n .options.mixed .card.full {\n flex: 1 0 100%;\n }\n .options.vertical {\n flex-direction: column;\n }\n .options.vertical .card {\n flex: 0 0 auto;\n }\n .options.horizontal {\n flex-wrap: nowrap;\n }\n .options.horizontal .card {\n flex: 1 1 0;\n min-width: 0;\n }\n .card {\n display: flex;\n align-items: flex-start;\n gap: 0.5rem;\n box-sizing: border-box;\n border: 1px solid var(--ui-border, #e2e8f0);\n border-radius: var(--ui-radius-sm, 0.25rem);\n padding: 0.5rem 0.75rem;\n cursor: pointer;\n font-family: var(\n --ui-font,\n ui-sans-serif,\n system-ui,\n sans-serif,\n \"Apple Color Emoji\",\n \"Segoe UI Emoji\",\n \"Segoe UI Symbol\",\n \"Noto Color Emoji\"\n );\n font-size: var(--ui-font-size-sm, 0.75rem);\n }\n /* Same single muted-surface variable as button-group/pagination-nav,\n but blended toward the card's own surface: that value is tuned for a\n small control, and across a card's much larger area it reads too\n heavy. Mixing with --ui-surface (rather than plain white) keeps the\n adjustment theme-correct — it lightens on light themes and deepens\n on dark ones. Written with the background shorthand (not\n background-image) so it stays valid whether the variable resolves to\n a gradient or a flat color. */\n .card:has(input:checked) {\n border-color: var(--ui-button-accent, var(--ui-primary, #4f46e5));\n background:\n linear-gradient(\n color-mix(in srgb, var(--ui-surface, #ffffff) 45%, transparent),\n color-mix(in srgb, var(--ui-surface, #ffffff) 45%, transparent)\n ),\n var(--ui-button-secondary-surface-muted, var(--ui-surface-muted, #f8fafc));\n box-shadow: var(--ui-button-highlight, 0 0 0 0 transparent);\n }\n .card input {\n width: 1rem;\n height: 1rem;\n margin-top: 0.25rem;\n accent-color: var(--ui-button-accent, var(--ui-primary, #4f46e5));\n cursor: pointer;\n }\n .card-label {\n font-weight: var(--ui-font-weight-semibold, 600);\n color: var(--ui-text, #0f172a);\n }\n .card-description {\n display: block;\n color: var(--ui-text-muted, #64748b);\n font-weight: var(--ui-font-weight-regular, 400);\n }\n .card:has(input:focus-visible) {\n outline: none;\n box-shadow: var(--ui-focus-ring, 0 0 0 3px rgb(79 70 229 / 0.35));\n }\n .card:has(input:checked):has(input:focus-visible) {\n box-shadow: var(--ui-focus-ring, 0 0 0 3px rgb(79 70 229 / 0.35)), var(--ui-button-highlight, 0 0 0 0 transparent);\n }\n .card:has(input:disabled) {\n cursor: not-allowed;\n opacity: 0.6;\n }\n .card:has(input:disabled) input {\n cursor: not-allowed;\n }\n .card input.sr-only {\n position: absolute;\n width: 1px;\n height: 1px;\n margin: -1px;\n padding: 0;\n overflow: hidden;\n clip: rect(0 0 0 0);\n clip-path: inset(50%);\n white-space: nowrap;\n border: 0;\n }\n @media (forced-colors: active) {\n .card:has(input:focus-visible) {\n outline: 2px solid CanvasText;\n outline-offset: 2px;\n box-shadow: none;\n }\n .card:has(input:checked) {\n border-color: Highlight;\n }\n .card:has(input:disabled) {\n color: GrayText;\n opacity: 1;\n }\n .card:has(input:disabled) .card-label,\n .card:has(input:disabled) .card-description {\n color: GrayText;\n }\n }\n `,\n ];\n\n /** Options to render, one card each. */\n @property({ attribute: false }) options: RadioCardOption[] = [];\n /** Currently selected value. */\n @property() value = \"\";\n /** Disables every native radio in the group. */\n @property({ type: Boolean }) disabled = false;\n /**\n * How the cards flow.\n * - \"mixed\" (default): cards wrap onto as many rows as fit; options marked\n * `fullWidth` take a row of their own.\n * - \"vertical\": one full-width card per row, never side by side.\n * - \"horizontal\": every card on one row, equal widths, no wrapping.\n */\n @property() layout: \"vertical\" | \"horizontal\" | \"mixed\" = \"mixed\";\n /** Visually hides the radio dot; the card's own border/tint carries the selected state. */\n @property({ type: Boolean, attribute: \"hide-input\" }) hideInput = false;\n\n readonly #name = `radio-cards-${++instanceCount}`;\n\n private _onChange(value: string) {\n if (this.disabled) return;\n this.value = value;\n this.dispatchEvent(new CustomEvent(\"change\", { detail: { value }, bubbles: true, composed: true }));\n }\n\n override render() {\n return html`\n <div class=\"options ${this.layout}\">\n ${repeat(\n this.options,\n (opt) => opt.value,\n (opt) => html`\n <label class=${classMap({ card: true, full: this.layout === \"mixed\" && !!opt.fullWidth })}>\n <input\n type=\"radio\"\n class=${classMap({ \"sr-only\": this.hideInput })}\n name=${this.#name}\n .checked=${this.value === opt.value}\n ?disabled=${this.disabled}\n @change=${() => this._onChange(opt.value)}\n />\n <span>\n <span class=\"card-label\">${opt.label}</span>\n ${opt.description ? html`<span class=\"card-description\">${opt.description}</span>` : nothing}\n </span>\n </label>\n `,\n )}\n </div>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"radio-cards\": RadioCards;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"radio-cards.js","sourceRoot":"","sources":["../src/radio-cards.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAUrC,IAAI,aAAa,GAAG,CAAC,CAAC;AAEtB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEI,IAAM,UAAU,GAAhB,MAAM,UAAW,SAAQ,UAAU;IAAnC;;QA+IL,wCAA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SAAS,EAAE,CAAC;uBACxC,IAAI,CAAC,KAAK;2BACN,IAAI,CAAC,KAAK,KAAK,GAAG,CAAC,KAAK;4BACvB,IAAI,CAAC,QAAQ;0BACf,GAAG,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC;;;2CAGd,GAAG,CAAC,KAAK;kBAClC,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAA,kCAAkC,GAAG,CAAC,WAAW,SAAS,CAAC,CAAC,CAAC,OAAO;;;WAGjG,CACF;;KAEJ,CAAC;IACJ,CAAC;CACF,CAAA;AAlDiC;IAA/B,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;2CAAiC;AAEpD;IAAX,QAAQ,EAAE;yCAAY;AAEM;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;4CAAkB;AAQlC;IAAX,QAAQ,EAAE;0CAAuD;AAEZ;IAArD,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC;6CAAmB;AA9J7D,UAAU;IADtB,aAAa,CAAC,aAAa,CAAC;GAChB,UAAU,CAkMtB","sourcesContent":["import { LitElement, css, html, nothing } from \"lit\";\nimport { customElement, property } from \"lit/decorators.js\";\nimport { classMap } from \"lit/directives/class-map.js\";\nimport { repeat } from \"lit/directives/repeat.js\";\nimport { tokens } from \"./tokens.js\";\n\nexport interface RadioCardOption {\n value: string;\n label: string;\n description?: string;\n /** In `layout=\"mixed\"`, forces this card onto its own full-width row. */\n fullWidth?: boolean;\n}\n\nlet instanceCount = 0;\n\n/**\n * Single-select group of full-width cards, each with a label and optional\n * description — for a handful of meaningfully different choices where the\n * description matters. For many short, same-shaped options (a color swatch,\n * a basemap style), use `radio-pills` instead. Wraps native radio inputs for\n * keyboard/a11y and fires `change` rather than relying on form submission.\n *\n * An unchecked card is treated as `ui-button`'s secondary variant: it reads\n * the same `--ui-button-secondary-background`/`-hover` and\n * `-border`/`-hover` tokens, so a gradient theme applies to a card exactly\n * like it does to any button. The selected card's border/radio dot instead\n * read `--ui-button-accent` (a solid stand-in, since `border-color`/\n * `accent-color` can't render a gradient), and its background reads the\n * shared `--ui-button-secondary-surface-muted` plus `--ui-button-highlight`,\n * so a gradient theme tints it consistently with `button-group`/\n * `pagination-nav`'s equivalents. That shared value is tuned for small\n * controls, so a card — with far more area — blends it 45% toward\n * `--ui-surface` rather than taking a second token: the tint stays the same\n * hue and gradient, just lighter on light themes (and correspondingly\n * deeper on dark ones) than on a button.\n *\n * `layout` controls how cards flow (\"mixed\" wraps with per-option\n * `fullWidth` rows, \"vertical\" stacks one per row, \"horizontal\" stays\n * side-by-side at every width). `hideInput` visually hides the radio dot via\n * the same `sr-only` clip pattern as `ui-checkbox` — the native input stays\n * in the DOM for keyboard/a11y, and the card's own border/tint carries the\n * selected state instead.\n *\n * @element radio-cards\n * @fires change - A card was selected; detail: { value }.\n */\n@customElement(\"radio-cards\")\nexport class RadioCards extends LitElement {\n static override styles = [\n tokens,\n css`\n :host {\n display: block;\n }\n .options {\n display: flex;\n gap: 0.5rem;\n }\n .options.mixed {\n flex-wrap: wrap;\n }\n .options.mixed .card {\n flex: 1 1 11.25rem;\n }\n .options.mixed .card.full {\n flex: 1 0 100%;\n }\n .options.vertical {\n flex-direction: column;\n }\n .options.vertical .card {\n flex: 0 0 auto;\n }\n .options.horizontal {\n flex-wrap: nowrap;\n }\n .options.horizontal .card {\n flex: 1 1 0;\n min-width: 0;\n }\n .card {\n display: flex;\n align-items: flex-start;\n gap: 0.5rem;\n box-sizing: border-box;\n background: var(--ui-button-secondary-background, none);\n border: 1px solid var(--ui-button-secondary-border, var(--ui-border, #e2e8f0));\n border-radius: var(--ui-radius-sm, 0.25rem);\n padding: 0.5rem 0.75rem;\n cursor: pointer;\n font-family: var(\n --ui-font,\n ui-sans-serif,\n system-ui,\n sans-serif,\n \"Apple Color Emoji\",\n \"Segoe UI Emoji\",\n \"Segoe UI Symbol\",\n \"Noto Color Emoji\"\n );\n font-size: var(--ui-font-size-sm, 0.75rem);\n }\n /* Unchecked cards are treated as ui-button's secondary variant (same\n resting/hover gradient tokens), so a gradient theme applies here the\n same way it does to every button — a card is not a special case. */\n .card:hover:not(:has(input:disabled)):not(:has(input:checked)) {\n background: var(--ui-button-secondary-background-hover, none);\n border-color: var(--ui-button-secondary-border-hover, var(--ui-text-muted, #64748b));\n }\n /* Same single muted-surface variable as button-group/pagination-nav,\n but blended toward the card's own surface: that value is tuned for a\n small control, and across a card's much larger area it reads too\n heavy. Mixing with --ui-surface (rather than plain white) keeps the\n adjustment theme-correct — it lightens on light themes and deepens\n on dark ones. Written with the background shorthand (not\n background-image) so it stays valid whether the variable resolves to\n a gradient or a flat color. */\n .card:has(input:checked) {\n border-color: var(--ui-button-accent, var(--ui-primary, #4f46e5));\n background:\n linear-gradient(\n color-mix(in srgb, var(--ui-surface, #ffffff) 45%, transparent),\n color-mix(in srgb, var(--ui-surface, #ffffff) 45%, transparent)\n ),\n var(--ui-button-secondary-surface-muted, var(--ui-surface-muted, #f8fafc));\n box-shadow: var(--ui-button-highlight, 0 0 0 0 transparent);\n }\n .card input {\n width: 1rem;\n height: 1rem;\n margin-top: 0.25rem;\n accent-color: var(--ui-button-accent, var(--ui-primary, #4f46e5));\n cursor: pointer;\n }\n .card-label {\n font-weight: var(--ui-font-weight-semibold, 600);\n color: var(--ui-text, #0f172a);\n }\n .card-description {\n display: block;\n color: var(--ui-text-muted, #64748b);\n font-weight: var(--ui-font-weight-regular, 400);\n }\n .card:has(input:focus-visible) {\n outline: none;\n box-shadow: var(--ui-focus-ring, 0 0 0 3px rgb(79 70 229 / 0.35));\n }\n .card:has(input:checked):has(input:focus-visible) {\n box-shadow: var(--ui-focus-ring, 0 0 0 3px rgb(79 70 229 / 0.35)), var(--ui-button-highlight, 0 0 0 0 transparent);\n }\n .card:has(input:disabled) {\n cursor: not-allowed;\n opacity: 0.6;\n }\n .card:has(input:disabled) input {\n cursor: not-allowed;\n }\n .card input.sr-only {\n position: absolute;\n width: 1px;\n height: 1px;\n margin: -1px;\n padding: 0;\n overflow: hidden;\n clip: rect(0 0 0 0);\n clip-path: inset(50%);\n white-space: nowrap;\n border: 0;\n }\n @media (forced-colors: active) {\n .card:has(input:focus-visible) {\n outline: 2px solid CanvasText;\n outline-offset: 2px;\n box-shadow: none;\n }\n .card:has(input:checked) {\n border-color: Highlight;\n }\n .card:has(input:disabled) {\n color: GrayText;\n opacity: 1;\n }\n .card:has(input:disabled) .card-label,\n .card:has(input:disabled) .card-description {\n color: GrayText;\n }\n }\n `,\n ];\n\n /** Options to render, one card each. */\n @property({ attribute: false }) options: RadioCardOption[] = [];\n /** Currently selected value. */\n @property() value = \"\";\n /** Disables every native radio in the group. */\n @property({ type: Boolean }) disabled = false;\n /**\n * How the cards flow.\n * - \"mixed\" (default): cards wrap onto as many rows as fit; options marked\n * `fullWidth` take a row of their own.\n * - \"vertical\": one full-width card per row, never side by side.\n * - \"horizontal\": every card on one row, equal widths, no wrapping.\n */\n @property() layout: \"vertical\" | \"horizontal\" | \"mixed\" = \"mixed\";\n /** Visually hides the radio dot; the card's own border/tint carries the selected state. */\n @property({ type: Boolean, attribute: \"hide-input\" }) hideInput = false;\n\n readonly #name = `radio-cards-${++instanceCount}`;\n\n private _onChange(value: string) {\n if (this.disabled) return;\n this.value = value;\n this.dispatchEvent(new CustomEvent(\"change\", { detail: { value }, bubbles: true, composed: true }));\n }\n\n override render() {\n return html`\n <div class=\"options ${this.layout}\">\n ${repeat(\n this.options,\n (opt) => opt.value,\n (opt) => html`\n <label class=${classMap({ card: true, full: this.layout === \"mixed\" && !!opt.fullWidth })}>\n <input\n type=\"radio\"\n class=${classMap({ \"sr-only\": this.hideInput })}\n name=${this.#name}\n .checked=${this.value === opt.value}\n ?disabled=${this.disabled}\n @change=${() => this._onChange(opt.value)}\n />\n <span>\n <span class=\"card-label\">${opt.label}</span>\n ${opt.description ? html`<span class=\"card-description\">${opt.description}</span>` : nothing}\n </span>\n </label>\n `,\n )}\n </div>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"radio-cards\": RadioCards;\n }\n}\n"]}
|
package/docs/radio-cards.md
CHANGED
|
@@ -6,15 +6,19 @@ description matters. For many short, same-shaped options (a color swatch,
|
|
|
6
6
|
a basemap style), use `radio-pills` instead. Wraps native radio inputs for
|
|
7
7
|
keyboard/a11y and fires `change` rather than relying on form submission.
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
9
|
+
An unchecked card is treated as `ui-button`'s secondary variant: it reads
|
|
10
|
+
the same `--ui-button-secondary-background`/`-hover` and
|
|
11
|
+
`-border`/`-hover` tokens, so a gradient theme applies to a card exactly
|
|
12
|
+
like it does to any button. The selected card's border/radio dot instead
|
|
13
|
+
read `--ui-button-accent` (a solid stand-in, since `border-color`/
|
|
14
|
+
`accent-color` can't render a gradient), and its background reads the
|
|
15
|
+
shared `--ui-button-secondary-surface-muted` plus `--ui-button-highlight`,
|
|
16
|
+
so a gradient theme tints it consistently with `button-group`/
|
|
17
|
+
`pagination-nav`'s equivalents. That shared value is tuned for small
|
|
18
|
+
controls, so a card — with far more area — blends it 45% toward
|
|
19
|
+
`--ui-surface` rather than taking a second token: the tint stays the same
|
|
20
|
+
hue and gradient, just lighter on light themes (and correspondingly
|
|
21
|
+
deeper on dark ones) than on a button.
|
|
18
22
|
|
|
19
23
|
`layout` controls how cards flow ("mixed" wraps with per-option
|
|
20
24
|
`fullWidth` rows, "vertical" stacks one per row, "horizontal" stays
|
|
@@ -71,6 +75,10 @@ _None._
|
|
|
71
75
|
| `--ui-border` |
|
|
72
76
|
| `--ui-button-accent` |
|
|
73
77
|
| `--ui-button-highlight` |
|
|
78
|
+
| `--ui-button-secondary-background` |
|
|
79
|
+
| `--ui-button-secondary-background-hover` |
|
|
80
|
+
| `--ui-button-secondary-border` |
|
|
81
|
+
| `--ui-button-secondary-border-hover` |
|
|
74
82
|
| `--ui-button-secondary-surface-muted` |
|
|
75
83
|
| `--ui-focus-ring` |
|
|
76
84
|
| `--ui-font` |
|
package/llms.txt
CHANGED
|
@@ -1828,15 +1828,19 @@ description matters. For many short, same-shaped options (a color swatch,
|
|
|
1828
1828
|
a basemap style), use `radio-pills` instead. Wraps native radio inputs for
|
|
1829
1829
|
keyboard/a11y and fires `change` rather than relying on form submission.
|
|
1830
1830
|
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1831
|
+
An unchecked card is treated as `ui-button`'s secondary variant: it reads
|
|
1832
|
+
the same `--ui-button-secondary-background`/`-hover` and
|
|
1833
|
+
`-border`/`-hover` tokens, so a gradient theme applies to a card exactly
|
|
1834
|
+
like it does to any button. The selected card's border/radio dot instead
|
|
1835
|
+
read `--ui-button-accent` (a solid stand-in, since `border-color`/
|
|
1836
|
+
`accent-color` can't render a gradient), and its background reads the
|
|
1837
|
+
shared `--ui-button-secondary-surface-muted` plus `--ui-button-highlight`,
|
|
1838
|
+
so a gradient theme tints it consistently with `button-group`/
|
|
1839
|
+
`pagination-nav`'s equivalents. That shared value is tuned for small
|
|
1840
|
+
controls, so a card — with far more area — blends it 45% toward
|
|
1841
|
+
`--ui-surface` rather than taking a second token: the tint stays the same
|
|
1842
|
+
hue and gradient, just lighter on light themes (and correspondingly
|
|
1843
|
+
deeper on dark ones) than on a button.
|
|
1840
1844
|
|
|
1841
1845
|
`layout` controls how cards flow ("mixed" wraps with per-option
|
|
1842
1846
|
`fullWidth` rows, "vertical" stacks one per row, "horizontal" stays
|
|
@@ -1849,7 +1853,7 @@ Import: `import "@f-ewald/components/radio-cards.js";`
|
|
|
1849
1853
|
|
|
1850
1854
|
Properties: `options` (JS property only) : RadioCardOption[], default []; `value` (attribute `value`) : string, default ""; `disabled` (attribute `disabled`) : boolean, default false; `layout` (attribute `layout`) : "vertical" | "horizontal" | "mixed", default "mixed"; `hideInput` (attribute `hide-input`) : boolean, default false
|
|
1851
1855
|
Events: `change`
|
|
1852
|
-
CSS custom properties: `--ui-border`, `--ui-button-accent`, `--ui-button-highlight`, `--ui-button-secondary-surface-muted`, `--ui-focus-ring`, `--ui-font`, `--ui-font-size-sm`, `--ui-font-weight-regular`, `--ui-font-weight-semibold`, `--ui-primary`, `--ui-radius-sm`, `--ui-surface`, `--ui-surface-muted`, `--ui-text`, `--ui-text-muted`
|
|
1856
|
+
CSS custom properties: `--ui-border`, `--ui-button-accent`, `--ui-button-highlight`, `--ui-button-secondary-background`, `--ui-button-secondary-background-hover`, `--ui-button-secondary-border`, `--ui-button-secondary-border-hover`, `--ui-button-secondary-surface-muted`, `--ui-focus-ring`, `--ui-font`, `--ui-font-size-sm`, `--ui-font-weight-regular`, `--ui-font-weight-semibold`, `--ui-primary`, `--ui-radius-sm`, `--ui-surface`, `--ui-surface-muted`, `--ui-text`, `--ui-text-muted`
|
|
1853
1857
|
|
|
1854
1858
|
Example:
|
|
1855
1859
|
```html
|