// — living style guide for every ui primitive this // package ships. One section per component, each mode it supports // rendered side by side with a caption naming the mode — so a visual // regression or a missing variant is obvious at a glance, and a new // primitive gets a section here the same day it's added. Sample data // only, no network calls — this page must render the same whether // swarm-controller's API is up or not. import { useState } from 'preact/hooks'; 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'; import { Button, type ButtonVariant } from '../ui/button/Button.js'; import './ComponentsPage.css'; function Section({ title, children }: { title: string; children: ComponentChildren }) { return (

{title}

{children}
); } function Sample({ label, children }: { label: string; children: ComponentChildren }) { return (
{label}
{children}
); } const CHIP_TONES: ChipTone[] = ['neutral', 'positive', 'warning', 'negative']; interface Row { name: string; detail: string; } const TABLE_COLUMNS: TableColumn[] = [ { key: 'name', header: 'name', render: (r) => r.name }, { key: 'detail', header: 'detail', render: (r) => r.detail }, { key: 'status', header: 'status', render: () => }, ]; const TABLE_ROWS: Row[] = [ { name: 'alpha', detail: 'sample row one' }, { name: 'beta', detail: 'sample row two' }, ]; const SELECT_OPTIONS: SelectOption[] = [ { value: 'alpha', label: 'alpha' }, { value: 'beta', label: 'beta' }, ]; const BUTTON_VARIANTS: ButtonVariant[] = ['primary', 'default']; // Controlled samples need their own state to actually type/select into — // module-level consts can't do that, hence these two small wrappers // rather than inline JSX in the page body below. function TextFieldSample() { const [value, setValue] = useState(''); return ; } function SelectFieldSample() { const [value, setValue] = useState('alpha'); return ( ); } function RefreshIntervalPickerSample() { const [value, setValue] = useState(30_000); return ; } export function ComponentsPage() { return (

Every primitive in src/ui/, shown in each mode it supports. Sample data only — nothing here calls the API.

panel body content panel body content, no title {}} />} > panel body content
{CHIP_TONES.map((tone) => ( ))}
r.name} />
r.name} />
{BUTTON_VARIANTS.map((variant) => ( ))}
); }