Vue kit: compact styles the action variant only, tone is accent or danger, a disabled icon button dims; pin the inherited type

Co-authored-by: Manjunath Paparaju <[email protected]>
This commit is contained in:
Sameh KhamisandManjunath Paparaju committed 2026-11-18 23:51:16 -08:00
1 parent 4114ea1a05
commit 0d3c3325d4
7 files changed
+87 -27

No files matched your search

+9 -2
View File
@@ -14,7 +14,10 @@ import { vClassToggle } from '../rail/classToggle.js';
// action (action-button.css).
// - `icon` is the 22px square glyph button of a panel's collapse toggle
// (controls.css).
// A pressed action, primary or icon button looks as a hovered one does. Each
// A pressed action, primary or icon button looks as a hovered regular one
// does (a compact action's quieter hover is for an unpressed button); a
// disabled one dims and ignores hover and press. `size` styles the action
// variant only. Each
// resting rule selects one kit class, so a feature class loaded later still
// wins. Core adds `pressedClass`, its class on a pressed button (most
// toggles use `active`). The pressed classes toggle through `classList`, so
@@ -31,7 +34,11 @@ const props = defineProps({
['ghost', 'action', 'primary', 'icon'].includes(value),
},
/** `accent`, or `danger` for an action that destroys or stops. */
tone: { type: String, default: 'accent' },
tone: {
type: String,
default: 'accent',
validator: (value) => ['accent', 'danger'].includes(value),
},
/** `compact` for an action's smaller footprint. */
size: {
type: String,
+45 -8
View File
@@ -17,7 +17,15 @@ function rules(source) {
const prelude = match[1].split('}').pop().trim();
if (prelude.startsWith('@')) continue;
out.push({
selectors: prelude.split(',').map((s) => s.replace(/\s+/g, ' ').trim()),
selectors: prelude
.split(',')
.map((s) =>
s
.replace(/\s+/g, ' ')
.replace(/\( /g, '(')
.replace(/ \)/g, ')')
.trim(),
),
body: match[2],
});
}
@@ -55,13 +63,21 @@ test('UiButton variants wear Core’s action and icon skins', () => {
'.ui-button--primary:where(:not(:disabled))',
'#scene-panel .scene-btn-primary:not(:disabled)',
);
shares('.ui-button--compact', '.gev-action-button--compact');
shares(
'.ui-button--compact.ui-button--danger:hover:not(:disabled)',
'.ui-button--compact:where(.ui-button--action)',
'.gev-action-button--compact',
);
shares(
'.ui-button--compact:where(.ui-button--action):hover:not(:disabled):not(.ui-button--pressed)',
'.gev-action-button--compact:hover:not(:disabled)',
);
shares(
'.ui-button--compact.ui-button--danger:where(.ui-button--action):hover:not(:disabled)',
'.gev-action-button--compact.gev-action-button--danger:hover:not(:disabled)',
);
shares('.ui-button--icon', '.panel-collapse-btn');
shares('.ui-button--icon:hover', '.panel-collapse-btn:hover');
shares('.ui-button--icon:hover:not(:disabled)', '.panel-collapse-btn:hover');
assert.match(ruleWith('.ui-button--icon:disabled').body, /opacity:\s*0\.45/);
});
test('a pressed styled button looks as a hovered one does', () => {
@@ -77,13 +93,17 @@ test('a pressed styled button looks as a hovered one does', () => {
'.ui-button--action.ui-button--danger.ui-button--pressed:not(:disabled)',
'.gev-action-button--danger:hover:not(:disabled)',
);
shares('.ui-button--icon.ui-button--pressed', '.panel-collapse-btn:hover');
shares(
'.ui-button--icon.ui-button--pressed:not(:disabled)',
'.panel-collapse-btn:hover',
);
});
test('a ghost button and the tones alone carry no style', () => {
test('a ghost button, the tones and the size alone carry no style', () => {
const kitButton =
/\.ui-button(?:--(?:ghost|accent|danger|alert|pressed))?(?![\w-])/;
const look = /\.ui-button--(?:action|primary|icon|compact)(?![\w-])/;
/\.ui-button(?:--(?:ghost|accent|danger|pressed|compact))?(?![\w-])/;
// size="compact" styles the action variant only.
const look = /\.ui-button--(?:action|primary|icon)(?![\w-])/;
for (const rule of all)
for (const selector of rule.selectors)
assert.ok(
@@ -133,3 +153,20 @@ test('the kit’s skins load before the feature stylesheets that restyle them',
);
}
});
test('feature rules over a kit skin keep the type they inherit', () => {
// The chip and empty skins set a font and colour; these feature surfaces
// inherit theirs from the card or strip around them.
for (const [selector, property] of [
['.gev-voice-card-chip', /font:\s*inherit/],
['.scene-shot-empty', /font:\s*inherit/],
['.recent-imagery-readout .ri-strip-empty', /font:\s*inherit/],
['.recent-imagery-readout .ri-strip-empty', /color:\s*inherit/],
])
assert.ok(
all.some(
(rule) => rule.selectors.includes(selector) && property.test(rule.body),
),
`${selector} keeps ${property}`,
);
});