From bcb432caf47d47d68d1364af7d9cdfc6c457ce8f Mon Sep 17 00:00:00 2001 From: iris Date: Sat, 28 Nov 2026 02:42:53 +0100 Subject: [PATCH] swarm-ui: three press targets show a hover state The selection bar's link buttons, an expandable card's head and a toast all take the pointer cursor and gave no other sign. The links underline on hover and focus, the head tints its title, and the toast darkens its border. --- .../src/pages/agents/SelectionBar.css | 4 +++ .../src/ui/expandable-card/ExpandableCard.css | 3 ++ .../packages/swarm-ui/src/ui/toast/Toast.css | 6 ++++ .../swarm-ui/test/hover-affordances.test.mjs | 31 +++++++++++++++++++ 4 files changed, 44 insertions(+) create mode 100644 frontend/packages/swarm-ui/test/hover-affordances.test.mjs diff --git a/frontend/packages/swarm-ui/src/pages/agents/SelectionBar.css b/frontend/packages/swarm-ui/src/pages/agents/SelectionBar.css index 907339bd9..4db99dde4 100644 --- a/frontend/packages/swarm-ui/src/pages/agents/SelectionBar.css +++ b/frontend/packages/swarm-ui/src/pages/agents/SelectionBar.css @@ -26,6 +26,10 @@ font: inherit; cursor: pointer; } +.agents-selection-link:hover:not(:disabled), +.agents-selection-link:focus-visible { + text-decoration: underline; +} .agents-selection-link:disabled { color: var(--muted); cursor: default; diff --git a/frontend/packages/swarm-ui/src/ui/expandable-card/ExpandableCard.css b/frontend/packages/swarm-ui/src/ui/expandable-card/ExpandableCard.css index 8208f2a81..9a5ee39a6 100644 --- a/frontend/packages/swarm-ui/src/ui/expandable-card/ExpandableCard.css +++ b/frontend/packages/swarm-ui/src/ui/expandable-card/ExpandableCard.css @@ -16,6 +16,9 @@ outline: 2px solid var(--purple); outline-offset: 2px; } +.ui-expandable-head:not(.ui-expandable-head-static):hover .ui-expandable-title { + color: var(--purple); +} /* The placeholder head is not a control. */ .ui-expandable-head-static { cursor: default; diff --git a/frontend/packages/swarm-ui/src/ui/toast/Toast.css b/frontend/packages/swarm-ui/src/ui/toast/Toast.css index f392220e1..c702ee77b 100644 --- a/frontend/packages/swarm-ui/src/ui/toast/Toast.css +++ b/frontend/packages/swarm-ui/src/ui/toast/Toast.css @@ -27,6 +27,12 @@ color: var(--fg); white-space: pre-wrap; } +/* The three sides that carry no tone: the left bar keeps its colour. */ +.ui-toast:hover { + border-top-color: var(--muted); + border-right-color: var(--muted); + border-bottom-color: var(--muted); +} .ui-toast-info { border-left-color: var(--cyan); } diff --git a/frontend/packages/swarm-ui/test/hover-affordances.test.mjs b/frontend/packages/swarm-ui/test/hover-affordances.test.mjs new file mode 100644 index 000000000..9f6e57ca0 --- /dev/null +++ b/frontend/packages/swarm-ui/test/hover-affordances.test.mjs @@ -0,0 +1,31 @@ +// Things that answer a press show it before it. Run by `npm test`: a control +// that takes the pointer cursor needs a hover state, or nothing says it is one. +import assert from "node:assert/strict"; +import { readFileSync } from "node:fs"; +import { test } from "node:test"; + +const read = (rel) => readFileSync(new URL(rel, import.meta.url), "utf8"); + +test("the selection bar's link buttons underline on hover and focus", () => { + assert.match( + read("../src/pages/agents/SelectionBar.css"), + /\.agents-selection-link:hover:not\(:disabled\),\s*\.agents-selection-link:focus-visible\s*\{\s*text-decoration:\s*underline/, + ); +}); + +test("an expandable card's head tints its title on hover, unless static", () => { + assert.match( + read("../src/ui/expandable-card/ExpandableCard.css"), + /\.ui-expandable-head:not\(\.ui-expandable-head-static\):hover \.ui-expandable-title\s*\{\s*color:\s*var\(--purple\)/, + ); +}); + +test("a toast, which dismisses on a click, darkens the sides that carry no tone", () => { + const css = read("../src/ui/toast/Toast.css"); + const rule = /\.ui-toast:hover\s*\{([^}]*)\}/.exec(css); + assert.ok(rule, "no hover rule"); + assert.match(rule[1], /border-top-color/); + assert.match(rule[1], /border-bottom-color/); + // The shorthand would repaint the left bar, which is the toast's tone. + assert.doesNotMatch(rule[1], /border-color|border-left/); +});