// Responsive layout: the SAME app on a phone, tablet, or desktop. The window is
// host-sized and resizable, so drive the layout from the live window instead of
// hardcoding pixels. Here the column count comes from
// `capabilities.windowSizeClass` (Material 3 width breakpoints: compact <600,
// medium 600-840, expanded >=840). Resize the window and the grid reflows.
//
// `capabilities` and `env` are plain objects with reactive GETTERS, not
// functions - read `capabilities.windowSizeClass` (no call). Reading it inside
// JSX tracks, so the memo below re-runs on every resize. `windowSize()` IS a
// function (call it) - we read its width to size each card exactly.
//
// This is the REFLOW answer, for layouts that genuinely rearrange across form
// factors. For content with fixed internal geometry (diagrams, slides,
// dashboards, game boards) do not branch on window size at all: author one
// design space and let `viewBox` scale it to fit - see view-viewbox.tsx.
import { render, capabilities, windowSize, createMemo, For } from "@solidrt/core"
const GAP = 16
const PAD = 24
const COLORS = ["#1f6feb", "#3fb950", "#db6d28", "#a371f7", "#e3b341", "#f778ba", "#2dd4bf", "#f85149"]
function App() {
// Column count from the size class; card width derived so N fit per row.
let cols = createMemo(() => (capabilities.windowSizeClass === "expanded" ? 3 : capabilities.windowSizeClass === "medium" ? 2 : 1))
let cardWidth = createMemo(() => (windowSize().width - PAD * 2 - GAP * (cols() - 1)) / cols())
return (
{capabilities.windowSizeClass} - {cols()} column{cols() === 1 ? "" : "s"}
{(c) => (
card
)}
)
}
render(() => )