diff --git a/frontend/packages/swarm-ui/src/App.tsx b/frontend/packages/swarm-ui/src/App.tsx index 5430dffb..10598605 100644 --- a/frontend/packages/swarm-ui/src/App.tsx +++ b/frontend/packages/swarm-ui/src/App.tsx @@ -1,35 +1,34 @@ -// Root shell component. Empty start page for now — functionality -// (swarm roster, target-state view, whatever the swarm-controller -// epic eventually needs) is out of scope until auth against authelia -// is figured out. What's here IS in scope: a real router + deep-link -// shape that the per-hive dashboard's vanilla-JS + custom-element MPA -// doesn't have, so later work has a shell to land routes into instead -// of bolting routing on after the fact. +// Root shell component. Real route (`/`) is still a placeholder — the +// swarm's hive roster is the next piece of work to land into it — but +// it now mounts inside and uses the ui/ primitives, so that +// page lands as a content change, not a structural one. import { Route, Switch } from 'wouter-preact'; +import { Shell } from './shell/Shell.js'; +import { Panel } from './ui/Panel.js'; function Home() { return ( -
-

swarm ui

-

nothing here yet — project-bootstrap placeholder.

-
+ +

hive roster lands here, sequenced after this shell.

+
); } function NotFound() { return ( -
-

404

+

no route here.

-
+ ); } export function App() { return ( - - - - + + + + + + ); } diff --git a/frontend/packages/swarm-ui/src/shell/Shell.css b/frontend/packages/swarm-ui/src/shell/Shell.css new file mode 100644 index 00000000..4a6de52c --- /dev/null +++ b/frontend/packages/swarm-ui/src/shell/Shell.css @@ -0,0 +1,40 @@ +/* — header bar + nav row + the content column every route + renders into. Colour vars come from ../theme.css (same base16 slots + the per-hive dashboard uses, so this reads as recognizably + hyperhive) — the layout itself is this package's own, not + @hive/shared's chrome.css. */ +.shell-header { + display: flex; + align-items: center; + gap: 1.5em; + padding: 0.75em 1.25em; + border-bottom: 1px solid var(--border); + background: var(--bg-elev); +} +.shell-brand { + font-weight: 600; + color: var(--purple); + letter-spacing: 0.02em; +} +.shell-nav { + display: flex; + gap: 1em; +} +.shell-nav-link { + color: var(--muted); + text-decoration: none; + padding: 0.25em 0; + border-bottom: 2px solid transparent; +} +.shell-nav-link:hover { + color: var(--fg); +} +.shell-nav-link-active { + color: var(--fg); + border-bottom-color: var(--purple); +} +.shell-body { + max-width: 60em; + margin: 0 auto; + padding: 1.5em 1.25em; +} diff --git a/frontend/packages/swarm-ui/src/shell/Shell.tsx b/frontend/packages/swarm-ui/src/shell/Shell.tsx new file mode 100644 index 00000000..508d98f1 --- /dev/null +++ b/frontend/packages/swarm-ui/src/shell/Shell.tsx @@ -0,0 +1,41 @@ +// — page chrome every swarm-ui route mounts inside: a header +// bar (swarm branding) plus a nav row linking the app's real routes. +// Preact-native styling (shell/Shell.css, imported globally via +// ../swarm-ui.css) — deliberately not @hive/shared's chrome.css +// page-header pattern, which is the per-hive MPA dashboard's visual +// language. This package is a clean field, not an inheritor of that +// look. +// +// Route list lives here, not prop-drilled from App — one small SPA +// has exactly one place that needs to know its own nav, and this is +// it. Grows additively as real routes land (a swarm-wide agent roster +// is next); no speculative entries. +import type { ComponentChildren } from 'preact'; +import { Link, useRoute } from 'wouter-preact'; + +const NAV_ITEMS: { href: string; label: string }[] = [{ href: '/', label: 'overview' }]; + +function NavLink({ href, label }: { href: string; label: string }) { + const [active] = useRoute(href); + return ( + + {label} + + ); +} + +export function Shell({ children }: { children: ComponentChildren }) { + return ( +
+
+ hyperhive swarm + +
+
{children}
+
+ ); +} diff --git a/frontend/packages/swarm-ui/src/swarm-ui.css b/frontend/packages/swarm-ui/src/swarm-ui.css index 43134567..c5bc4cdf 100644 --- a/frontend/packages/swarm-ui/src/swarm-ui.css +++ b/frontend/packages/swarm-ui/src/swarm-ui.css @@ -1,12 +1,5 @@ @import "@hive/shared/base.css"; - -/* Bootstrap placeholder only — real layout comes with the first - route that actually needs one. */ -.swarm-ui-empty { - max-width: 40em; - margin: 4em auto; - padding: 0 1em; -} -.swarm-ui-empty h1 { - color: var(--purple); -} +@import "./shell/Shell.css"; +@import "./ui/Panel.css"; +@import "./ui/StatusChip.css"; +@import "./ui/Table.css"; diff --git a/frontend/packages/swarm-ui/src/ui/Panel.css b/frontend/packages/swarm-ui/src/ui/Panel.css new file mode 100644 index 00000000..23a40980 --- /dev/null +++ b/frontend/packages/swarm-ui/src/ui/Panel.css @@ -0,0 +1,15 @@ +.ui-panel { + border: 1px solid var(--border); + border-radius: 0.5em; + background: var(--bg-elev); +} +.ui-panel-title { + margin: 0; + padding: 0.75em 1em; + font-size: 1em; + font-weight: 600; + border-bottom: 1px solid var(--border); +} +.ui-panel-body { + padding: 1em; +} diff --git a/frontend/packages/swarm-ui/src/ui/Panel.tsx b/frontend/packages/swarm-ui/src/ui/Panel.tsx new file mode 100644 index 00000000..8998a1e8 --- /dev/null +++ b/frontend/packages/swarm-ui/src/ui/Panel.tsx @@ -0,0 +1,14 @@ +// — the one generic container primitive every route needs: a +// bordered surface with an optional title, no other opinions. Not a +// card-with-actions/footer/whatever kit — those get added the first +// time a real page actually needs one, not speculatively ahead of it. +import type { ComponentChildren } from 'preact'; + +export function Panel({ title, children }: { title?: string; children: ComponentChildren }) { + return ( +
+ {title ?

{title}

: null} +
{children}
+
+ ); +} diff --git a/frontend/packages/swarm-ui/src/ui/StatusChip.css b/frontend/packages/swarm-ui/src/ui/StatusChip.css new file mode 100644 index 00000000..c6908552 --- /dev/null +++ b/frontend/packages/swarm-ui/src/ui/StatusChip.css @@ -0,0 +1,21 @@ +.ui-chip { + display: inline-block; + padding: 0.15em 0.6em; + border-radius: 1em; + font-size: 0.85em; + line-height: 1.4; + background: var(--purple-dim); + color: var(--fg); +} +.ui-chip-neutral { + color: var(--muted); +} +.ui-chip-positive { + color: var(--green); +} +.ui-chip-warning { + color: var(--amber); +} +.ui-chip-negative { + color: var(--red); +} diff --git a/frontend/packages/swarm-ui/src/ui/StatusChip.tsx b/frontend/packages/swarm-ui/src/ui/StatusChip.tsx new file mode 100644 index 00000000..d83ad6b8 --- /dev/null +++ b/frontend/packages/swarm-ui/src/ui/StatusChip.tsx @@ -0,0 +1,11 @@ +// — a small labelled state indicator. Generic over +// `tone` rather than a fixed status vocabulary (`online`/`offline`/…) +// because the first real caller (the hive roster) starts with a +// single static "configured" tone and grows real online/stale/offline +// states once a status rollup lands server-side — same component, +// richer data later, no rebuild. +export type ChipTone = 'neutral' | 'positive' | 'warning' | 'negative'; + +export function StatusChip({ tone = 'neutral', label }: { tone?: ChipTone; label: string }) { + return {label}; +} diff --git a/frontend/packages/swarm-ui/src/ui/Table.css b/frontend/packages/swarm-ui/src/ui/Table.css new file mode 100644 index 00000000..f990dae6 --- /dev/null +++ b/frontend/packages/swarm-ui/src/ui/Table.css @@ -0,0 +1,18 @@ +.ui-table { + width: 100%; + border-collapse: collapse; +} +.ui-table th { + text-align: left; + font-weight: 600; + color: var(--muted); + padding: 0.5em 0.75em; + border-bottom: 1px solid var(--border); +} +.ui-table td { + padding: 0.5em 0.75em; + border-bottom: 1px solid var(--border); +} +.ui-table tr:last-child td { + border-bottom: none; +} diff --git a/frontend/packages/swarm-ui/src/ui/Table.tsx b/frontend/packages/swarm-ui/src/ui/Table.tsx new file mode 100644 index 00000000..402953a7 --- /dev/null +++ b/frontend/packages/swarm-ui/src/ui/Table.tsx @@ -0,0 +1,43 @@ +// — a generic column-defined table, the shape the hive roster +// (name / domain / status chip, one row per hive) needs. Columns own +// their own cell rendering rather than this component knowing about +// any particular row shape, so it stays reusable for the swarm-wide +// agent roster later without a rewrite. +import type { ComponentChildren } from 'preact'; + +export interface TableColumn { + key: string; + header: string; + render: (row: T) => ComponentChildren; +} + +export function Table({ + columns, + rows, + rowKey, +}: { + columns: TableColumn[]; + rows: T[]; + rowKey: (row: T) => string; +}) { + return ( +
+ + + {columns.map((c) => ( + + ))} + + + + {rows.map((row) => ( + + {columns.map((c) => ( + + ))} + + ))} + +
{c.header}
{c.render(row)}
+ ); +}