feat(webui): free-form draggable/resizable dashboard grid (phase 4)

The overview becomes a gridstack-backed free grid — drag, resize, and show/
hide 9 widgets (the 5 top stat tiles split out of the old single block, plus
connections/alerts/host/sessions), persisted to config/ui.json's
layout.overviewBlocks as {id,x,y,w,h,visible}.

- gridstack (zero-dep, vanilla; chosen over react-grid-layout whose
  react-draggable uses the React-19-removed findDOMNode). React renders each
  widget into a gridstack item via a portal (context flows through); gridstack
  owns layout/drag/resize. Per-widget minW/minH prevent content collapse.
- Desktop = editable in place; narrow screens = auto single-column, read-only.
  Fixed cellHeight => no ResizeObserver => the narrow column-clamp never
  persists over the desktop coords.
- Edit mode shows a panel: widget show/hide + nav reorder (the phase-3 motion
  list); the grid below is live-editable. Reset + empty-state preserved.
- Server UiLayoutItem gains optional x/y/w/h (clamped); the stats->5-tiles
  migration + default placement live client-side (lib/dashboard-layout.ts).

Verified across 2 adversarial review rounds (gridstack+React lifecycle traced
against the library source: StrictMode-safe, no mount-persist loop, no
re-init on coord change, no narrow-visit data loss).
This commit is contained in:
DrSmoothl committed 2026-06-13 21:17:23 +08:00
1 parent a5335687ec
commit f07f309c51
10 files changed
+532 -226

No files matched your search

+32
View File
@@ -215,3 +215,35 @@ html[data-reduce-motion="1"] *::after {
transition-duration: 0.01ms !important;
scroll-behavior: auto !important;
}
/* ──────────────────────────────────────────────
gridstack dashboard — mesh the library's item shell with our cards.
The widget content (a Card) owns its own bg/border/rounding, so the
gridstack content box is just a transparent, full-bleed container.
────────────────────────────────────────────── */
.grid-stack {
/* Negative inset cancels gridstack's per-item margin at the edges so the
grid lines up with surrounding page padding. */
background: transparent;
}
.grid-stack-item-content {
inset: 0;
overflow: visible;
background: transparent;
display: block;
}
/* The drag placeholder (drop target preview). */
.grid-stack > .grid-stack-placeholder > .placeholder-content {
border: 2px dashed var(--primary);
background: color-mix(in oklab, var(--primary) 8%, transparent);
border-radius: var(--radius);
}
/* Resize handle — only meaningful while editing (grid is interactive). */
.grid-stack-item > .ui-resizable-handle {
filter: none;
}
.grid-stack-item > .ui-resizable-se {
/* Make the bottom-right resize grip visible against either theme. */
border-right: 2px solid color-mix(in oklab, var(--primary) 70%, transparent);
border-bottom: 2px solid color-mix(in oklab, var(--primary) 70%, transparent);
}