@timmo001/groundwork-ui 0.6.0 → 0.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/custom-elements.json +214 -18
- package/package.json +1 -1
- package/src/fields.ts +32 -6
- package/src/gw-badge.ts +29 -18
- package/src/gw-button.ts +8 -24
- package/src/gw-card.ts +97 -4
- package/src/gw-chip.ts +26 -7
- package/src/gw-input.ts +7 -0
- package/src/gw-menu-button.ts +17 -5
- package/src/gw-segmented.ts +19 -7
- package/src/gw-select.ts +7 -0
- package/src/gw-setting-row.ts +21 -5
- package/src/styles.ts +25 -0
package/src/gw-select.ts
CHANGED
|
@@ -62,6 +62,10 @@ const chevronIcon =
|
|
|
62
62
|
* @attr {OptionItem[]} options - The options, as JSON.
|
|
63
63
|
* @attr {boolean} label-hidden - Hides the label but keeps it for assistive technology.
|
|
64
64
|
* @attr {boolean} inline-label - Shows the label inside the trigger, before the value, for toolbars and filters.
|
|
65
|
+
* @attr {"xs"|"small"|"medium"|"large"|"xl"} size - The field's size, 40px tall at medium. Defaults to `medium`.
|
|
66
|
+
*
|
|
67
|
+
* @cssprop --gw-field-scale - Scales the field, around 1 for medium.
|
|
68
|
+
* @cssprop --gw-control-scale - Scales its height with the theme's density. The theme sets it.
|
|
65
69
|
*
|
|
66
70
|
* @fires {Event} change - When the value, or `values` with `multiple`, changes.
|
|
67
71
|
*/
|
|
@@ -81,6 +85,7 @@ export class GwSelect extends LightElement {
|
|
|
81
85
|
options: { type: "json" },
|
|
82
86
|
labelHidden: { type: "boolean", attribute: "label-hidden" },
|
|
83
87
|
inlineLabel: { type: "boolean", attribute: "inline-label", reflect: true },
|
|
88
|
+
size: { reflect: true },
|
|
84
89
|
} as const;
|
|
85
90
|
|
|
86
91
|
declare label: string;
|
|
@@ -99,6 +104,7 @@ export class GwSelect extends LightElement {
|
|
|
99
104
|
declare options: readonly OptionItem[];
|
|
100
105
|
declare labelHidden: boolean;
|
|
101
106
|
declare inlineLabel: boolean;
|
|
107
|
+
declare size: "xs" | "small" | "medium" | "large" | "xl";
|
|
102
108
|
|
|
103
109
|
readonly #id = fieldId();
|
|
104
110
|
|
|
@@ -172,6 +178,7 @@ export class GwSelect extends LightElement {
|
|
|
172
178
|
this.options = [];
|
|
173
179
|
this.labelHidden = false;
|
|
174
180
|
this.inlineLabel = false;
|
|
181
|
+
this.size = "medium";
|
|
175
182
|
}
|
|
176
183
|
|
|
177
184
|
/** Opens the list, such as from a keyboard shortcut. */
|
package/src/gw-setting-row.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
import { GwElement, css, h, setAttribute } from "./element.js";
|
|
8
8
|
import "./gw-skeleton.js";
|
|
9
9
|
import { fadeIn } from "./motion.js";
|
|
10
|
-
import { base } from "./styles.js";
|
|
10
|
+
import { base, controlSizes } from "./styles.js";
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* A setting: its name and description on one side, its control on the
|
|
@@ -21,34 +21,42 @@ import { base } from "./styles.js";
|
|
|
21
21
|
* @attr {string} heading - The setting's name.
|
|
22
22
|
* @attr {string} description - What it does.
|
|
23
23
|
* @attr {boolean} loading - Shows skeletons for the control and any unknown text.
|
|
24
|
+
* @attr {"xs"|"small"|"medium"|"large"|"xl"} size - The text and spacing size. Defaults to `medium`.
|
|
24
25
|
*
|
|
25
26
|
* @slot - The control.
|
|
26
27
|
*
|
|
27
28
|
* @csspart row - The row.
|
|
28
29
|
*
|
|
29
30
|
* @cssprop --gw-row-padding - The padding above and below. Defaults to `--gw-space-2`.
|
|
31
|
+
* @cssprop --gw-setting-row-scale - Scales the text and spacing, around 1 for medium.
|
|
30
32
|
*/
|
|
31
33
|
export class GwSettingRow extends GwElement {
|
|
32
34
|
static override properties = {
|
|
33
35
|
heading: {},
|
|
34
36
|
description: {},
|
|
35
37
|
loading: { type: "boolean", reflect: true },
|
|
38
|
+
size: { reflect: true },
|
|
36
39
|
} as const;
|
|
37
40
|
|
|
38
41
|
static override styles = [
|
|
39
42
|
base,
|
|
43
|
+
controlSizes("setting-row"),
|
|
40
44
|
css`
|
|
41
45
|
:host {
|
|
46
|
+
--gw-size: var(--gw-setting-row-scale, 1);
|
|
47
|
+
|
|
42
48
|
display: block;
|
|
43
49
|
}
|
|
44
50
|
|
|
45
51
|
.row {
|
|
46
52
|
display: flex;
|
|
47
53
|
flex-wrap: wrap;
|
|
48
|
-
gap: var(--gw-space-1) var(--gw-
|
|
54
|
+
gap: calc(var(--gw-space-1) * var(--gw-size))
|
|
55
|
+
calc(var(--gw-space-3) * var(--gw-size));
|
|
49
56
|
align-items: center;
|
|
50
57
|
justify-content: space-between;
|
|
51
|
-
padding: var(--gw-row-padding, var(--gw-space-2))
|
|
58
|
+
padding: var(--gw-row-padding, calc(var(--gw-space-2) * var(--gw-size)))
|
|
59
|
+
0;
|
|
52
60
|
}
|
|
53
61
|
|
|
54
62
|
/* A full line even in themes without borders, since it separates rows */
|
|
@@ -63,13 +71,19 @@ export class GwSettingRow extends GwElement {
|
|
|
63
71
|
}
|
|
64
72
|
|
|
65
73
|
.heading {
|
|
66
|
-
font-size:
|
|
74
|
+
font-size: max(
|
|
75
|
+
var(--gw-font-size-xs),
|
|
76
|
+
calc(var(--gw-font-size-s) * var(--gw-size))
|
|
77
|
+
);
|
|
67
78
|
font-weight: var(--gw-font-weight-strong);
|
|
68
79
|
color: var(--gw-color-text-strong);
|
|
69
80
|
}
|
|
70
81
|
|
|
71
82
|
.description {
|
|
72
|
-
font-size:
|
|
83
|
+
font-size: max(
|
|
84
|
+
var(--gw-font-size-2xs),
|
|
85
|
+
calc(var(--gw-font-size-xs) * var(--gw-size))
|
|
86
|
+
);
|
|
73
87
|
color: var(--gw-color-text-secondary);
|
|
74
88
|
}
|
|
75
89
|
|
|
@@ -89,6 +103,7 @@ export class GwSettingRow extends GwElement {
|
|
|
89
103
|
declare heading: string;
|
|
90
104
|
declare description: string;
|
|
91
105
|
declare loading: boolean;
|
|
106
|
+
declare size: "xs" | "small" | "medium" | "large" | "xl";
|
|
92
107
|
|
|
93
108
|
readonly #row = h("div", { class: "row", part: "row" });
|
|
94
109
|
|
|
@@ -124,6 +139,7 @@ export class GwSettingRow extends GwElement {
|
|
|
124
139
|
this.heading = "";
|
|
125
140
|
this.description = "";
|
|
126
141
|
this.loading = false;
|
|
142
|
+
this.size = "medium";
|
|
127
143
|
}
|
|
128
144
|
|
|
129
145
|
protected override create(root: ShadowRoot) {
|
package/src/styles.ts
CHANGED
|
@@ -7,6 +7,31 @@ import { css } from "./element.js";
|
|
|
7
7
|
|
|
8
8
|
const svgNamespace = "http://www.w3.org/2000/svg";
|
|
9
9
|
|
|
10
|
+
/**
|
|
11
|
+
* The `xs` to `xl` presets on a `size` attribute, as `--gw-<name>-scale`
|
|
12
|
+
* around 1 for medium, so an app can also set any size between or beyond
|
|
13
|
+
* them. A control multiplies its height and icon by `--gw-control-scale`
|
|
14
|
+
* too, which follows the theme's density, and its text only by its own
|
|
15
|
+
* scale, since spacing and type already follow density on their own.
|
|
16
|
+
*/
|
|
17
|
+
export const controlSizes = (name: string) => css`
|
|
18
|
+
:host([size="xs"]) {
|
|
19
|
+
--gw-${name}-scale: 0.6;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
:host([size="small"]) {
|
|
23
|
+
--gw-${name}-scale: 0.8;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
:host([size="large"]) {
|
|
27
|
+
--gw-${name}-scale: 1.2;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
:host([size="xl"]) {
|
|
31
|
+
--gw-${name}-scale: 1.4;
|
|
32
|
+
}
|
|
33
|
+
`;
|
|
34
|
+
|
|
10
35
|
/**
|
|
11
36
|
* What every component shares: box sizing, the focus ring, icons and the
|
|
12
37
|
* tones that set `--gw-tone` from a `tone` attribute.
|