dashboard: action buttons use the swarm UI's button, with its danger tone and touch height
Button.css moves to @hive/shared, a rename from swarm-ui/src/ui/button/Button.css to shared/src/button/Button.css; the swarm UI's Button imports it from there and the dashboard imports it too. The dashboard's own .btn rules and its eleven per-action colour modifiers are gone: the bulk action buttons, the per-row purge and the selection bar's clear are ui-button, destroy and purge are ui-button-danger, and all of them have the 2.75em height the dashboard buttons were under. The form() and addBulkButton helpers take a tone (danger or default) in place of a btn-* class. The danger variant is the one the confirmations PR adds, identical, so the two merge in either order.
This commit is contained in:
parent
94dd24fa99
commit
16a5bff2b1
6 changed files with 26 additions and 140 deletions
|
|
@ -4,7 +4,7 @@
|
|||
// job-queue-rollup ops. See docs/4-implementation/web-ui/dashboard.md::Container row for the
|
||||
// rendering contract.
|
||||
|
||||
import { $, form, fmtAgeSecs } from "./common.js";
|
||||
import { $, buttonClass, form, fmtAgeSecs } from "./common.js";
|
||||
import { el } from "@hive/shared/dom.js";
|
||||
import { themedConfirm, themedToast } from "@hive/shared/modal.js";
|
||||
import { h, render } from "preact";
|
||||
|
|
@ -731,7 +731,7 @@ export function renderSelectionBar(containers) {
|
|||
return `${label} not available — ${blockers.join(", ")} ${blockers.length === 1 ? "is" : "are"} blocking it`;
|
||||
}
|
||||
|
||||
addBulkButton(actions, "btn-restart", "↺ R3ST4RT", allRunning, selected, {
|
||||
addBulkButton(actions, "default", "↺ R3ST4RT", allRunning, selected, {
|
||||
action: "/api/restart/",
|
||||
confirm: (names) =>
|
||||
`restart ${names.length} agent${names.length === 1 ? "" : "s"} (${names.join(", ")})?`,
|
||||
|
|
@ -743,7 +743,7 @@ export function renderSelectionBar(containers) {
|
|||
stoppedNames.map((n) => `\`${n}\` is stopped`),
|
||||
),
|
||||
});
|
||||
addBulkButton(actions, "btn-stop", "■ ST0P", allRunning, selected, {
|
||||
addBulkButton(actions, "default", "■ ST0P", allRunning, selected, {
|
||||
action: "/api/kill/",
|
||||
confirm: (names) =>
|
||||
`stop ${names.length} agent${names.length === 1 ? "" : "s"} (${names.join(", ")})?`,
|
||||
|
|
@ -754,7 +754,7 @@ export function renderSelectionBar(containers) {
|
|||
stoppedNames.map((n) => `\`${n}\` is already stopped`),
|
||||
),
|
||||
});
|
||||
addBulkButton(actions, "btn-start", "▶ ST4RT", allStopped, selected, {
|
||||
addBulkButton(actions, "default", "▶ ST4RT", allStopped, selected, {
|
||||
action: "/api/start/",
|
||||
confirm: (names) =>
|
||||
`start ${names.length} agent${names.length === 1 ? "" : "s"} (${names.join(", ")})?`,
|
||||
|
|
@ -763,7 +763,7 @@ export function renderSelectionBar(containers) {
|
|||
runningNames.map((n) => `\`${n}\` is already running`),
|
||||
),
|
||||
});
|
||||
addBulkButton(actions, "btn-pause", "⏸ P4US3", allUnpaused, selected, {
|
||||
addBulkButton(actions, "default", "⏸ P4US3", allUnpaused, selected, {
|
||||
action: "/api/pause/",
|
||||
confirm: (names) =>
|
||||
`pause ${names.length} agent${names.length === 1 ? "" : "s"} (${names.join(", ")})? parks the turn loop — inbox messages queue unacked.`,
|
||||
|
|
@ -772,7 +772,7 @@ export function renderSelectionBar(containers) {
|
|||
pausedNames.map((n) => `\`${n}\` is already paused`),
|
||||
),
|
||||
});
|
||||
addBulkButton(actions, "btn-resume", "▶ R3SUM3", allPaused, selected, {
|
||||
addBulkButton(actions, "default", "▶ R3SUM3", allPaused, selected, {
|
||||
action: "/api/resume/",
|
||||
confirm: (names) =>
|
||||
`resume ${names.length} agent${names.length === 1 ? "" : "s"} (${names.join(", ")})? the turn loop restarts and drains queued messages.`,
|
||||
|
|
@ -781,17 +781,17 @@ export function renderSelectionBar(containers) {
|
|||
unpausedNames.map((n) => `\`${n}\` is not paused`),
|
||||
),
|
||||
});
|
||||
addBulkButton(actions, "btn-rebuild", "↻ R3BU1LD", true, selected, {
|
||||
addBulkButton(actions, "default", "↻ R3BU1LD", true, selected, {
|
||||
action: "/api/rebuild/",
|
||||
confirm: (names) =>
|
||||
`rebuild ${names.length} agent${names.length === 1 ? "" : "s"} (${names.join(", ")})? hot-reloads each container.`,
|
||||
});
|
||||
addBulkButton(actions, "btn-destroy", "DESTR0Y", true, selected, {
|
||||
addBulkButton(actions, "danger", "DESTR0Y", true, selected, {
|
||||
action: "/api/destroy/",
|
||||
confirm: (names) =>
|
||||
`destroy ${names.length} agent${names.length === 1 ? "" : "s"} (${names.join(", ")})? containers are removed; state + creds kept.`,
|
||||
});
|
||||
addBulkButton(actions, "btn-destroy", "PURG3", true, selected, {
|
||||
addBulkButton(actions, "danger", "PURG3", true, selected, {
|
||||
action: "/api/destroy/",
|
||||
body: { purge: "on" },
|
||||
confirm: (names) =>
|
||||
|
|
@ -799,13 +799,13 @@ export function renderSelectionBar(containers) {
|
|||
});
|
||||
}
|
||||
|
||||
function addBulkButton(parent, btnClass, label, enabled, selected, opts) {
|
||||
function addBulkButton(parent, tone, label, enabled, selected, opts) {
|
||||
const names = selected.map((c) => c.name);
|
||||
const btn = el(
|
||||
"button",
|
||||
{
|
||||
type: "button",
|
||||
class: "btn " + btnClass,
|
||||
class: buttonClass(tone),
|
||||
},
|
||||
label,
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
/* Shared Catppuccin palette + body typography + terminal pane styles.
|
||||
Bundled in front of the page-specific rules via esbuild. */
|
||||
@import "@hive/shared/base.css";
|
||||
@import "@hive/shared/button.css";
|
||||
@import "@hive/shared/terminal.css";
|
||||
@import "@hive/shared/tabs.css";
|
||||
/* Shared pill/chip/badge shape (the "extract pill component" issue,
|
||||
|
|
@ -128,120 +129,6 @@ code {
|
|||
border-color: var(--amber);
|
||||
}
|
||||
|
||||
/* ─── buttons ───────────────────────────────────────────────────────
|
||||
.btn base + semantic colour/size modifiers. */
|
||||
.btn {
|
||||
font-family: inherit;
|
||||
font-weight: bold;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.1em;
|
||||
background: transparent;
|
||||
/* Strip browser UA button chrome (solid fill, system text colour).
|
||||
Without this, native <button> + <input type="submit"> elements
|
||||
ignore our background:transparent and colour in some browsers. */
|
||||
-webkit-appearance: none;
|
||||
appearance: none;
|
||||
border: 1px solid;
|
||||
padding: 0.25em 0.8em;
|
||||
cursor: pointer;
|
||||
text-shadow: 0 0 4px currentColor;
|
||||
box-shadow: 0 0 0 0 currentColor;
|
||||
transition: box-shadow 0.15s ease;
|
||||
}
|
||||
.btn:hover {
|
||||
background: color-mix(in srgb, var(--fg) 6%, transparent);
|
||||
text-shadow: 0 0 10px currentColor;
|
||||
box-shadow: 0 0 10px -2px currentColor;
|
||||
}
|
||||
.btn:disabled,
|
||||
.btn[disabled] {
|
||||
opacity: 0.32;
|
||||
cursor: not-allowed;
|
||||
text-shadow: none;
|
||||
box-shadow: none;
|
||||
}
|
||||
.btn:disabled:hover,
|
||||
.btn[disabled]:hover {
|
||||
background: transparent;
|
||||
text-shadow: none;
|
||||
box-shadow: none;
|
||||
}
|
||||
.btn-approve {
|
||||
color: var(--green);
|
||||
border-color: var(--green);
|
||||
}
|
||||
.btn-destroy {
|
||||
color: var(--red);
|
||||
border-color: var(--red);
|
||||
font-size: 0.75em;
|
||||
padding: 0.15em 0.5em;
|
||||
margin-left: 0.6em;
|
||||
}
|
||||
.btn-rebuild {
|
||||
color: var(--amber);
|
||||
border-color: var(--amber);
|
||||
font-size: 0.75em;
|
||||
padding: 0.15em 0.5em;
|
||||
margin-left: 0.6em;
|
||||
}
|
||||
.btn-restart {
|
||||
color: var(--cyan);
|
||||
border-color: var(--cyan);
|
||||
font-size: 0.75em;
|
||||
padding: 0.15em 0.5em;
|
||||
margin-left: 0.6em;
|
||||
}
|
||||
.btn-stop {
|
||||
color: var(--pink);
|
||||
border-color: var(--pink);
|
||||
font-size: 0.75em;
|
||||
padding: 0.15em 0.5em;
|
||||
margin-left: 0.6em;
|
||||
}
|
||||
.btn-start {
|
||||
color: var(--green);
|
||||
border-color: var(--green);
|
||||
font-size: 0.75em;
|
||||
padding: 0.15em 0.5em;
|
||||
margin-left: 0.6em;
|
||||
}
|
||||
/* Same yellow as .badge-paused (the paused-state pill) — pause enters
|
||||
that state, so the trigger and the resulting badge read as one
|
||||
colour, not two unrelated ones. Resume reads as green like
|
||||
.btn-start: both are "go" actions, back to the turn loop running. */
|
||||
.btn-pause {
|
||||
color: var(--yellow);
|
||||
border-color: var(--yellow);
|
||||
font-size: 0.75em;
|
||||
padding: 0.15em 0.5em;
|
||||
margin-left: 0.6em;
|
||||
}
|
||||
.btn-resume {
|
||||
color: var(--green);
|
||||
border-color: var(--green);
|
||||
font-size: 0.75em;
|
||||
padding: 0.15em 0.5em;
|
||||
margin-left: 0.6em;
|
||||
}
|
||||
/* M0V3 affordance (selection bar) — mauve reads as "structural
|
||||
change" rather than the destructive red / amber chrome of
|
||||
destroy / rebuild. See docs/4-implementation/web-ui/dashboard.md::Selection bar. */
|
||||
.btn-move {
|
||||
color: var(--purple);
|
||||
border-color: var(--purple);
|
||||
font-size: 0.75em;
|
||||
padding: 0.15em 0.5em;
|
||||
margin-left: 0.6em;
|
||||
}
|
||||
.btn-talk {
|
||||
color: var(--cyan);
|
||||
border-color: var(--cyan);
|
||||
}
|
||||
.btn-spawn {
|
||||
color: var(--amber);
|
||||
border-color: var(--amber);
|
||||
}
|
||||
|
||||
/* ─── page-content gutter ─────────────────────────────────────────────
|
||||
Inverted-gutter layout: the dashboard keeps `<body>` full-bleed
|
||||
and wraps their padded content in a single `.page-content` div that
|
||||
|
|
|
|||
|
|
@ -22,9 +22,17 @@ export const esc = (s) =>
|
|||
(c) => ({ "&": "&", "<": "<", ">": ">", '"': """ })[c],
|
||||
);
|
||||
|
||||
// An action button in the swarm UI's look (`@hive/shared/button.css`): the tone
|
||||
// is `"danger"` for an action that destroys, `"default"` for the rest. Any other
|
||||
// string is taken as the button's own classes, for the one pill-shaped control.
|
||||
export const buttonClass = (tone) =>
|
||||
tone === "danger" || tone === "default"
|
||||
? "ui-button ui-button-" + tone
|
||||
: tone;
|
||||
|
||||
export const form = (
|
||||
action,
|
||||
btnClass,
|
||||
tone,
|
||||
btnLabel,
|
||||
confirmMsg,
|
||||
extra = {},
|
||||
|
|
@ -45,7 +53,7 @@ export const form = (
|
|||
f.append(el("input", { type: "hidden", name, value }));
|
||||
}
|
||||
f.append(
|
||||
el("button", { type: "submit", class: "btn " + btnClass }, btnLabel),
|
||||
el("button", { type: "submit", class: buttonClass(tone) }, btnLabel),
|
||||
);
|
||||
return f;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -630,16 +630,6 @@ footer .banner-thin {
|
|||
gap: 0.4em;
|
||||
align-items: center;
|
||||
}
|
||||
.selection-actions .btn {
|
||||
font-size: 0.75em;
|
||||
padding: 0.2em 0.7em;
|
||||
}
|
||||
.selection-clear {
|
||||
color: var(--muted);
|
||||
border-color: var(--purple-dim);
|
||||
font-size: 0.75em;
|
||||
padding: 0.2em 0.7em;
|
||||
}
|
||||
/* Pad the dashboard body so the sticky bar doesn't cover the
|
||||
bottom of the agent list. Only applies when bar is visible. */
|
||||
body.dashboard-shell.has-selection {
|
||||
|
|
|
|||
|
|
@ -179,7 +179,7 @@
|
|||
<span class="selection-actions" id="selection-actions"></span>
|
||||
<button
|
||||
type="button"
|
||||
class="btn selection-clear"
|
||||
class="ui-button ui-button-default selection-clear"
|
||||
id="selection-clear"
|
||||
title="clear selection (esc)"
|
||||
>
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ export function renderKept() {
|
|||
actions.append(
|
||||
form(
|
||||
"/api/purge-tombstone/" + t.name,
|
||||
"btn-destroy",
|
||||
"danger",
|
||||
"PURG3",
|
||||
"PURGE " +
|
||||
t.name +
|
||||
|
|
|
|||
Loading…
Reference in a new issue