Inset
Room around what it holds, in the kit's sizes or pixels, on every side or only across or down.
Demo
md: 16px all round
xl: 40px all round
lg, axis x: 24px at the sides only
top sm, bottom xl
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/inset.qwemain.qwe
import ui/theme.qwe use theme_cssuse ui/inset.qweroute GET / = <html><head><style>{theme_css}</style></head><body class="ui-root">...</body></html>Example
The code of the preview above.
demos/inset.qwe
view InsetDemoBox(label: str, class: str, size = "md", axis: str = "both") = <div style="border: 1px dashed var(--ui-strong); border-radius: var(--ui-radius-sm)"> <Inset size={size} axis={axis} class={class}> <div style="padding: 10px; background: var(--ui-accent-soft); color: var(--ui-accent); border-radius: var(--ui-radius-sm); font-size: 13px; text-align: center">{label}</div> </Inset> </div>view InsetDemo() = <Grid columns={2}> <InsetDemoBox label="md: 16px all round" class="inset-demo-md"/> <InsetDemoBox label="xl: 40px all round" class="inset-demo-xl" size="xl"/> <InsetDemoBox label="lg, axis x: 24px at the sides only" class="inset-demo-x" size="lg" axis="x"/> <InsetDemoBox label="top sm, bottom xl" class="inset-demo-map" size={{ top: "sm", bottom: "xl" }}/> </Grid>Source
ui/inset.qwe
// Inset: room around what it holds, in the kit's sizes, on every side or only// across or down. For padding a card's custom body, a drawer's content, a cell.//// <Inset> <p>Breathing room on every side.</p> </Inset>// <Inset size="lg" axis="x"> ... </Inset>// <Inset size={{ top: "sm", bottom: "xl" }}> ... </Inset>//// size: "xs" (4px), "sm" (8px), "md" (16px, the default), "lg" (24px), "xl" (40px)// or a number of pixels; or a map of { top, right, bottom, left } with a size each// (sides left out get none). axis: "both" (default), "x" (left and right only) or// "y" (top and bottom only). The whole room is kept when it is narrow, so give a// phone a smaller size yourself if it needs one.import ui/theme.qwe use ui_clslet inset_css = css`.ui-inset { min-width: 0; padding: var(--ui-inset-t, 0) var(--ui-inset-r, 0) var(--ui-inset-b, 0) var(--ui-inset-l, 0); }.ui-inset > :first-child { margin-top: 0; }.ui-inset > :last-child { margin-bottom: 0; }`fn inset_px(size) -> str = match size { int as n => `${n}px` float as n => `${n}px` "xs" => "4px" "sm" => "8px" "lg" => "24px" "xl" => "40px" "none" => "0" null => "0" _ => "16px" }view Inset(size = "md", axis: str = "both", class: str? = null, children) { style global inset_css let sides = match size { map as m => { t: get(m, "top"), r: get(m, "right"), b: get(m, "bottom"), l: get(m, "left") } _ => { t: axis != "x" ? size : null, r: axis != "y" ? size : null, b: axis != "x" ? size : null, l: axis != "y" ? size : null } } <div class={ui_cls(["ui-inset", class])} style={`--ui-inset-t: ${inset_px(sides.t)}; --ui-inset-r: ${inset_px(sides.r)}; --ui-inset-b: ${inset_px(sides.b)}; --ui-inset-l: ${inset_px(sides.l)}`}> {children} </div>}Related
CenterPuts its content in the middle: a column capped in width, a thing centred by its own width, or centred text.7 views · 7 downloadsResizableBoxA box the user resizes by dragging its corner or an edge, within limits, with the keyboard too.5 views · 5 downloadsScrollAreaA box with its own scrollbars and a height limit, fading at the edges where there is more to see.6 views · 7 downloadsSpacerEmpty room between things, down a column or along a row, in the kit's sizes or pixels, or growing to push things apart.5 views · 6 downloadsStickyKeeps what it holds in view at an offset from the top, or the bottom, while the rest scrolls past.5 views · 6 downloadsActionBarA page's main action and a line about it, fixed to the bottom of the screen on a phone.13 views · 6 downloads
Thread
Thread 0 posts
On Inset: questions, tips, corrections, and code that uses it.
No posts yet. The first one opens the thread.