@inglorious/ui 9.1.1 → 9.2.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/package.json +1 -1
- package/src/controls/checkbox/checkbox.stories.js +16 -0
- package/src/controls/checkbox/style.css +24 -0
- package/src/controls/checkbox/template.js +15 -2
- package/src/controls/radio-group/radio-group.stories.js +19 -0
- package/src/controls/radio-group/style.css +30 -0
- package/src/controls/radio-group/template.js +15 -2
- package/src/data-display/chip/chip.stories.js +13 -0
- package/src/data-display/chip/style.css +22 -0
- package/src/data-display/chip/template.js +25 -2
- package/types/controls/checkbox.d.ts +4 -0
- package/types/controls/radio-group.d.ts +4 -0
- package/types/data-display/chip.d.ts +7 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inglorious/ui",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.2.0",
|
|
4
4
|
"description": "A design system for Inglorious Web with render-function components and customizable themes",
|
|
5
5
|
"author": "Matteo Antony Mistretta <antony.mistretta@gmail.com> (https://ingloriouscoderz.it)",
|
|
6
6
|
"license": "MIT",
|
|
@@ -12,6 +12,12 @@ export default {
|
|
|
12
12
|
description: "A line of detail under the label.",
|
|
13
13
|
},
|
|
14
14
|
name: { control: "text", description: "Native HTML name attribute." },
|
|
15
|
+
variant: {
|
|
16
|
+
control: "select",
|
|
17
|
+
options: ["default", "card"],
|
|
18
|
+
description:
|
|
19
|
+
"`card` draws the checkbox as a card, outlined while checked.",
|
|
20
|
+
},
|
|
15
21
|
isChecked: { control: "boolean", description: "Current checked state." },
|
|
16
22
|
isDisabled: { control: "boolean", description: "Disables interaction." },
|
|
17
23
|
isRequired: { control: "boolean", description: "Marks input as required." },
|
|
@@ -60,3 +66,13 @@ WithDescription.args = {
|
|
|
60
66
|
name: "summary",
|
|
61
67
|
description: "An email every Monday with last week's totals.",
|
|
62
68
|
}
|
|
69
|
+
|
|
70
|
+
export const Card = {}
|
|
71
|
+
Card.args = {
|
|
72
|
+
...Default.args,
|
|
73
|
+
label: "Breakfast",
|
|
74
|
+
name: "breakfast",
|
|
75
|
+
description: "Served from 7 to 10, €12",
|
|
76
|
+
variant: "card",
|
|
77
|
+
isChecked: true,
|
|
78
|
+
}
|
|
@@ -38,6 +38,30 @@
|
|
|
38
38
|
font-size: var(--iw-font-size-lg);
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
+
.iw-checkbox-media {
|
|
42
|
+
display: block;
|
|
43
|
+
margin-block-end: var(--iw-space-2);
|
|
44
|
+
|
|
45
|
+
img {
|
|
46
|
+
display: block;
|
|
47
|
+
max-inline-size: 100%;
|
|
48
|
+
border-radius: var(--iw-radius-sm);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
&.iw-checkbox-card {
|
|
53
|
+
display: flex;
|
|
54
|
+
align-items: flex-start;
|
|
55
|
+
padding: var(--iw-space-3);
|
|
56
|
+
border: 1px solid var(--iw-color-border);
|
|
57
|
+
border-radius: var(--iw-radius-md);
|
|
58
|
+
|
|
59
|
+
&:has(:checked) {
|
|
60
|
+
border-color: var(--iw-checkbox-accent);
|
|
61
|
+
background: color-mix(in srgb, var(--iw-checkbox-accent) 8%, transparent);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
41
65
|
&.iw-checkbox-disabled {
|
|
42
66
|
opacity: 0.6;
|
|
43
67
|
cursor: not-allowed;
|
|
@@ -23,6 +23,8 @@ export function render(props) {
|
|
|
23
23
|
name = "",
|
|
24
24
|
label = "",
|
|
25
25
|
description,
|
|
26
|
+
media,
|
|
27
|
+
variant = "default",
|
|
26
28
|
isChecked = false,
|
|
27
29
|
isDisabled = false,
|
|
28
30
|
isRequired = false,
|
|
@@ -39,6 +41,7 @@ export function render(props) {
|
|
|
39
41
|
const classes = {
|
|
40
42
|
"iw-checkbox": true,
|
|
41
43
|
"iw-checkbox-disabled": isDisabled,
|
|
44
|
+
"iw-checkbox-card": variant === "card",
|
|
42
45
|
[`iw-checkbox-${color}`]: color !== "primary",
|
|
43
46
|
[`iw-checkbox-${size}`]: size !== "md",
|
|
44
47
|
}
|
|
@@ -57,11 +60,21 @@ export function render(props) {
|
|
|
57
60
|
${ref((element) => applyElementProps(element, rest))}
|
|
58
61
|
/>
|
|
59
62
|
${when(
|
|
60
|
-
description,
|
|
63
|
+
description || media,
|
|
61
64
|
() =>
|
|
62
65
|
html`<span class="iw-checkbox-text">
|
|
66
|
+
${when(
|
|
67
|
+
media,
|
|
68
|
+
() => html`<span class="iw-checkbox-media">${media}</span>`,
|
|
69
|
+
)}
|
|
63
70
|
<span class="iw-checkbox-label">${label}</span>
|
|
64
|
-
|
|
71
|
+
${when(
|
|
72
|
+
description,
|
|
73
|
+
() =>
|
|
74
|
+
html`<span class="iw-checkbox-description"
|
|
75
|
+
>${description}</span
|
|
76
|
+
>`,
|
|
77
|
+
)}
|
|
65
78
|
</span>`,
|
|
66
79
|
() => html`<span class="iw-checkbox-label">${label}</span>`,
|
|
67
80
|
)}
|
|
@@ -14,6 +14,11 @@ export default {
|
|
|
14
14
|
options: ["column", "row"],
|
|
15
15
|
description: "Layout direction for options.",
|
|
16
16
|
},
|
|
17
|
+
variant: {
|
|
18
|
+
control: "select",
|
|
19
|
+
options: ["default", "card"],
|
|
20
|
+
description: "`card` draws each option as a card in a grid.",
|
|
21
|
+
},
|
|
17
22
|
color: {
|
|
18
23
|
control: "select",
|
|
19
24
|
options: ["primary", "secondary", "success", "warning", "error", "info"],
|
|
@@ -72,3 +77,17 @@ WithDescriptions.args = {
|
|
|
72
77
|
{ label: "Express", value: "express", description: "Next day, €9" },
|
|
73
78
|
],
|
|
74
79
|
}
|
|
80
|
+
|
|
81
|
+
export const Cards = {}
|
|
82
|
+
Cards.args = {
|
|
83
|
+
...Default.args,
|
|
84
|
+
label: "Room",
|
|
85
|
+
name: "room",
|
|
86
|
+
value: "double",
|
|
87
|
+
variant: "card",
|
|
88
|
+
options: [
|
|
89
|
+
{ label: "Single", value: "single", description: "One bed, €80" },
|
|
90
|
+
{ label: "Double", value: "double", description: "Two beds, €120" },
|
|
91
|
+
{ label: "Suite", value: "suite", description: "With a view, €200" },
|
|
92
|
+
],
|
|
93
|
+
}
|
|
@@ -70,4 +70,34 @@
|
|
|
70
70
|
&.iw-radio-group-info {
|
|
71
71
|
--iw-radio-accent: var(--iw-color-info);
|
|
72
72
|
}
|
|
73
|
+
|
|
74
|
+
/* After the directions, which it overrides with a grid. */
|
|
75
|
+
&.iw-radio-group-card {
|
|
76
|
+
display: grid;
|
|
77
|
+
grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr));
|
|
78
|
+
gap: var(--iw-space-3);
|
|
79
|
+
|
|
80
|
+
.iw-radio-option {
|
|
81
|
+
align-items: flex-start;
|
|
82
|
+
padding: var(--iw-space-3);
|
|
83
|
+
border: 1px solid var(--iw-color-border);
|
|
84
|
+
border-radius: var(--iw-radius-md);
|
|
85
|
+
|
|
86
|
+
&:has(:checked) {
|
|
87
|
+
border-color: var(--iw-radio-accent);
|
|
88
|
+
background: color-mix(in srgb, var(--iw-radio-accent) 8%, transparent);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.iw-radio-media {
|
|
94
|
+
display: block;
|
|
95
|
+
margin-block-end: var(--iw-space-2);
|
|
96
|
+
|
|
97
|
+
img {
|
|
98
|
+
display: block;
|
|
99
|
+
max-inline-size: 100%;
|
|
100
|
+
border-radius: var(--iw-radius-sm);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
73
103
|
}
|
|
@@ -25,6 +25,7 @@ export function render(props) {
|
|
|
25
25
|
value,
|
|
26
26
|
options = [],
|
|
27
27
|
direction = "column",
|
|
28
|
+
variant = "default",
|
|
28
29
|
color = "primary",
|
|
29
30
|
isDisabled = false,
|
|
30
31
|
onChange,
|
|
@@ -38,6 +39,7 @@ export function render(props) {
|
|
|
38
39
|
const rootClasses = {
|
|
39
40
|
"iw-radio-group": true,
|
|
40
41
|
[`iw-radio-group-${direction}`]: true,
|
|
42
|
+
"iw-radio-group-card": variant === "card",
|
|
41
43
|
[`iw-radio-group-${color}`]: color !== "primary",
|
|
42
44
|
"iw-radio-group-disabled": isDisabled,
|
|
43
45
|
}
|
|
@@ -56,6 +58,7 @@ export function render(props) {
|
|
|
56
58
|
const {
|
|
57
59
|
label: optionLabel,
|
|
58
60
|
description: optionDescription,
|
|
61
|
+
media,
|
|
59
62
|
value: optionValue,
|
|
60
63
|
isDisabled: optionDisabled = false,
|
|
61
64
|
...optionRest
|
|
@@ -75,11 +78,21 @@ export function render(props) {
|
|
|
75
78
|
${ref((element) => applyElementProps(element, optionRest))}
|
|
76
79
|
/>
|
|
77
80
|
${when(
|
|
78
|
-
optionDescription,
|
|
81
|
+
optionDescription || media,
|
|
79
82
|
() =>
|
|
80
83
|
html`<span class="iw-radio-text">
|
|
84
|
+
${when(
|
|
85
|
+
media,
|
|
86
|
+
() => html`<span class="iw-radio-media">${media}</span>`,
|
|
87
|
+
)}
|
|
81
88
|
<span>${optionLabel}</span>
|
|
82
|
-
|
|
89
|
+
${when(
|
|
90
|
+
optionDescription,
|
|
91
|
+
() =>
|
|
92
|
+
html`<span class="iw-radio-description"
|
|
93
|
+
>${optionDescription}</span
|
|
94
|
+
>`,
|
|
95
|
+
)}
|
|
83
96
|
</span>`,
|
|
84
97
|
() => html`<span>${optionLabel}</span>`,
|
|
85
98
|
)}
|
|
@@ -10,6 +10,10 @@ export default {
|
|
|
10
10
|
render: createRender(Chip),
|
|
11
11
|
argTypes: {
|
|
12
12
|
children: { control: "text", description: "Chip label content." },
|
|
13
|
+
isSelected: {
|
|
14
|
+
control: "boolean",
|
|
15
|
+
description: "Makes the chip a toggle button, pressed while true.",
|
|
16
|
+
},
|
|
13
17
|
icon: {
|
|
14
18
|
control: false,
|
|
15
19
|
description: "Shown before the label, such as an `Icon.render(...)`.",
|
|
@@ -72,3 +76,12 @@ export const WithIcon = {
|
|
|
72
76
|
color: "success",
|
|
73
77
|
},
|
|
74
78
|
}
|
|
79
|
+
|
|
80
|
+
export const Selectable = {
|
|
81
|
+
args: {
|
|
82
|
+
...Default.args,
|
|
83
|
+
children: "Vegan",
|
|
84
|
+
isRemovable: false,
|
|
85
|
+
isSelected: true,
|
|
86
|
+
},
|
|
87
|
+
}
|
|
@@ -64,6 +64,28 @@
|
|
|
64
64
|
border-radius: var(--iw-radius-none);
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
+
&.iw-chip-selectable {
|
|
68
|
+
border: 1px solid var(--iw-color-border);
|
|
69
|
+
font: inherit;
|
|
70
|
+
font-size: var(--iw-font-size-sm);
|
|
71
|
+
cursor: pointer;
|
|
72
|
+
|
|
73
|
+
&:focus-visible {
|
|
74
|
+
outline: 2px solid var(--iw-color-primary);
|
|
75
|
+
outline-offset: 2px;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
&:disabled {
|
|
79
|
+
opacity: 0.6;
|
|
80
|
+
cursor: not-allowed;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
&.iw-chip-selected {
|
|
85
|
+
border-color: var(--iw-color-primary);
|
|
86
|
+
background: color-mix(in srgb, var(--iw-color-primary) 20%, transparent);
|
|
87
|
+
}
|
|
88
|
+
|
|
67
89
|
&.iw-chip-primary {
|
|
68
90
|
background: color-mix(in srgb, var(--iw-color-primary) 20%, transparent);
|
|
69
91
|
}
|
|
@@ -21,6 +21,8 @@ export function render(props) {
|
|
|
21
21
|
color = "default",
|
|
22
22
|
size = "md",
|
|
23
23
|
shape = "pill",
|
|
24
|
+
isSelected,
|
|
25
|
+
isDisabled = false,
|
|
24
26
|
onClick,
|
|
25
27
|
} = props
|
|
26
28
|
|
|
@@ -31,9 +33,30 @@ export function render(props) {
|
|
|
31
33
|
[`iw-chip-shape-${shape}`]: shape !== "pill",
|
|
32
34
|
}
|
|
33
35
|
|
|
36
|
+
const content = html`${when(
|
|
37
|
+
icon,
|
|
38
|
+
() => html`<span class="iw-chip-icon" aria-hidden="true">${icon}</span>`,
|
|
39
|
+
)} <span class="iw-chip-label">${children}</span>`
|
|
40
|
+
|
|
41
|
+
// A chip that can be picked is a toggle button, pressed while selected.
|
|
42
|
+
if (isSelected !== undefined) {
|
|
43
|
+
return html`<button
|
|
44
|
+
type="button"
|
|
45
|
+
class=${classMap({
|
|
46
|
+
...classes,
|
|
47
|
+
"iw-chip-selectable": true,
|
|
48
|
+
"iw-chip-selected": isSelected,
|
|
49
|
+
})}
|
|
50
|
+
aria-pressed=${String(isSelected)}
|
|
51
|
+
?disabled=${isDisabled}
|
|
52
|
+
@click=${onClick}
|
|
53
|
+
>
|
|
54
|
+
${content}
|
|
55
|
+
</button>`
|
|
56
|
+
}
|
|
57
|
+
|
|
34
58
|
return html`<span class=${classMap(classes)}>
|
|
35
|
-
${
|
|
36
|
-
<span class="iw-chip-label">${children}</span>
|
|
59
|
+
${content}
|
|
37
60
|
${when(
|
|
38
61
|
isRemovable,
|
|
39
62
|
() =>
|
|
@@ -6,6 +6,10 @@ export interface CheckboxProps {
|
|
|
6
6
|
label?: string
|
|
7
7
|
/** A line of detail under the label. */
|
|
8
8
|
description?: string
|
|
9
|
+
/** Shown above the label, such as an icon or an image. */
|
|
10
|
+
media?: TemplateResult
|
|
11
|
+
/** `"card"` draws the checkbox as a card, outlined while checked. */
|
|
12
|
+
variant?: "default" | "card"
|
|
9
13
|
isChecked?: boolean
|
|
10
14
|
isDisabled?: boolean
|
|
11
15
|
isRequired?: boolean
|
|
@@ -4,6 +4,8 @@ export interface RadioOption {
|
|
|
4
4
|
label: string
|
|
5
5
|
/** A line of detail under the label. */
|
|
6
6
|
description?: string
|
|
7
|
+
/** Shown above the label, such as an icon or an image. */
|
|
8
|
+
media?: TemplateResult
|
|
7
9
|
value: string
|
|
8
10
|
isDisabled?: boolean
|
|
9
11
|
[key: string]: unknown
|
|
@@ -16,6 +18,8 @@ export interface RadioGroupProps {
|
|
|
16
18
|
value?: string
|
|
17
19
|
options?: RadioOption[]
|
|
18
20
|
direction?: "column" | "row"
|
|
21
|
+
/** `"card"` draws each option as a card in a grid, outlined while checked. */
|
|
22
|
+
variant?: "default" | "card"
|
|
19
23
|
color?: "primary" | "secondary" | "success" | "warning" | "error" | "info"
|
|
20
24
|
isDisabled?: boolean
|
|
21
25
|
onChange?: (value: string) => void
|
|
@@ -16,6 +16,13 @@ export interface ChipProps {
|
|
|
16
16
|
| "info"
|
|
17
17
|
size?: "sm" | "md" | "lg"
|
|
18
18
|
shape?: "pill" | "rounded" | "square"
|
|
19
|
+
/**
|
|
20
|
+
* Makes the chip a toggle button, pressed while true, for picking options:
|
|
21
|
+
* `onClick` toggles it. Left out, the chip is a plain label.
|
|
22
|
+
*/
|
|
23
|
+
isSelected?: boolean
|
|
24
|
+
/** Only for a chip with `isSelected`. */
|
|
25
|
+
isDisabled?: boolean
|
|
19
26
|
onClick?: () => void
|
|
20
27
|
[key: string]: unknown
|
|
21
28
|
}
|