Watch
0
0
Fork
You've already forked hyperhive
0

swarm-ui: shared Hint, ActionRow, Toolbar, EmptyState, ExternalLink and ExpandableCard replace per-page copies

Hint, ActionRow, Toolbar, EmptyState and ExternalLink replace the muted
text, button row, refresh bar, empty line and _blank anchor that each page
restyled under its own class. ExpandableCard (with a loading twin) holds the
builds and recent-runs cards, which had identical head and body CSS. The
create form's raw checkbox becomes CheckboxField. The components page shows
each new piece.
This commit is contained in:
iris 2026-11-06 17:54:24 +01:00 • committed by mara
commit 8a2e5203ad
2 changed files with 689 additions and 427 deletions

View file

@ -1,42 +1,10 @@
/* The build list: one card per build, the head row a button that opens it. */
/* The build list: one card per build (`ui/expandable-card`). */
.ui-builds-list {
display: flex;
flex-direction: column;
gap: 0.75em;
margin-top: 1em;
}
.ui-builds-head {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 0.5em 0.75em;
padding: 0;
border: 0;
background: none;
color: inherit;
font: inherit;
text-align: left;
cursor: pointer;
}
.ui-builds-head:focus-visible {
outline: 2px solid var(--purple);
outline-offset: 2px;
}
.ui-builds-title {
display: inline-flex;
align-items: baseline;
gap: 0.5em;
}
.ui-builds-meta {
color: var(--muted);
margin: 0;
}
.ui-builds-body {
display: flex;
flex-direction: column;
gap: 0.4em;
margin-top: 0.6em;
}
.ui-builds-text {
margin: 0;
overflow-wrap: anywhere;
@ -51,11 +19,3 @@
background: color-mix(in srgb, var(--crust) 60%, transparent);
font-size: 0.85em;
}
.ui-builds-empty {
color: var(--muted);
}
.ui-builds-refresh {
display: flex;
justify-content: flex-end;
margin-block-end: 0.5em;
}

View file

@ -9,7 +9,13 @@ import { useEffect, useRef, useState } from "preact/hooks";
import { useSearch } from "wouter-preact";
import { ApiErrorPanel } from "@hive/shared/api-error-panel.js";
import { Badge } from "@hive/shared/badge.js";
import { Card } from "../../ui/card/Card.js";
import { EmptyState } from "../../ui/empty-state/EmptyState.js";
import {
ExpandableCard,
ExpandableCardSkeleton,
} from "../../ui/expandable-card/ExpandableCard.js";
import { Hint } from "../../ui/hint/Hint.js";
import { Toolbar } from "../../ui/toolbar/Toolbar.js";
import { LazyDisclosure } from "../../ui/disclosure/LazyDisclosure.js";
import {
RefreshIntervalPicker,
@ -45,50 +51,44 @@ function BuildCard({
onToggle: () => void;
}) {
const body = bodyText(run);
const bodyId = `${cardId(run.id)}-body`;
return (
<Card class="ui-builds-card">
<div id={cardId(run.id)}>
<button
type="button"
class="ui-builds-head"
aria-expanded={open}
aria-controls={bodyId}
onClick={onToggle}
>
<span class="ui-builds-title">
<strong>{runTitle(run)}</strong>
<code>{run.head_sha.slice(0, 7)}</code>
</span>
<Badge
tone={OUTCOME_TONE[run.outcome]}
value={OUTCOME_LABEL[run.outcome]}
/>
<span class="ui-builds-meta">
<RelativeTime epochMs={run.started_unix * 1000} /> · took{" "}
{durationLabel(run.started_unix, run.finished_unix)}
</span>
</button>
{open ? (
<div class="ui-builds-body" id={bodyId}>
{body ? (
<>
<p class="ui-builds-meta">{body.label}</p>
{body.preformatted ? (
<pre class="ui-builds-tail">{body.text}</pre>
) : (
<p class="ui-builds-text">{body.text}</p>
)}
</>
) : (
<p class="ui-builds-meta">
nothing more was recorded for this build.
</p>
)}
</div>
) : null}
</div>
</Card>
<ExpandableCard
id={cardId(run.id)}
class="ui-builds-card"
open={open}
onToggle={onToggle}
title={
<>
<strong>{runTitle(run)}</strong>
<code>{run.head_sha.slice(0, 7)}</code>
</>
}
badge={
<Badge
tone={OUTCOME_TONE[run.outcome]}
value={OUTCOME_LABEL[run.outcome]}
/>
}
meta={
<>
<RelativeTime epochMs={run.started_unix * 1000} /> · took{" "}
{durationLabel(run.started_unix, run.finished_unix)}
</>
}
>
{body ? (
<>
<Hint>{body.label}</Hint>
{body.preformatted ? (
<pre class="ui-builds-tail">{body.text}</pre>
) : (
<p class="ui-builds-text">{body.text}</p>
)}
</>
) : (
<Hint>nothing more was recorded for this build.</Hint>
)}
</ExpandableCard>
);
}
@ -133,14 +133,14 @@ function BuildsBody() {
return (
<>
<div class="ui-builds-refresh">
<Toolbar>
<RefreshIntervalPicker
id="builds-refresh"
value={intervalMs}
onChange={setIntervalMs}
refreshing={refreshing}
/>
</div>
</Toolbar>
<p>
What the swarm builder built, newest first: agent config PR heads, and
the agents it builds from internal/meta before a deploy. How each ended,
@ -153,15 +153,22 @@ function BuildsBody() {
/>
) : null}
{missing ? (
<p class="ui-builds-meta" role="status">
<Hint role="status">
the build in this link is no longer listed: the builder keeps only its
newest builds.
</p>
</Hint>
) : null}
{runs !== null && runs.length === 0 && !error ? (
<p class="ui-builds-empty">No builds yet.</p>
<EmptyState>No builds yet.</EmptyState>
) : null}
<div class="ui-builds-list">
{runs === null && !error ? (
<>
<ExpandableCardSkeleton />
<ExpandableCardSkeleton />
<ExpandableCardSkeleton />
</>
) : null}
{(runs ?? []).map((run) => (
<BuildCard
key={run.id}