@timmo001/groundwork-ui 0.9.6 → 0.9.7
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 +18 -2
- package/package.json +1 -1
- package/src/gw-menu-button.ts +48 -1
package/custom-elements.json
CHANGED
|
@@ -10368,7 +10368,7 @@
|
|
|
10368
10368
|
"text": "Properties"
|
|
10369
10369
|
},
|
|
10370
10370
|
"static": true,
|
|
10371
|
-
"default": "{ label: {}, heading: {}, icon: {}, empty: {}, items: { type: \"json\" }, actions: { type: \"json\" }, size: { reflect: true }, active: { type: \"boolean\", reflect: true }, labels: { reflect: true }, }",
|
|
10371
|
+
"default": "{ label: {}, heading: {}, icon: {}, empty: {}, items: { type: \"json\" }, actions: { type: \"json\" }, size: { reflect: true }, appearance: { reflect: true }, active: { type: \"boolean\", reflect: true }, labels: { reflect: true }, }",
|
|
10372
10372
|
"inheritedFrom": {
|
|
10373
10373
|
"name": "GwElement",
|
|
10374
10374
|
"module": "src/element.ts"
|
|
@@ -10381,7 +10381,7 @@
|
|
|
10381
10381
|
"text": "readonly CSSStyleSheet[]"
|
|
10382
10382
|
},
|
|
10383
10383
|
"static": true,
|
|
10384
|
-
"default": "[ base, controlSizes(\"menu-button\"), css` :host { position: relative; display: inline-block; anchor-scope: --gw-menu; } .trigger { --gw-size: var(--gw-menu-button-scale, 1); --gw-scale: calc(var(--gw-size) * var(--gw-control-scale, 1)); --gw-icon-size: calc(1.25rem * var(--gw-scale)); display: inline-flex; gap: calc(var(--gw-space-2) * var(--gw-size)); align-items: center; box-sizing: border-box; height: calc(2.5rem * var(--gw-scale)); padding: 0 calc(var(--gw-space-4) * var(--gw-size)); font: inherit; font-size: calc(var(--gw-font-size-s) * var(--gw-size)); font-weight: var(--gw-font-weight-strong); color: var(--gw-color-text-strong); cursor: pointer; background: var(--gw-color-fill-neutral-resting); border: var(--gw-border-width) solid var(--gw-border-color); border-radius: var(--gw-radius-control); transition: background-color var(--gw-motion-fast) var(--gw-motion-easing); anchor-name: --gw-menu; } .trigger:hover { background: var(--gw-color-fill-neutral-hovered); } :host([active]) .trigger { color: var(--gw-color-accent); border-color: var(--gw-color-accent); } /* Icon only, square, with the text kept for assistive technology */ :host([labels=\"hide\"]) .trigger.has-icon { padding: 0 calc(var(--gw-space-2) * var(--gw-size)); } :host([labels=\"hide\"]) .has-icon .label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; } @media (width < 40rem) { :host([labels=\"auto\"]) .trigger.has-icon { padding: 0 calc(var(--gw-space-2) * var(--gw-size)); } :host([labels=\"auto\"]) .has-icon .label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; } } .chevron { width: 0.4rem; height: 0.4rem; margin-inline-start: var(--gw-space-1); border-inline-end: 1.5px solid currentColor; border-block-end: 1.5px solid currentColor; rotate: 45deg; translate: 0 -0.125rem; transition: rotate var(--gw-motion-normal) var(--gw-motion-easing), translate var(--gw-motion-normal) var(--gw-motion-easing); } .trigger[aria-expanded=\"true\"] .chevron { rotate: 225deg; translate: 0 0.125rem; } [popover] { position-anchor: --gw-menu; position-try-fallbacks: flip-block, flip-inline; inset: auto; top: anchor(bottom); left: anchor(left); box-sizing: border-box; min-width: 15rem; max-height: min(24rem, 60vh); padding: 0; margin: var(--gw-space-1) 0 0; overflow: hidden; color: var(--gw-color-text-primary); background: var(--gw-color-surface-overlay); border: max(var(--gw-border-width), 1px) solid var(--gw-color-border-normal); border-radius: var(--gw-radius-l); box-shadow: var(--gw-shadow-m); opacity: 0; translate: 0 -0.25rem; transition: opacity var(--gw-motion-fast) var(--gw-motion-easing), translate var(--gw-motion-normal) var(--gw-motion-easing), display var(--gw-motion-normal) allow-discrete, overlay var(--gw-motion-normal) allow-discrete; } [popover]:popover-open { display: flex; flex-direction: column; opacity: 1; translate: 0 0; } @starting-style { [popover]:popover-open { opacity: 0; translate: 0 -0.25rem; } } /* The items scroll; the actions stay put below them, so \"Add\" is always in reach rather than at the end of a long list */ .items, .actions { display: flex; flex-direction: column; gap: var(--gw-space-0-5); padding: var(--gw-space-1); } .items { flex: 1; min-height: 0; overflow-y: auto; } .actions { border-block-start: max(var(--gw-border-width), 1px) solid var(--gw-color-border-normal); } .empty { padding: var(--gw-space-3); margin: 0; font-size: var(--gw-font-size-s); color: var(--gw-color-text-secondary); } .item { display: flex; gap: var(--gw-space-3); align-items: center; box-sizing: border-box; min-height: 2.5rem; padding: var(--gw-space-2) var(--gw-space-3); font: inherit; font-size: var(--gw-font-size-s); color: var(--gw-color-text-primary); text-align: start; cursor: pointer; background: transparent; border: 0; border-radius: var(--gw-radius-m); transition: background-color var(--gw-motion-fast) var(--gw-motion-easing); --gw-icon-size: 1.125rem; } .item:hover, .item:focus-visible { background: var(--gw-color-fill-neutral-hovered); outline: none; } .item:focus-visible { box-shadow: inset 0 0 0 var(--gw-focus-width) var(--gw-color-focus); } .item:disabled { color: var(--gw-color-text-disabled); cursor: not-allowed; background: transparent; } .action { font-weight: var(--gw-font-weight-strong); color: var(--gw-color-accent); } /* Holds the tick's place on every choice, so the labels line up */ .tick { flex: none; width: var(--gw-icon-size); height: var(--gw-icon-size); color: var(--gw-color-accent); } .item[aria-checked=\"false\"] .tick { visibility: hidden; } .separator { flex: none; height: 0; margin: var(--gw-space-0-5) calc(-1 * var(--gw-space-1)); border: 0; border-block-start: max(var(--gw-border-width), 1px) solid var(--gw-color-border-normal); } .text { display: flex; flex-direction: column; gap: var(--gw-space-0-5); } .description { font-size: var(--gw-font-size-xs); color: var(--gw-color-text-secondary); } `, ]",
|
|
10384
|
+
"default": "[ base, controlSizes(\"menu-button\"), css` :host { position: relative; display: inline-block; anchor-scope: --gw-menu; } .trigger { --gw-size: var(--gw-menu-button-scale, 1); --gw-scale: calc(var(--gw-size) * var(--gw-control-scale, 1)); --gw-icon-size: calc(1.25rem * var(--gw-scale)); display: inline-flex; gap: calc(var(--gw-space-2) * var(--gw-size)); align-items: center; box-sizing: border-box; height: calc(2.5rem * var(--gw-scale)); padding: 0 calc(var(--gw-space-4) * var(--gw-size)); font: inherit; font-size: calc(var(--gw-font-size-s) * var(--gw-size)); font-weight: var(--gw-font-weight-strong); color: var(--gw-color-text-strong); cursor: pointer; background: var(--gw-color-fill-neutral-resting); border: var(--gw-border-width) solid var(--gw-border-color); border-radius: var(--gw-radius-control); transition: background-color var(--gw-motion-fast) var(--gw-motion-easing); anchor-name: --gw-menu; } .trigger:hover { background: var(--gw-color-fill-neutral-hovered); } /* The other appearances draw the trigger as gw-button draws a neutral one, a pill, so it sits in a row of buttons without a seam */ :host([appearance=\"accent\"]) .trigger, :host([appearance=\"outlined\"]) .trigger, :host([appearance=\"plain\"]) .trigger { background: transparent; border: max(var(--gw-border-width), 1px) solid transparent; border-radius: var(--gw-radius-pill); transition: background-color var(--gw-motion-fast) var(--gw-motion-easing), border-color var(--gw-motion-fast) var(--gw-motion-easing), color var(--gw-motion-fast) var(--gw-motion-easing); } :host([appearance=\"outlined\"]) .trigger { border-color: var(--gw-color-text-secondary); } :host([appearance=\"outlined\"]) .trigger:hover, :host([appearance=\"plain\"]) .trigger:hover { background: color-mix( in oklch, var(--gw-color-text-secondary) 16%, transparent ); } /* A solid fill, with text that flips between black and white by the fill's lightness, as gw-button's accent does */ :host([appearance=\"accent\"]) .trigger { color: oklch( from var(--gw-color-accent) clamp(0, (0.66 - l) * 1000, 1) 0 0 ); background: var(--gw-color-accent); } :host([appearance=\"accent\"]) .trigger:hover { background: oklch( from var(--gw-color-accent) calc(l + (0.6 - l) * 0.2) c h ); } :host([active]:not([appearance=\"accent\"])) .trigger { color: var(--gw-color-accent); border-color: var(--gw-color-accent); } /* Icon only, square, with the text kept for assistive technology */ :host([labels=\"hide\"]) .trigger.has-icon { padding: 0 calc(var(--gw-space-2) * var(--gw-size)); } :host([labels=\"hide\"]) .has-icon .label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; } @media (width < 40rem) { :host([labels=\"auto\"]) .trigger.has-icon { padding: 0 calc(var(--gw-space-2) * var(--gw-size)); } :host([labels=\"auto\"]) .has-icon .label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; } } .chevron { width: 0.4rem; height: 0.4rem; margin-inline-start: var(--gw-space-1); border-inline-end: 1.5px solid currentColor; border-block-end: 1.5px solid currentColor; rotate: 45deg; translate: 0 -0.125rem; transition: rotate var(--gw-motion-normal) var(--gw-motion-easing), translate var(--gw-motion-normal) var(--gw-motion-easing); } .trigger[aria-expanded=\"true\"] .chevron { rotate: 225deg; translate: 0 0.125rem; } [popover] { position-anchor: --gw-menu; position-try-fallbacks: flip-block, flip-inline; inset: auto; top: anchor(bottom); left: anchor(left); box-sizing: border-box; min-width: 15rem; max-height: min(24rem, 60vh); padding: 0; margin: var(--gw-space-1) 0 0; overflow: hidden; color: var(--gw-color-text-primary); background: var(--gw-color-surface-overlay); border: max(var(--gw-border-width), 1px) solid var(--gw-color-border-normal); border-radius: var(--gw-radius-l); box-shadow: var(--gw-shadow-m); opacity: 0; translate: 0 -0.25rem; transition: opacity var(--gw-motion-fast) var(--gw-motion-easing), translate var(--gw-motion-normal) var(--gw-motion-easing), display var(--gw-motion-normal) allow-discrete, overlay var(--gw-motion-normal) allow-discrete; } [popover]:popover-open { display: flex; flex-direction: column; opacity: 1; translate: 0 0; } @starting-style { [popover]:popover-open { opacity: 0; translate: 0 -0.25rem; } } /* The items scroll; the actions stay put below them, so \"Add\" is always in reach rather than at the end of a long list */ .items, .actions { display: flex; flex-direction: column; gap: var(--gw-space-0-5); padding: var(--gw-space-1); } .items { flex: 1; min-height: 0; overflow-y: auto; } .actions { border-block-start: max(var(--gw-border-width), 1px) solid var(--gw-color-border-normal); } .empty { padding: var(--gw-space-3); margin: 0; font-size: var(--gw-font-size-s); color: var(--gw-color-text-secondary); } .item { display: flex; gap: var(--gw-space-3); align-items: center; box-sizing: border-box; min-height: 2.5rem; padding: var(--gw-space-2) var(--gw-space-3); font: inherit; font-size: var(--gw-font-size-s); color: var(--gw-color-text-primary); text-align: start; cursor: pointer; background: transparent; border: 0; border-radius: var(--gw-radius-m); transition: background-color var(--gw-motion-fast) var(--gw-motion-easing); --gw-icon-size: 1.125rem; } .item:hover, .item:focus-visible { background: var(--gw-color-fill-neutral-hovered); outline: none; } .item:focus-visible { box-shadow: inset 0 0 0 var(--gw-focus-width) var(--gw-color-focus); } .item:disabled { color: var(--gw-color-text-disabled); cursor: not-allowed; background: transparent; } .action { font-weight: var(--gw-font-weight-strong); color: var(--gw-color-accent); } /* Holds the tick's place on every choice, so the labels line up */ .tick { flex: none; width: var(--gw-icon-size); height: var(--gw-icon-size); color: var(--gw-color-accent); } .item[aria-checked=\"false\"] .tick { visibility: hidden; } .separator { flex: none; height: 0; margin: var(--gw-space-0-5) calc(-1 * var(--gw-space-1)); border: 0; border-block-start: max(var(--gw-border-width), 1px) solid var(--gw-color-border-normal); } .text { display: flex; flex-direction: column; gap: var(--gw-space-0-5); } .description { font-size: var(--gw-font-size-xs); color: var(--gw-color-text-secondary); } `, ]",
|
|
10385
10385
|
"inheritedFrom": {
|
|
10386
10386
|
"name": "GwElement",
|
|
10387
10387
|
"module": "src/element.ts"
|
|
@@ -10446,6 +10446,15 @@
|
|
|
10446
10446
|
},
|
|
10447
10447
|
"default": "\"medium\""
|
|
10448
10448
|
},
|
|
10449
|
+
{
|
|
10450
|
+
"kind": "field",
|
|
10451
|
+
"name": "appearance",
|
|
10452
|
+
"type": {
|
|
10453
|
+
"text": "\"accent\" | \"filled\" | \"outlined\" | \"plain\""
|
|
10454
|
+
},
|
|
10455
|
+
"description": "How the trigger is drawn: a neutral fill, or as a neutral `gw-button` of that appearance.",
|
|
10456
|
+
"default": "\"filled\""
|
|
10457
|
+
},
|
|
10449
10458
|
{
|
|
10450
10459
|
"kind": "field",
|
|
10451
10460
|
"name": "active",
|
|
@@ -10939,6 +10948,13 @@
|
|
|
10939
10948
|
"description": "The trigger's size, 24 to 56px tall. Defaults to `medium`.",
|
|
10940
10949
|
"name": "size"
|
|
10941
10950
|
},
|
|
10951
|
+
{
|
|
10952
|
+
"type": {
|
|
10953
|
+
"text": "\"accent\"|\"filled\"|\"outlined\"|\"plain\""
|
|
10954
|
+
},
|
|
10955
|
+
"description": "How the trigger is drawn: `filled` is a neutral fill with a border, and the others match a neutral `gw-button` of that appearance, so it sits in a row of them. Defaults to `filled`.",
|
|
10956
|
+
"name": "appearance"
|
|
10957
|
+
},
|
|
10942
10958
|
{
|
|
10943
10959
|
"type": {
|
|
10944
10960
|
"text": "boolean"
|
package/package.json
CHANGED
package/src/gw-menu-button.ts
CHANGED
|
@@ -53,6 +53,7 @@ const tick = "M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z";
|
|
|
53
53
|
* @attr {MenuItem[]} items - The items, as JSON.
|
|
54
54
|
* @attr {MenuItem[]} actions - Actions pinned under the items, as JSON.
|
|
55
55
|
* @attr {"xs"|"small"|"medium"|"large"|"xl"} size - The trigger's size, 24 to 56px tall. Defaults to `medium`.
|
|
56
|
+
* @attr {"accent"|"filled"|"outlined"|"plain"} appearance - How the trigger is drawn: `filled` is a neutral fill with a border, and the others match a neutral `gw-button` of that appearance, so it sits in a row of them. Defaults to `filled`.
|
|
56
57
|
* @attr {boolean} active - Marks the trigger as set, such as a grouping that's on, with an accent border and text.
|
|
57
58
|
* @attr {"show"|"hide"|"auto"} labels - Whether the trigger's text shows beside its icon: always, never, or not on narrow screens. Defaults to `show`.
|
|
58
59
|
*
|
|
@@ -72,6 +73,7 @@ export class GwMenuButton extends GwElement {
|
|
|
72
73
|
items: { type: "json" },
|
|
73
74
|
actions: { type: "json" },
|
|
74
75
|
size: { reflect: true },
|
|
76
|
+
appearance: { reflect: true },
|
|
75
77
|
active: { type: "boolean", reflect: true },
|
|
76
78
|
labels: { reflect: true },
|
|
77
79
|
} as const;
|
|
@@ -114,7 +116,49 @@ export class GwMenuButton extends GwElement {
|
|
|
114
116
|
background: var(--gw-color-fill-neutral-hovered);
|
|
115
117
|
}
|
|
116
118
|
|
|
117
|
-
|
|
119
|
+
/* The other appearances draw the trigger as gw-button draws a neutral
|
|
120
|
+
one, a pill, so it sits in a row of buttons without a seam */
|
|
121
|
+
:host([appearance="accent"]) .trigger,
|
|
122
|
+
:host([appearance="outlined"]) .trigger,
|
|
123
|
+
:host([appearance="plain"]) .trigger {
|
|
124
|
+
background: transparent;
|
|
125
|
+
border: max(var(--gw-border-width), 1px) solid transparent;
|
|
126
|
+
border-radius: var(--gw-radius-pill);
|
|
127
|
+
transition:
|
|
128
|
+
background-color var(--gw-motion-fast) var(--gw-motion-easing),
|
|
129
|
+
border-color var(--gw-motion-fast) var(--gw-motion-easing),
|
|
130
|
+
color var(--gw-motion-fast) var(--gw-motion-easing);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
:host([appearance="outlined"]) .trigger {
|
|
134
|
+
border-color: var(--gw-color-text-secondary);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
:host([appearance="outlined"]) .trigger:hover,
|
|
138
|
+
:host([appearance="plain"]) .trigger:hover {
|
|
139
|
+
background: color-mix(
|
|
140
|
+
in oklch,
|
|
141
|
+
var(--gw-color-text-secondary) 16%,
|
|
142
|
+
transparent
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/* A solid fill, with text that flips between black and white by the
|
|
147
|
+
fill's lightness, as gw-button's accent does */
|
|
148
|
+
:host([appearance="accent"]) .trigger {
|
|
149
|
+
color: oklch(
|
|
150
|
+
from var(--gw-color-accent) clamp(0, (0.66 - l) * 1000, 1) 0 0
|
|
151
|
+
);
|
|
152
|
+
background: var(--gw-color-accent);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
:host([appearance="accent"]) .trigger:hover {
|
|
156
|
+
background: oklch(
|
|
157
|
+
from var(--gw-color-accent) calc(l + (0.6 - l) * 0.2) c h
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
:host([active]:not([appearance="accent"])) .trigger {
|
|
118
162
|
color: var(--gw-color-accent);
|
|
119
163
|
border-color: var(--gw-color-accent);
|
|
120
164
|
}
|
|
@@ -320,6 +364,8 @@ export class GwMenuButton extends GwElement {
|
|
|
320
364
|
declare items: readonly MenuItem[];
|
|
321
365
|
declare actions: readonly MenuItem[];
|
|
322
366
|
declare size: "xs" | "small" | "medium" | "large" | "xl";
|
|
367
|
+
/** How the trigger is drawn: a neutral fill, or as a neutral `gw-button` of that appearance. */
|
|
368
|
+
declare appearance: "accent" | "filled" | "outlined" | "plain";
|
|
323
369
|
/** Marks the trigger as set, such as a grouping that's on. */
|
|
324
370
|
declare active: boolean;
|
|
325
371
|
/** Whether the trigger's text shows beside its icon: always, never, or not on narrow screens. */
|
|
@@ -366,6 +412,7 @@ export class GwMenuButton extends GwElement {
|
|
|
366
412
|
this.items = [];
|
|
367
413
|
this.actions = [];
|
|
368
414
|
this.size = "medium";
|
|
415
|
+
this.appearance = "filled";
|
|
369
416
|
this.active = false;
|
|
370
417
|
this.labels = "show";
|
|
371
418
|
}
|