Rework the dashboard into two looks over one behaviour

A dashboard is a wall panel somebody hangs in their own hallway, so it
now wears what they choose: a look, and a palette of their own colours.

Two complete component sets live under `Dashboard/ui/` — `glass`
(translucent panes over a slowly moving ground) and `material` (Material
3 tonal cards) — behind one prop contract. Every control's state,
keyboard and `aria-` live in `ui/core` and are shared, so the two sets
are the same dashboard drawn twice rather than two products: a set only
decides what a control looks like while doing it.

Four settings join the channel, each drivable by a flow like any other:
`look`, `palette`, `background` and `touch`. A palette is an ordered list
of hex colours — background, surface, primary, accent, text, then more
chart colours — pasted from a coolors.co link or typed, written onto the
canvas as the token variables everything already reads. Trailing roles
are derived, so three colours are a whole dashboard, and derived text is
held to AA rather than trusted (`theme.check.ts` measures it). A palette
also decides light or dark, since its first colour is the ground.

Widgets are measured against their own tile with container queries rather
than against the viewport, animate through `motion`, and can be drawn
without their title. The three reworks:

- a bar draws a row per reading, up to eight, each in the dashboard's own
  data colours and each able to carry its own scale — replacing readings
  nested in one fill, which could only ever share one colour and stop at
  three. Documents written the old way are read as rows.
- a chart's range picker moved to a column down its right-hand edge, which
  gives the plot back a whole row of a short tile.
- the colour wheel became a disc: hue is the angle and saturation the
  distance from the middle, so a colour is one gesture rather than three,
  with brightness on a slider beside it.

`index.css` and `lib/motion.ts` are untouched — the dashboard overrides
token *values* on its canvas, never the blocks the two repos share.
This commit is contained in:
2026-08-23 21:52:14 +02:00
parent 7c6e655e17
commit acae48ddb6
52 changed files with 5517 additions and 1568 deletions
@@ -78,18 +78,56 @@ import {
usePublishDashboard,
useSaveDashboard,
} from "./queries"
import { PaletteProvider, useDashboardTheme } from "./settings"
import { PaletteProvider } from "./settings"
import { useUi } from "./ui"
import { showTitle } from "./ui/core/config"
import { LookProvider, useCanvasRoot } from "./ui/core/look"
import {
WIDGET_LABELS,
WIDGET_SIZES,
WidgetBody,
WidgetFrame,
type WidgetKind,
widgetIssue,
} from "./widgets"
const KINDS = Object.keys(WIDGET_LABELS) as WidgetKind[]
/**
* A widget as the editor draws it: the panel's own look, plus a click that
* picks it.
*
* Its own component because it draws with the look's components, which are
* only knowable below `LookProvider`.
*/
function Pickable({
widget,
dashboard,
grip,
selected,
onPick,
}: {
widget: WidgetDef
dashboard: string
grip: boolean
selected: boolean
onPick: () => void
}) {
const { Frame } = useUi()
return (
<Frame
title={showTitle(widget) ? widget.title : undefined}
issue={widgetIssue(widget)}
grip={grip}
selected={selected}
onClick={(event) => {
if (!(event.target as Element).closest(INTERACTIVE)) onPick()
}}
>
<WidgetBody widget={widget} dashboard={dashboard} />
</Frame>
)
}
/** How long to sit on edits before saving, so typing is not a save per key. */
const AUTOSAVE_MS = 800
@@ -212,10 +250,10 @@ export function DashboardEditor({
// A phone reads the dashboard rather than arranges it, so the grid library
// never mounts there. See DESIGN-GUIDELINES.md → Responsive.
const stacked = useIsMobile()
// The dashboard's own theme, on the surface only: the shell around the
// The dashboard's own appearance, on the surface only: the shell around the
// canvas stays whatever the person editing chose for the app. Non-stacked,
// `CanvasSurface` states it on the canvas box itself.
const theme = useDashboardTheme(draft)
const root = useCanvasRoot(draft)
const navigate = useNavigate()
const queryClient = useQueryClient()
const save = useSaveDashboard(dashboard.name)
@@ -414,28 +452,16 @@ export function DashboardEditor({
/** A widget that can be picked to open its settings. */
const pickable = (widget: WidgetDef, grip = false) => (
<WidgetFrame
title={widget.title}
issue={widgetIssue(widget)}
className={cn(
"cursor-pointer",
// Drawn inwards: the canvas is clipped to the panel's exact pixel
// size, so an outward ring on a widget sitting in column 0 or row 0
// is cut off on that side. The border takes the same colour so the
// edge reads as one line rather than a grey seam around the ring.
widget.id === selected &&
"border-primary ring-2 ring-inset ring-primary",
)}
<Pickable
widget={widget}
dashboard={draft.name}
grip={grip}
onClick={(event) => {
if (!(event.target as Element).closest(INTERACTIVE)) {
setSettingsOpen(false)
setSelected(widget.id)
}
selected={widget.id === selected}
onPick={() => {
setSettingsOpen(false)
setSelected(widget.id)
}}
>
<WidgetBody widget={widget} dashboard={draft.name} />
</WidgetFrame>
/>
)
const body = !page ? (
@@ -450,10 +476,14 @@ export function DashboardEditor({
// One column at the viewport's width. Edit mode still picks a widget and
// opens its settings; only the arrangement is missing.
<div
data-look={root["data-look"]}
data-touch={root["data-touch"]}
data-palette={root["data-palette"]}
className={cn(
"h-full overflow-y-auto bg-background text-foreground",
theme,
root.className,
)}
style={root.style}
>
<DashboardView
dashboard={draft}
@@ -503,7 +533,7 @@ export function DashboardEditor({
)
return (
<>
<LookProvider dashboard={draft}>
{railDashboards && !stacked ? (
<PanelRail
dashboards={railDashboards}
@@ -802,6 +832,6 @@ export function DashboardEditor({
</Dialog>
</>
) : null}
</>
</LookProvider>
)
}