Draw the panel as a panel
Five things a wall panel showed that a wall panel should not. **A tile's body no longer clips.** It scrolled, and a box that scrolls also cuts whatever crosses its edge — which took the glow off a lit button at exactly the width where the button filled its tile, and off a gauge's arc at exactly the height where the dial filled its own. Only what is written or listed asks for a scroller now; everything else is a picture drawn to fit, and what overflows is left to the frame, which clips at the tile's edge where a shadow has already faded out. The slider's phantom scrollbar goes with it. **The selector is a selector.** Named for what it does rather than what it is, and the choice it is holding is held in the dashboard's own primary — a pill that slides between the options rather than a grey one that had to be looked for. The stored type is untouched, so no document changes meaning. **The arrangement is held off the panel's edges**, by the same distance it holds between two widgets. The ground is not held off with it: a background covers the whole panel, and only what is arranged on it has a margin. No stored panel loses a row to it. **The rail is drawn on the panel.** It was chrome bolted to the edge of the screen beside the canvas — in the app's own design rather than the dashboard's, and on a scaled canvas not even lined up with it. It now takes a column out of the canvas the way the margin does, scaled with it and wearing its look. Which cell each widget sits in is unchanged; only how big a cell is. Two of these were the same mistake twice: an unlayered rule stating `position` for everything wearing a class — `.gl-surface` on a rail placed by a utility, and a blanket lift over every child of a pressable on a pill placed by `layoutId`. Both now say it one element at a time.
This commit is contained in:
@@ -54,8 +54,8 @@ import { appPath } from "@/lib/portal"
|
||||
import { cn } from "@/lib/utils"
|
||||
import { handleError } from "@/utils"
|
||||
import {
|
||||
areaOf,
|
||||
CanvasSurface,
|
||||
canvasOf,
|
||||
columnsOf,
|
||||
type Dashboard,
|
||||
DashboardView,
|
||||
@@ -69,7 +69,7 @@ import {
|
||||
sectionsOf,
|
||||
widgetsOf,
|
||||
} from "./DashboardView"
|
||||
import { PanelRail, RAIL_INSET } from "./PanelRail"
|
||||
import { PanelRail } from "./PanelRail"
|
||||
import { DashboardPanel, WidgetPanel } from "./panels"
|
||||
import {
|
||||
dashboardKeys,
|
||||
@@ -327,7 +327,6 @@ export function DashboardEditor({
|
||||
// Every widget the panel shows, not just the first section's — a document
|
||||
// written with several sections is one arrangement here, as it is there.
|
||||
const widgets = page ? flatWidgets(page) : []
|
||||
const canvas = canvasOf(draft)
|
||||
|
||||
const updateWidgets = (next: WidgetDef[]) => {
|
||||
if (!page) return
|
||||
@@ -381,8 +380,25 @@ export function DashboardEditor({
|
||||
),
|
||||
)
|
||||
|
||||
// A dashboard hanging on a panel beside others is drawn with a rail on it,
|
||||
// which takes room off the canvas. Show that here rather than letting someone
|
||||
// arrange against a width the wall does not have.
|
||||
// ponytail: the first such panel wins — the others differ only in scale.
|
||||
const { data: panels } = useQuery(panelsQueryOptions())
|
||||
const railDashboards =
|
||||
(panels?.panels ?? []).find(
|
||||
(panel) =>
|
||||
(panel.dashboards ?? []).length > 1 &&
|
||||
(panel.dashboards ?? []).includes(draft.name),
|
||||
)?.dashboards ?? null
|
||||
const hasRail = Boolean(railDashboards) && !stacked
|
||||
// What the arrangement is laid out in: the canvas less its margin, and less
|
||||
// the rail's column when the panel carries one.
|
||||
const area = areaOf(draft, hasRail)
|
||||
|
||||
const layout = layoutOf(widgets, columns)
|
||||
const rows = rowsOf(draft)
|
||||
const rows = rowsOf(draft, hasRail)
|
||||
|
||||
// maxRows below only constrains a *drag*. A stored placement is corrected
|
||||
// against `cols` and nothing else, so a canvas that shrank leaves whatever
|
||||
// now falls past its bottom edge drawn under the clip.
|
||||
@@ -428,18 +444,6 @@ export function DashboardEditor({
|
||||
const active = widgets.find((widget) => widget.id === selected) ?? null
|
||||
const panelOpen = Boolean(active) || settingsOpen
|
||||
|
||||
// A dashboard hanging on a panel beside others is drawn with a rail over it,
|
||||
// which takes room off the canvas. Show that here rather than letting someone
|
||||
// arrange against a width the wall does not have.
|
||||
// ponytail: the first such panel wins — the others differ only in scale.
|
||||
const { data: panels } = useQuery(panelsQueryOptions())
|
||||
const railDashboards =
|
||||
(panels?.panels ?? []).find(
|
||||
(panel) =>
|
||||
(panel.dashboards ?? []).length > 1 &&
|
||||
(panel.dashboards ?? []).includes(draft.name),
|
||||
)?.dashboards ?? null
|
||||
|
||||
const setEdit = (next: boolean) => {
|
||||
setSelected(null)
|
||||
setSettingsOpen(false)
|
||||
@@ -492,19 +496,37 @@ export function DashboardEditor({
|
||||
/>
|
||||
</div>
|
||||
) : (
|
||||
<CanvasSurface dashboard={draft} dots={edit}>
|
||||
<CanvasSurface
|
||||
dashboard={draft}
|
||||
dots={edit}
|
||||
rail={
|
||||
railDashboards ? (
|
||||
<PanelRail
|
||||
dashboards={railDashboards}
|
||||
current={draft.name}
|
||||
// Editing one dashboard of a panel and editing its neighbour are
|
||||
// the same job, so the rail keeps whichever mode this one is in.
|
||||
linkFor={(name) => ({
|
||||
to: "/dashboards/$name",
|
||||
params: { name },
|
||||
search: edit ? { edit: true } : {},
|
||||
})}
|
||||
/>
|
||||
) : null
|
||||
}
|
||||
>
|
||||
{(scale) =>
|
||||
!edit ? (
|
||||
<DashboardView dashboard={draft} />
|
||||
<DashboardView dashboard={draft} rail={hasRail} />
|
||||
) : (
|
||||
<GridLayout
|
||||
width={canvas.width}
|
||||
width={area.width}
|
||||
layout={layout}
|
||||
onLayoutChange={applyLayout}
|
||||
positionStrategy={scaledStrategy(scale)}
|
||||
gridConfig={{
|
||||
cols: columns,
|
||||
rowHeight: rowHeightOf(draft),
|
||||
rowHeight: rowHeightOf(draft, hasRail),
|
||||
margin: [GRID_GAP, GRID_GAP],
|
||||
containerPadding: [0, 0],
|
||||
// The canvas is the constraint: nothing may be dragged off the
|
||||
@@ -534,28 +556,11 @@ export function DashboardEditor({
|
||||
|
||||
return (
|
||||
<LookProvider dashboard={draft}>
|
||||
{railDashboards && !stacked ? (
|
||||
<PanelRail
|
||||
dashboards={railDashboards}
|
||||
current={draft.name}
|
||||
// Editing one dashboard of a panel and editing its neighbour are the
|
||||
// same job, so the rail keeps whichever mode this one is in.
|
||||
linkFor={(name) => ({
|
||||
to: "/dashboards/$name",
|
||||
params: { name },
|
||||
search: edit ? { edit: true } : {},
|
||||
})}
|
||||
/>
|
||||
) : null}
|
||||
|
||||
<div
|
||||
className={cn(
|
||||
"absolute inset-0 overflow-hidden px-4 pb-24 pt-20 transition-[padding] duration-200",
|
||||
panelOpen && "md:pr-[27rem]",
|
||||
)}
|
||||
style={
|
||||
railDashboards && !stacked ? { paddingLeft: RAIL_INSET } : undefined
|
||||
}
|
||||
data-testid="dashboard-canvas"
|
||||
>
|
||||
<PaletteProvider dashboard={draft}>{body}</PaletteProvider>
|
||||
@@ -566,7 +571,6 @@ export function DashboardEditor({
|
||||
"pointer-events-none absolute inset-0 transition-[right] duration-200",
|
||||
panelOpen && "md:right-[27rem]",
|
||||
)}
|
||||
style={railDashboards && !stacked ? { left: RAIL_INSET } : undefined}
|
||||
>
|
||||
<CanvasTitle>
|
||||
<span className="truncate px-3 py-1.5 text-sm font-medium">
|
||||
|
||||
Reference in New Issue
Block a user