DashboardGrid
Widgets on a twelve-column grid, each spanning columns and rows (DashboardCell), stacking on a phone.
Demo
Twelve columns: 8 + 4, then 4 + 4 + 4 (the tall one spans two rows), then 12. Narrow the window to see them stack.
Get it
It needs theme.qwe, as every component does; or take the whole kit, quillo-ui.qwe. Each component brings its own styles to the pages that show it.
$ curl -O https://quillolang.org/components/ui/theme.qwe$ curl -O https://quillolang.org/components/ui/dashboard_grid.qwemain.qwe
import ui/theme.qwe use theme_cssuse ui/dashboard_grid.qweroute GET / = <html><head><style>{theme_css}</style></head><body class="ui-root">...</body></html>Example
The code of the preview above.
demos/dashboard_grid.qwe
view DashboardGridDemo() = <div.demo-stack> <DashboardGrid id="dashboard-grid-demo"> <DashboardCell span={8}> <Widget title="Revenue" subtitle="Last 8 weeks"> <BarChart labels={["W1", "W2", "W3", "W4", "W5", "W6", "W7", "W8"]} values={[31, 34, 33, 38, 41, 40, 45, 48]} label="Revenue by week"/> </Widget> </DashboardCell> <DashboardCell span={4}> <Widget title="Orders"><Stat label="This week" value="312" delta={8.1} delta_suffix="%" card={false}/></Widget> </DashboardCell> <DashboardCell span={4} rows={2}> <Widget title="Activity"> <Timeline items={[{ title: "Order #1041 paid", time: "9:12" }, { title: "Refund #1033", time: "8:50", tone: "warning" }, { title: "New customer: Ada L.", time: "8:02", tone: "success" }]}/> </Widget> </DashboardCell> <DashboardCell span={4}> <Widget title="Visitors"><Stat label="Today" value="4,180" delta={-2.4} delta_suffix="%" card={false}/></Widget> </DashboardCell> <DashboardCell span={4}> <Widget title="Conversion"><Stat label="Today" value="3.1%" delta={0.3} delta_suffix=" pts" card={false}/></Widget> </DashboardCell> <DashboardCell span={12}> <Widget title="Recent orders" href="#dashboard_grid" padding="none"> <DataTable columns={[{ key: "id", label: "Order" }, { key: "who", label: "Customer" }, { key: "total", label: "Total", align: "right" }]} rows={[{ id: "#1041", who: "Ada L.", total: "$120.00" }, { id: "#1040", who: "Grace H.", total: "$64.50" }]}/> </Widget> </DashboardCell> </DashboardGrid> <p.demo-note>Twelve columns: 8 + 4, then 4 + 4 + 4 (the tall one spans two rows), then 12. Narrow the window to see them stack.</p> </div>Source
ui/dashboard_grid.qwe
// DashboardGrid: widgets laid out on a grid of twelve columns, each spanning as// many as it asks for, and all of them stacking on a phone. DashboardCell is one// place on it; a Widget (or anything) goes inside.//// <DashboardGrid>// <DashboardCell span={8}><Widget title="Revenue">...</Widget></DashboardCell>// <DashboardCell span={4}><Widget title="Orders">...</Widget></DashboardCell>// <DashboardCell span={4} rows={2}><Widget title="Activity">...</Widget></DashboardCell>// <DashboardCell span={12}><Widget title="Recent orders">...</Widget></DashboardCell>// </DashboardGrid>//// DashboardGrid: columns (12), gap in pixels (16), children (DashboardCells).// DashboardCell: span, how many columns it takes (4 by default: three in a row);// rows, how many rows (1). Between 600 and 900px wide the grid has half the// columns, so a cell takes half as many (at least one); under 600px every cell// takes the whole width. Cells in a row stretch to the tallest, so widgets line// up along the bottom.import ui/theme.qwe use ui_clslet dashboard_grid_css = css`.ui-dash { display: grid; gap: var(--ui-dash-gap, 16px); grid-template-columns: repeat(var(--ui-dash-cols, 12), minmax(0, 1fr)); grid-auto-rows: auto; }.ui-dash-cell { display: grid; min-width: 0; grid-column: span min(var(--c, 4), var(--ui-dash-cols, 12)); grid-row: span var(--r, 1); }.ui-dash-cell > * { min-width: 0; }@media (max-width: 899px) { .ui-dash { grid-template-columns: repeat(max(1, calc(var(--ui-dash-cols, 12) / 2)), minmax(0, 1fr)); } .ui-dash-cell { grid-column: span max(1, min(round(var(--c, 4) / 2), calc(var(--ui-dash-cols, 12) / 2))); }}@media (max-width: 599px) { .ui-dash { grid-template-columns: minmax(0, 1fr); } .ui-dash-cell { grid-column: 1 / -1; grid-row: auto; }}`view DashboardGrid(columns: int = 12, gap: int = 16, id: str? = null, class: str? = null, children) { style global dashboard_grid_css <div id={id} class={ui_cls(["ui-dash", class])} style={`--ui-dash-cols: ${columns}; --ui-dash-gap: ${gap}px`}>{children}</div>}view DashboardCell(span: int = 4, rows: int = 1, class: str? = null, children) { style global dashboard_grid_css <div class={ui_cls(["ui-dash-cell", class])} style={`--c: ${span}; --r: ${rows}`}>{children}</div>}Related
QuickActionsA grid of big icon buttons for the common actions: links, submit buttons in a form, or on_select.6 views · 6 downloadsSettingsSectionA titled block of settings rows, each a label and hint with its control at the right (SettingsRow).5 views · 6 downloadsWidgetA dashboard panel: a title row with a menu slot, the body, and a footer line or link, as a named region.7 views · 7 downloadsBentoGridA grid of tiles spanning columns and rows, with titles, tints and links, packed to leave no holes.9 views · 6 downloadsColumnsChildren side by side, equal or weighted, that go one under another when their box is narrow.7 views · 9 downloadsGridColumns that fit the screen: as many as fit a minimum width, or a fixed number that folds on phones.6 views · 8 downloads
Thread
Thread 0 posts
On DashboardGrid: questions, tips, corrections, and code that uses it.
No posts yet. The first one opens the thread.