swarm-ui: delete StatusChip, migrate its 3 callers to shared Badge
mara: non-interactive Badge and StatusChip render identically (same padding/radius/font, same tone-to-color mapping) and StatusChip's 4-tone/single-label shape is a strict subset of Badge's — no real reason to keep both. Deletes StatusChip.tsx/.css, migrates AgentsPage's config-PR chip, HivesPage's freshness chip, and ComponentsPage's own table-status sample to Badge (tone/value, no onClick). Also drops the now-redundant standalone StatusChip demo section on /components (the Badge section already covers all 4 former chip tones plus accent). Updated the two stale StatusChip references outside swarm-ui too: design-guide.md's component-list example and colors.css's WCAG- contrast-rationale comment.
This commit is contained in:
parent
62cc0620c8
commit
638e1ac2c6
8 changed files with 19 additions and 76 deletions
|
|
@ -21,6 +21,7 @@
|
|||
import { useState } from 'preact/hooks';
|
||||
import { ApiErrorPanel } from '@hive/shared/api-error-panel.js';
|
||||
import { readApiError, type ProblemDetails } from '@hive/shared/api-error.js';
|
||||
import { Badge } from '@hive/shared/badge.js';
|
||||
import { Button } from '../ui/button/Button.js';
|
||||
import { Dialog } from '../ui/dialog/Dialog.js';
|
||||
import { Panel } from '../ui/panel/Panel.js';
|
||||
|
|
@ -29,7 +30,6 @@ import {
|
|||
useRefreshInterval,
|
||||
type RefreshIntervalMs,
|
||||
} from '../ui/refresh-interval/RefreshInterval.js';
|
||||
import { StatusChip } from '../ui/status-chip/StatusChip.js';
|
||||
import { Table, type TableColumn } from '../ui/table/Table.js';
|
||||
import { CreateAgentForm } from './CreateAgentForm.js';
|
||||
|
||||
|
|
@ -50,9 +50,9 @@ const COLUMNS: TableColumn<AgentRow>[] = [
|
|||
header: 'config PR',
|
||||
render: (a) =>
|
||||
a.configPr ? (
|
||||
<StatusChip
|
||||
<Badge
|
||||
tone="warning"
|
||||
label={
|
||||
value={
|
||||
a.configPr.html_url ? (
|
||||
<a href={a.configPr.html_url} target="_blank" rel="noreferrer">
|
||||
#{a.configPr.pr_number}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ import type { ComponentChildren } from 'preact';
|
|||
import { Panel } from '../ui/panel/Panel.js';
|
||||
import { RelativeTime } from '../ui/relative-time/RelativeTime.js';
|
||||
import { RefreshIntervalPicker, type RefreshIntervalMs } from '../ui/refresh-interval/RefreshInterval.js';
|
||||
import { StatusChip, type ChipTone } from '../ui/status-chip/StatusChip.js';
|
||||
import { Table, type TableColumn } from '../ui/table/Table.js';
|
||||
import { TextField } from '../ui/text-field/TextField.js';
|
||||
import { SelectField, type SelectOption } from '../ui/select-field/SelectField.js';
|
||||
|
|
@ -37,8 +36,6 @@ function Sample({ label, children }: { label: string; children: ComponentChildre
|
|||
);
|
||||
}
|
||||
|
||||
const CHIP_TONES: ChipTone[] = ['neutral', 'positive', 'warning', 'negative'];
|
||||
|
||||
interface Row {
|
||||
name: string;
|
||||
detail: string;
|
||||
|
|
@ -47,7 +44,7 @@ interface Row {
|
|||
const TABLE_COLUMNS: TableColumn<Row>[] = [
|
||||
{ key: 'name', header: 'name', render: (r) => r.name },
|
||||
{ key: 'detail', header: 'detail', render: (r) => r.detail },
|
||||
{ key: 'status', header: 'status', render: () => <StatusChip tone="positive" label="ok" /> },
|
||||
{ key: 'status', header: 'status', render: () => <Badge tone="positive" value="ok" /> },
|
||||
];
|
||||
|
||||
const TABLE_ROWS: Row[] = [
|
||||
|
|
@ -170,16 +167,6 @@ export function ComponentsPage() {
|
|||
</Sample>
|
||||
</Section>
|
||||
|
||||
<Section title="StatusChip">
|
||||
<div class="components-chip-row">
|
||||
{CHIP_TONES.map((tone) => (
|
||||
<Sample key={tone} label={tone}>
|
||||
<StatusChip tone={tone} label={tone} />
|
||||
</Sample>
|
||||
))}
|
||||
</div>
|
||||
</Section>
|
||||
|
||||
<Section title="Table">
|
||||
<Sample label="populated">
|
||||
<Table columns={TABLE_COLUMNS} rows={TABLE_ROWS} rowKey={(r) => r.name} />
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@
|
|||
import { useState } from 'preact/hooks';
|
||||
import { ApiErrorPanel } from '@hive/shared/api-error-panel.js';
|
||||
import { readApiError, type ProblemDetails } from '@hive/shared/api-error.js';
|
||||
import { Badge, type BadgeTone } from '@hive/shared/badge.js';
|
||||
import { Panel } from '../ui/panel/Panel.js';
|
||||
import { RelativeTime } from '../ui/relative-time/RelativeTime.js';
|
||||
import {
|
||||
|
|
@ -22,7 +23,6 @@ import {
|
|||
useRefreshInterval,
|
||||
type RefreshIntervalMs,
|
||||
} from '../ui/refresh-interval/RefreshInterval.js';
|
||||
import { StatusChip, type ChipTone } from '../ui/status-chip/StatusChip.js';
|
||||
import { Table, type TableColumn } from '../ui/table/Table.js';
|
||||
|
||||
type Freshness = 'fresh' | 'stale' | 'never_reported' | 'unknown';
|
||||
|
|
@ -41,7 +41,7 @@ interface HiveStatus {
|
|||
// One tone + label per freshness value. `unknown` (reporting but absent
|
||||
// from the roster) reads `negative` — it's the one case this endpoint
|
||||
// cannot vouch for at all, per `status.rs`'s doc comment.
|
||||
const FRESHNESS: Record<Freshness, { tone: ChipTone; label: string }> = {
|
||||
const FRESHNESS: Record<Freshness, { tone: BadgeTone; label: string }> = {
|
||||
fresh: { tone: 'positive', label: 'fresh' },
|
||||
stale: { tone: 'warning', label: 'stale' },
|
||||
never_reported: { tone: 'neutral', label: 'never reported' },
|
||||
|
|
@ -68,9 +68,9 @@ const COLUMNS: TableColumn<HiveStatus>[] = [
|
|||
render: (h) => {
|
||||
const { tone, label } = FRESHNESS[h.freshness];
|
||||
return (
|
||||
<StatusChip
|
||||
<Badge
|
||||
tone={tone}
|
||||
label={
|
||||
value={
|
||||
h.last_seen_unix !== null ? (
|
||||
<>
|
||||
{label} (<RelativeTime epochMs={h.last_seen_unix * 1000} />)
|
||||
|
|
|
|||
Loading…
Reference in a new issue