@getflip/swirl-components 0.88.0 → 0.89.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/components.json +77 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/swirl-checkbox.cjs.entry.js +4 -3
- package/dist/cjs/swirl-chip.cjs.entry.js +6 -4
- package/dist/cjs/swirl-components.cjs.js +1 -1
- package/dist/cjs/swirl-description-list-item.cjs.entry.js +2 -1
- package/dist/cjs/swirl-description-list.cjs.entry.js +1 -1
- package/dist/cjs/swirl-radio.cjs.entry.js +4 -3
- package/dist/collection/assets/pdfjs/pdf.worker.min.js +0 -22
- package/dist/collection/components/swirl-checkbox/swirl-checkbox.css +33 -0
- package/dist/collection/components/swirl-checkbox/swirl-checkbox.js +26 -2
- package/dist/collection/components/swirl-checkbox/swirl-checkbox.spec.js +1 -1
- package/dist/collection/components/swirl-chip/swirl-chip.css +34 -0
- package/dist/collection/components/swirl-chip/swirl-chip.js +22 -3
- package/dist/collection/components/swirl-chip/swirl-chip.spec.js +17 -0
- package/dist/collection/components/swirl-description-list/swirl-description-list.js +1 -1
- package/dist/collection/components/swirl-description-list/swirl-description-list.spec.js +2 -2
- package/dist/collection/components/swirl-description-list-item/swirl-description-list-item.js +19 -1
- package/dist/collection/components/swirl-description-list-item/swirl-description-list-item.spec.js +5 -5
- package/dist/collection/components/swirl-radio/swirl-radio.css +33 -0
- package/dist/collection/components/swirl-radio/swirl-radio.js +26 -2
- package/dist/collection/components/swirl-radio/swirl-radio.spec.js +1 -1
- package/dist/components/assets/pdfjs/pdf.worker.min.js +0 -22
- package/dist/components/swirl-checkbox.js +6 -4
- package/dist/components/swirl-chip.js +7 -4
- package/dist/components/swirl-description-list-item.js +3 -1
- package/dist/components/swirl-description-list.js +1 -1
- package/dist/components/swirl-radio.js +6 -4
- package/dist/esm/loader.js +1 -1
- package/dist/esm/swirl-checkbox.entry.js +4 -3
- package/dist/esm/swirl-chip.entry.js +6 -4
- package/dist/esm/swirl-components.js +1 -1
- package/dist/esm/swirl-description-list-item.entry.js +2 -1
- package/dist/esm/swirl-description-list.entry.js +1 -1
- package/dist/esm/swirl-radio.entry.js +4 -3
- package/dist/swirl-components/p-4dc91925.entry.js +1 -0
- package/dist/swirl-components/p-7c70d4b2.entry.js +1 -0
- package/dist/swirl-components/p-ae31163c.entry.js +1 -0
- package/dist/swirl-components/p-d82144bc.entry.js +1 -0
- package/dist/swirl-components/p-ea08c219.entry.js +1 -0
- package/dist/swirl-components/swirl-components.esm.js +1 -1
- package/dist/types/components/swirl-checkbox/swirl-checkbox.d.ts +2 -0
- package/dist/types/components/swirl-chip/swirl-chip.d.ts +1 -0
- package/dist/types/components/swirl-description-list-item/swirl-description-list-item.d.ts +1 -0
- package/dist/types/components/swirl-radio/swirl-radio.d.ts +2 -0
- package/dist/types/components.d.ts +12 -4
- package/package.json +13 -13
- package/vscode-data.json +32 -0
- package/dist/swirl-components/p-2c44a1cb.entry.js +0 -1
- package/dist/swirl-components/p-34dcadc5.entry.js +0 -1
- package/dist/swirl-components/p-62f1aaae.entry.js +0 -1
- package/dist/swirl-components/p-6cf1cf56.entry.js +0 -1
- package/dist/swirl-components/p-d6034b86.entry.js +0 -1
|
@@ -17,6 +17,39 @@
|
|
|
17
17
|
0 0 0 0.1875rem var(--s-focus-default);
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
+
.checkbox--variant-card {
|
|
21
|
+
width: 100%;
|
|
22
|
+
padding: var(--s-space-16);
|
|
23
|
+
border: 0.0625rem solid var(--s-border-default);
|
|
24
|
+
border-radius: var(--s-border-radius-sm);
|
|
25
|
+
background-color: var(--s-surface);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.checkbox--variant-card:focus-within {
|
|
29
|
+
box-shadow: 0 0 0 0.125rem var(--s-background-default),
|
|
30
|
+
0 0 0 0.25rem var(--s-focus-default);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.checkbox--variant-card:focus-within .checkbox__box {
|
|
34
|
+
box-shadow: none;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.checkbox--variant-card:hover:not(.checkbox--disabled) {
|
|
38
|
+
background-color: var(--s-surface-hovered);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.checkbox--variant-card:active:not(.checkbox--disabled) {
|
|
42
|
+
background-color: var(--s-surface-pressed);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.checkbox--variant-card.checkbox--checked:not(.checkbox--disabled) {
|
|
46
|
+
border-color: var(--s-border-highlight);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.checkbox--variant-card.checkbox--invalid:not(.checkbox--disabled) {
|
|
50
|
+
border-color: var(--s-border-critical);
|
|
51
|
+
}
|
|
52
|
+
|
|
20
53
|
.checkbox--checked .checkbox__control:hover .checkbox__box, .checkbox--indeterminate .checkbox__control:hover .checkbox__box {
|
|
21
54
|
border-color: var(--s-interactive-primary-hovered);
|
|
22
55
|
background-color: var(--s-interactive-primary-hovered);
|
|
@@ -18,6 +18,7 @@ export class SwirlCheckbox {
|
|
|
18
18
|
this.label = undefined;
|
|
19
19
|
this.labelWeight = "medium";
|
|
20
20
|
this.value = undefined;
|
|
21
|
+
this.variant = "default";
|
|
21
22
|
}
|
|
22
23
|
getAriaCheckedLabel(checked, unchecked) {
|
|
23
24
|
if (checked) {
|
|
@@ -37,14 +38,14 @@ export class SwirlCheckbox {
|
|
|
37
38
|
const ariaInvalid = this.invalid === true || this.invalid === false
|
|
38
39
|
? String(this.invalid)
|
|
39
40
|
: undefined;
|
|
40
|
-
const className = classnames("checkbox", `checkbox--label-weight-${this.labelWeight}`, {
|
|
41
|
+
const className = classnames("checkbox", `checkbox--label-weight-${this.labelWeight}`, `checkbox--variant-${this.variant}`, {
|
|
41
42
|
"checkbox--checked": checked,
|
|
42
43
|
"checkbox--disabled": this.disabled,
|
|
43
44
|
"checkbox--indeterminate": indeterminate,
|
|
44
45
|
"checkbox--invalid": this.invalid,
|
|
45
46
|
"checkbox--unchecked": unchecked,
|
|
46
47
|
});
|
|
47
|
-
return (h(Host,
|
|
48
|
+
return (h(Host, { style: { width: this.variant === "card" ? "100%" : undefined } }, h("label", { class: className, htmlFor: this.inputId }, h("span", { class: "checkbox__control" }, h("swirl-visually-hidden", null, h("input", { "aria-checked": ariaCheckedLabel, "aria-describedby": this.swirlAriaDescribedby, "aria-invalid": ariaInvalid, "aria-label": this.swirlAriaLabel, checked: checked, class: "checkbox__input", disabled: this.disabled, id: this.inputId, indeterminate: indeterminate, name: this.inputName, onChange: this.onChange, type: "checkbox", value: this.value })), h("span", { "aria-hidden": "true", class: "checkbox__box" }, h("span", { class: "checkbox__icon" }, checked && h("swirl-icon-check-strong", null), indeterminate && (h("span", { class: "checkbox__indeterminate-icon" }))))), showLabelContainer && (h("span", { class: "checkbox__label-container" }, this.label && h("span", { class: "checkbox__label" }, this.label), this.description && (h("span", { class: "checkbox__description" }, this.description)))))));
|
|
48
49
|
}
|
|
49
50
|
static get is() { return "swirl-checkbox"; }
|
|
50
51
|
static get encapsulation() { return "scoped"; }
|
|
@@ -259,6 +260,29 @@ export class SwirlCheckbox {
|
|
|
259
260
|
},
|
|
260
261
|
"attribute": "value",
|
|
261
262
|
"reflect": false
|
|
263
|
+
},
|
|
264
|
+
"variant": {
|
|
265
|
+
"type": "string",
|
|
266
|
+
"mutable": false,
|
|
267
|
+
"complexType": {
|
|
268
|
+
"original": "SwirlCheckboxVariant",
|
|
269
|
+
"resolved": "\"card\" | \"default\"",
|
|
270
|
+
"references": {
|
|
271
|
+
"SwirlCheckboxVariant": {
|
|
272
|
+
"location": "local",
|
|
273
|
+
"path": "/home/runner/work/swirl/swirl/packages/swirl-components/src/components/swirl-checkbox/swirl-checkbox.tsx"
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
},
|
|
277
|
+
"required": false,
|
|
278
|
+
"optional": true,
|
|
279
|
+
"docs": {
|
|
280
|
+
"tags": [],
|
|
281
|
+
"text": ""
|
|
282
|
+
},
|
|
283
|
+
"attribute": "variant",
|
|
284
|
+
"reflect": false,
|
|
285
|
+
"defaultValue": "\"default\""
|
|
262
286
|
}
|
|
263
287
|
};
|
|
264
288
|
}
|
|
@@ -8,7 +8,7 @@ describe("swirl-checkbox", () => {
|
|
|
8
8
|
});
|
|
9
9
|
expect(page.root).toMatchInlineSnapshot(`
|
|
10
10
|
<swirl-checkbox checked="true" description="Description" disabled="true" input-id="checkbox" input-name="checkbox" label="Label" value="Value">
|
|
11
|
-
<label class="checkbox checkbox--checked checkbox--disabled checkbox--label-weight-medium" htmlfor="checkbox">
|
|
11
|
+
<label class="checkbox checkbox--checked checkbox--disabled checkbox--label-weight-medium checkbox--variant-default" htmlfor="checkbox">
|
|
12
12
|
<span class="checkbox__control">
|
|
13
13
|
<swirl-visually-hidden>
|
|
14
14
|
<input aria-checked="true" checked="" class="checkbox__input" disabled="" id="checkbox" name="checkbox" type="checkbox" value="Value">
|
|
@@ -110,6 +110,40 @@
|
|
|
110
110
|
color: var(--s-icon-success);
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
+
.chip--variant-outline.chip--pressed {
|
|
114
|
+
background-color: var(--s-action-primary-default);
|
|
115
|
+
color: var(--s-text-on-action-primary);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
.chip--variant-outline.chip--pressed:hover {
|
|
119
|
+
background-color: var(--s-action-primary-hovered);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.chip--variant-outline.chip--pressed:hover + .chip__remove-button {
|
|
123
|
+
background-color: var(--s-action-primary-hovered);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
.chip--variant-outline.chip--pressed:active {
|
|
127
|
+
background-color: var(--s-action-primary-pressed);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
.chip--variant-outline.chip--pressed:active + .chip__remove-button {
|
|
131
|
+
background-color: var(--s-action-primary-pressed);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
.chip--variant-outline.chip--pressed + .chip__remove-button {
|
|
135
|
+
background-color: var(--s-action-primary-default);
|
|
136
|
+
color: var(--s-text-on-action-primary);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
.chip--variant-outline.chip--pressed + .chip__remove-button:hover {
|
|
140
|
+
background-color: var(--s-action-primary-hovered);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
.chip--variant-outline.chip--pressed + .chip__remove-button:active {
|
|
144
|
+
background-color: var(--s-action-primary-pressed);
|
|
145
|
+
}
|
|
146
|
+
|
|
113
147
|
.chip--variant-plain {
|
|
114
148
|
height: auto;
|
|
115
149
|
border: none;
|
|
@@ -17,6 +17,7 @@ export class SwirlChip {
|
|
|
17
17
|
this.interactive = false;
|
|
18
18
|
this.label = undefined;
|
|
19
19
|
this.progress = undefined;
|
|
20
|
+
this.pressed = undefined;
|
|
20
21
|
this.progressBarLabel = "Loading progress";
|
|
21
22
|
this.removable = undefined;
|
|
22
23
|
this.removeButtonLabel = "Remove";
|
|
@@ -39,15 +40,16 @@ export class SwirlChip {
|
|
|
39
40
|
icon?.setAttribute("size", iconSize);
|
|
40
41
|
}
|
|
41
42
|
render() {
|
|
42
|
-
const Tag = this.interactive ? "button" : "span";
|
|
43
|
+
const Tag = this.interactive || this.pressed !== undefined ? "button" : "span";
|
|
43
44
|
const showAvatar = Boolean(this.el.querySelector('[slot="avatar"]'));
|
|
44
45
|
const showIcon = !showAvatar && Boolean(this.icon);
|
|
45
46
|
const className = classnames("chip", `chip--border-radius-${this.borderRadius}`, `chip--icon-color-${this.iconColor}`, `chip--intent-${this.intent}`, `chip--size-${this.size}`, `chip--variant-${this.variant}`, {
|
|
47
|
+
"chip--pressed": this.pressed,
|
|
46
48
|
"chip--has-progress": this.progress !== undefined,
|
|
47
|
-
"chip--interactive": this.interactive,
|
|
49
|
+
"chip--interactive": this.interactive || this.pressed !== undefined,
|
|
48
50
|
"chip--removable": this.removable,
|
|
49
51
|
});
|
|
50
|
-
return (h(Host, null, h(Tag, { class: className, type: this.interactive ? "button" : undefined }, h("span", { class: "chip__inner" }, showAvatar && (h("span", { class: "chip__avatar" }, h("slot", { name: "avatar" }))), showIcon && (h("span", { class: "chip__icon", innerHTML: this.icon, ref: (el) => (this.iconEl = el) })), h("span", { class: "chip__label" }, this.label)), this.progress !== undefined && (h("span", { class: "chip__progress-indicator" }, h("swirl-progress-indicator", { label: this.progressBarLabel, value: this.progress })))), this.removable && (h("button", { "aria-label": this.removeButtonLabel, class: "chip__remove-button", onClick: this.remove.emit }, h("swirl-icon-close", { size: 20 })))));
|
|
52
|
+
return (h(Host, null, h(Tag, { class: className, type: this.interactive ? "button" : undefined, "aria-pressed": this.pressed !== undefined ? String(this.pressed) : undefined }, h("span", { class: "chip__inner" }, showAvatar && (h("span", { class: "chip__avatar" }, h("slot", { name: "avatar" }))), showIcon && (h("span", { class: "chip__icon", innerHTML: this.icon, ref: (el) => (this.iconEl = el) })), h("span", { class: "chip__label" }, this.label)), this.progress !== undefined && (h("span", { class: "chip__progress-indicator" }, h("swirl-progress-indicator", { label: this.progressBarLabel, value: this.progress })))), this.removable && (h("button", { "aria-label": this.removeButtonLabel, class: "chip__remove-button", onClick: this.remove.emit }, h("swirl-icon-close", { size: 20 })))));
|
|
51
53
|
}
|
|
52
54
|
static get is() { return "swirl-chip"; }
|
|
53
55
|
static get encapsulation() { return "shadow"; }
|
|
@@ -201,6 +203,23 @@ export class SwirlChip {
|
|
|
201
203
|
"attribute": "progress",
|
|
202
204
|
"reflect": false
|
|
203
205
|
},
|
|
206
|
+
"pressed": {
|
|
207
|
+
"type": "boolean",
|
|
208
|
+
"mutable": false,
|
|
209
|
+
"complexType": {
|
|
210
|
+
"original": "boolean",
|
|
211
|
+
"resolved": "boolean",
|
|
212
|
+
"references": {}
|
|
213
|
+
},
|
|
214
|
+
"required": false,
|
|
215
|
+
"optional": true,
|
|
216
|
+
"docs": {
|
|
217
|
+
"tags": [],
|
|
218
|
+
"text": ""
|
|
219
|
+
},
|
|
220
|
+
"attribute": "pressed",
|
|
221
|
+
"reflect": false
|
|
222
|
+
},
|
|
204
223
|
"progressBarLabel": {
|
|
205
224
|
"type": "string",
|
|
206
225
|
"mutable": false,
|
|
@@ -53,6 +53,23 @@ describe("swirl-chip", () => {
|
|
|
53
53
|
</swirl-chip>
|
|
54
54
|
`);
|
|
55
55
|
});
|
|
56
|
+
it.only("renders pressed", async () => {
|
|
57
|
+
const page = await newSpecPage({
|
|
58
|
+
components: [SwirlChip],
|
|
59
|
+
html: `<swirl-chip pressed="true" label="Label"></swirl-chip>`,
|
|
60
|
+
});
|
|
61
|
+
expect(page.root).toEqualHtml(`
|
|
62
|
+
<swirl-chip pressed="true" label="Label">
|
|
63
|
+
<mock:shadow-root>
|
|
64
|
+
<button aria-pressed="true" class="chip chip--border-radius-pill chip--icon-color-default chip--intent-default chip--size-m chip--variant-outline chip--interactive chip--pressed">
|
|
65
|
+
<span class="chip__inner">
|
|
66
|
+
<span class="chip__label">Label</span>
|
|
67
|
+
</span>
|
|
68
|
+
</button>
|
|
69
|
+
</mock:shadow-root>
|
|
70
|
+
</swirl-chip>
|
|
71
|
+
`);
|
|
72
|
+
});
|
|
56
73
|
it("renders icon with overwritten props", async () => {
|
|
57
74
|
const page = await newSpecPage({
|
|
58
75
|
components: [SwirlChip],
|
|
@@ -4,7 +4,7 @@ import { h, Host } from "@stencil/core";
|
|
|
4
4
|
*/
|
|
5
5
|
export class SwirlDescriptionList {
|
|
6
6
|
render() {
|
|
7
|
-
return (h(Host, null, h("
|
|
7
|
+
return (h(Host, null, h("div", { class: "description-list", role: "list" }, h("slot", null))));
|
|
8
8
|
}
|
|
9
9
|
static get is() { return "swirl-description-list"; }
|
|
10
10
|
static get encapsulation() { return "shadow"; }
|
|
@@ -16,9 +16,9 @@ describe("swirl-description-list", () => {
|
|
|
16
16
|
expect(page.root).toEqualHtml(`
|
|
17
17
|
<swirl-description-list>
|
|
18
18
|
<mock:shadow-root>
|
|
19
|
-
<
|
|
19
|
+
<div class="description-list" role="list">
|
|
20
20
|
<slot></slot>
|
|
21
|
-
</
|
|
21
|
+
</div>
|
|
22
22
|
</mock:shadow-root>
|
|
23
23
|
<swirl-description-list-item term="Term #1">
|
|
24
24
|
A short description
|
package/dist/collection/components/swirl-description-list-item/swirl-description-list-item.js
CHANGED
|
@@ -6,12 +6,13 @@ import classNames from "classnames";
|
|
|
6
6
|
export class SwirlDescriptionListItem {
|
|
7
7
|
constructor() {
|
|
8
8
|
this.bordered = true;
|
|
9
|
+
this.maxWidth = undefined;
|
|
9
10
|
this.orientation = "horizontal";
|
|
10
11
|
this.term = undefined;
|
|
11
12
|
}
|
|
12
13
|
render() {
|
|
13
14
|
const className = classNames("description-list-item", `description-list-item--orientation-${this.orientation}`, { "description-list-item--bordered": this.bordered });
|
|
14
|
-
return (h(Host,
|
|
15
|
+
return (h(Host, { role: "listitem" }, h("div", { class: className, part: "description-list-item", role: "group" }, h("div", { class: "description-list-item__term", part: "description-list-item__term", role: "term" }, this.term), h("div", { style: { maxWidth: this.maxWidth }, class: "description-list-item__description", role: "definition" }, h("slot", null)))));
|
|
15
16
|
}
|
|
16
17
|
static get is() { return "swirl-description-list-item"; }
|
|
17
18
|
static get encapsulation() { return "shadow"; }
|
|
@@ -45,6 +46,23 @@ export class SwirlDescriptionListItem {
|
|
|
45
46
|
"reflect": false,
|
|
46
47
|
"defaultValue": "true"
|
|
47
48
|
},
|
|
49
|
+
"maxWidth": {
|
|
50
|
+
"type": "string",
|
|
51
|
+
"mutable": false,
|
|
52
|
+
"complexType": {
|
|
53
|
+
"original": "string",
|
|
54
|
+
"resolved": "string",
|
|
55
|
+
"references": {}
|
|
56
|
+
},
|
|
57
|
+
"required": false,
|
|
58
|
+
"optional": true,
|
|
59
|
+
"docs": {
|
|
60
|
+
"tags": [],
|
|
61
|
+
"text": ""
|
|
62
|
+
},
|
|
63
|
+
"attribute": "max-width",
|
|
64
|
+
"reflect": false
|
|
65
|
+
},
|
|
48
66
|
"orientation": {
|
|
49
67
|
"type": "string",
|
|
50
68
|
"mutable": false,
|
package/dist/collection/components/swirl-description-list-item/swirl-description-list-item.spec.js
CHANGED
|
@@ -7,13 +7,13 @@ describe("swirl-description-list-item", () => {
|
|
|
7
7
|
html: `<swirl-description-list-item term="Term">Description</swirl-description-list-item>`,
|
|
8
8
|
});
|
|
9
9
|
expect(page.root).toEqualHtml(`
|
|
10
|
-
<swirl-description-list-item term="Term">
|
|
10
|
+
<swirl-description-list-item role="listitem" term="Term">
|
|
11
11
|
<mock:shadow-root>
|
|
12
|
-
<div class="description-list-item description-list-item--bordered description-list-item--orientation-horizontal" part="description-list-item">
|
|
13
|
-
<
|
|
14
|
-
<
|
|
12
|
+
<div class="description-list-item description-list-item--bordered description-list-item--orientation-horizontal" part="description-list-item" role="group">
|
|
13
|
+
<div class="description-list-item__term" part="description-list-item__term" role="term">Term</div>
|
|
14
|
+
<div class="description-list-item__description" role="definition">
|
|
15
15
|
<slot></slot>
|
|
16
|
-
</
|
|
16
|
+
</div>
|
|
17
17
|
</div>
|
|
18
18
|
</mock:shadow-root>
|
|
19
19
|
Description
|
|
@@ -17,6 +17,39 @@
|
|
|
17
17
|
0 0 0 0.1875rem var(--s-focus-default);
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
+
.radio--variant-card {
|
|
21
|
+
width: 100%;
|
|
22
|
+
padding: var(--s-space-16);
|
|
23
|
+
border: 0.0625rem solid var(--s-border-default);
|
|
24
|
+
border-radius: var(--s-border-radius-sm);
|
|
25
|
+
background-color: var(--s-surface);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.radio--variant-card:focus-within {
|
|
29
|
+
box-shadow: 0 0 0 0.125rem var(--s-background-default),
|
|
30
|
+
0 0 0 0.25rem var(--s-focus-default);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.radio--variant-card:focus-within .radio__box {
|
|
34
|
+
box-shadow: none;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.radio--variant-card:hover:not(.radio--disabled) {
|
|
38
|
+
background-color: var(--s-surface-hovered);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.radio--variant-card:active:not(.radio--disabled) {
|
|
42
|
+
background-color: var(--s-surface-pressed);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.radio--variant-card.radio--checked:not(.radio--disabled) {
|
|
46
|
+
border-color: var(--s-border-highlight);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.radio--variant-card.radio--invalid:not(.radio--disabled) {
|
|
50
|
+
border-color: var(--s-border-critical);
|
|
51
|
+
}
|
|
52
|
+
|
|
20
53
|
.radio--checked .radio__control:hover .radio__box {
|
|
21
54
|
border-color: var(--s-interactive-primary-hovered);
|
|
22
55
|
background-color: var(--s-interactive-primary-hovered);
|
|
@@ -14,6 +14,7 @@ export class SwirlRadio {
|
|
|
14
14
|
this.invalid = undefined;
|
|
15
15
|
this.label = undefined;
|
|
16
16
|
this.value = undefined;
|
|
17
|
+
this.variant = "default";
|
|
17
18
|
}
|
|
18
19
|
getAriaCheckedLabel(checked, unchecked) {
|
|
19
20
|
if (checked) {
|
|
@@ -29,13 +30,13 @@ export class SwirlRadio {
|
|
|
29
30
|
const checked = this.checked === true || this.checked === "true";
|
|
30
31
|
const ariaCheckedLabel = this.getAriaCheckedLabel(checked, unchecked);
|
|
31
32
|
const ariaInvalid = this.invalid;
|
|
32
|
-
const className = classnames("radio", {
|
|
33
|
+
const className = classnames("radio", `radio--variant-${this.variant}`, {
|
|
33
34
|
"radio--checked": checked,
|
|
34
35
|
"radio--disabled": this.disabled,
|
|
35
36
|
"radio--invalid": this.invalid,
|
|
36
37
|
"radio--unchecked": unchecked,
|
|
37
38
|
});
|
|
38
|
-
return (h(Host,
|
|
39
|
+
return (h(Host, { style: { width: this.variant === "card" ? "100%" : undefined } }, h("label", { class: className, htmlFor: this.inputId }, h("span", { class: "radio__control" }, h("swirl-visually-hidden", null, h("input", { "aria-checked": ariaCheckedLabel, "aria-invalid": ariaInvalid, checked: checked, class: "radio__input", disabled: this.disabled, id: this.inputId, name: this.inputName, onChange: this.onChange, type: "radio", value: this.value })), h("span", { "aria-hidden": "true", class: "radio__box" })), h("span", { class: "radio__label-container" }, this.label && h("span", { class: "radio__label" }, this.label), this.description && (h("span", { class: "radio__description", innerHTML: this.description }))))));
|
|
39
40
|
}
|
|
40
41
|
static get is() { return "swirl-radio"; }
|
|
41
42
|
static get encapsulation() { return "scoped"; }
|
|
@@ -193,6 +194,29 @@ export class SwirlRadio {
|
|
|
193
194
|
},
|
|
194
195
|
"attribute": "value",
|
|
195
196
|
"reflect": false
|
|
197
|
+
},
|
|
198
|
+
"variant": {
|
|
199
|
+
"type": "string",
|
|
200
|
+
"mutable": false,
|
|
201
|
+
"complexType": {
|
|
202
|
+
"original": "SwirlRadioVariant",
|
|
203
|
+
"resolved": "\"card\" | \"default\"",
|
|
204
|
+
"references": {
|
|
205
|
+
"SwirlRadioVariant": {
|
|
206
|
+
"location": "local",
|
|
207
|
+
"path": "/home/runner/work/swirl/swirl/packages/swirl-components/src/components/swirl-radio/swirl-radio.tsx"
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
},
|
|
211
|
+
"required": false,
|
|
212
|
+
"optional": true,
|
|
213
|
+
"docs": {
|
|
214
|
+
"tags": [],
|
|
215
|
+
"text": ""
|
|
216
|
+
},
|
|
217
|
+
"attribute": "variant",
|
|
218
|
+
"reflect": false,
|
|
219
|
+
"defaultValue": "\"default\""
|
|
196
220
|
}
|
|
197
221
|
};
|
|
198
222
|
}
|
|
@@ -8,7 +8,7 @@ describe("swirl-radio", () => {
|
|
|
8
8
|
});
|
|
9
9
|
expect(page.root).toMatchInlineSnapshot(`
|
|
10
10
|
<swirl-radio checked="true" disabled="true" input-id="radio" input-name="radio" label="Label" value="Value">
|
|
11
|
-
<label class="radio radio--checked radio--disabled" htmlfor="radio">
|
|
11
|
+
<label class="radio radio--checked radio--disabled radio--variant-default" htmlfor="radio">
|
|
12
12
|
<span class="radio__control">
|
|
13
13
|
<swirl-visually-hidden>
|
|
14
14
|
<input aria-checked="true" checked="" class="radio__input" disabled="" id="radio" name="radio" type="radio" value="Value">
|