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,47 +1,7 @@
/* The run list: one card per run, the head row a button that opens it. */
/* The run list: one card per run (`ui/expandable-card`). */
.ui-runs-list {
display: flex;
flex-direction: column;
gap: 0.75em;
margin-top: 1em;
}
.ui-runs-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-runs-head:focus-visible {
outline: 2px solid var(--purple);
outline-offset: 2px;
}
.ui-runs-title {
display: inline-flex;
align-items: baseline;
gap: 0.5em;
}
.ui-runs-meta {
color: var(--muted);
}
.ui-runs-head .ui-runs-meta {
flex-basis: 100%;
}
.ui-runs-body {
display: flex;
flex-direction: column;
gap: 0.6em;
margin-top: 0.5em;
}
.ui-runs-body p {
margin: 0;
}
.ui-runs-empty {
color: var(--muted);
}

View file

@ -7,7 +7,13 @@
import { useState } from "preact/hooks";
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 { ExternalLink } from "../../ui/external-link/ExternalLink.js";
import {
ExpandableCard,
ExpandableCardSkeleton,
} from "../../ui/expandable-card/ExpandableCard.js";
import { Hint } from "../../ui/hint/Hint.js";
import { Panel } from "../../ui/panel/Panel.js";
import {
RefreshIntervalPicker,
@ -38,55 +44,50 @@ function RunCard({
open: boolean;
onToggle: () => void;
}) {
const bodyId = `review-run-${run.id}`;
return (
<Card class="ui-runs-card">
<button
type="button"
class="ui-runs-head"
aria-expanded={open}
aria-controls={bodyId}
onClick={onToggle}
>
<span class="ui-runs-title">
<ExpandableCard
id={`review-run-${run.id}`}
class="ui-runs-card"
open={open}
onToggle={onToggle}
metaOnOwnRow
title={
<>
<strong>
{run.repo} #{run.pr}
</strong>
{run.head_sha ? <code>{run.head_sha.slice(0, 7)}</code> : null}
</span>
</>
}
badge={
<Badge
tone={OUTCOME_TONE[run.outcome]}
value={OUTCOME_LABEL[run.outcome]}
/>
<span class="ui-runs-meta">
}
meta={
<>
{TRIGGER_LABEL[run.trigger]} ·{" "}
<RelativeTime epochMs={run.started_unix * 1000} /> · took{" "}
{durationLabel(run.started_unix, run.finished_unix)} ·{" "}
{classificationCount(run)}
</span>
</button>
{open ? (
<div class="ui-runs-body" id={bodyId}>
{run.detail ? <p class="ui-runs-detail">{run.detail}</p> : null}
{run.rows && run.rows.length > 0 ? (
<TryOutResult
result={run}
filterKey="swarm-ui:review-runs:table-filters"
/>
) : null}
{run.review_url ? (
<p class="ui-runs-link">
<a href={run.review_url} target="_blank" rel="noreferrer">
the posted review
</a>
</p>
) : null}
{run.requester ? (
<p class="ui-runs-meta">Requested by {run.requester}.</p>
) : null}
</div>
</>
}
>
{run.detail ? <p class="ui-runs-detail">{run.detail}</p> : null}
{run.rows && run.rows.length > 0 ? (
<TryOutResult
result={run}
filterKey="swarm-ui:review-runs:table-filters"
/>
) : null}
</Card>
{run.review_url ? (
<p class="ui-runs-link">
<ExternalLink href={run.review_url}>the posted review</ExternalLink>
</p>
) : null}
{run.requester ? <Hint>Requested by {run.requester}.</Hint> : null}
</ExpandableCard>
);
}
@ -136,9 +137,16 @@ export function ReviewRuns() {
<ApiErrorPanel context="the runs could not be loaded" problem={error} />
) : null}
{runs !== null && runs.length === 0 && !error ? (
<p class="ui-runs-empty">No runs yet.</p>
<EmptyState>No runs yet.</EmptyState>
) : null}
<div class="ui-runs-list">
{runs === null && !error ? (
<>
<ExpandableCardSkeleton metaOnOwnRow />
<ExpandableCardSkeleton metaOnOwnRow />
<ExpandableCardSkeleton metaOnOwnRow />
</>
) : null}
{(runs ?? []).map((run) => (
<RunCard
key={run.id}