Skip to main content

Module domkit

Module domkit 

Source
Expand description

The DOM widget catalog (CSS-styled controls, select popover, chat blocks). The DOM widget catalog: ready-made El trees for the common controls and chat building blocks, styled by KIT_CSS (every look is a CSS rule an app may override by appending its own sheet, see sheet_with).

widgetbuilderelement / classeshit ids
buttonbuttonbutton.k-btn (.primary, .ghost)id
switchswitchbutton.k-switch + Control::Switch (:checked)id
checkboxcheckboxdiv.k-check > span.k-box + Control::Checkboxid
text inputinputdiv.k-input + Control::Input (:focus)id
number fieldnumber_input + NumberSpecdiv.k-num > div.k-input, div.k-steps > button.k-stepid, {id}:inc, {id}:dec
spinnerspinnerspan.k-spinner + Control::Spinner—
select triggerselect_triggerselect.k-select (.open)id
select popoverselect_popoverfixed div.k-pop > div.k-opt (.sel, .dis) > label + div.k-sub{id}:opt:{i} (enabled rows only)
message bubblebubblediv.k-msg.me / .them > div.k-who, div.k-body (runs), div.k-timeid
hover action rowaction_rowdiv.k-actions > button.k-act{id}:{key}
collapsible cardcarddiv.k-card (.open) > div.k-card-head + div.k-card-bodyid (the head)
chip / filterchipbutton.k-chip (.on)id
bannerbannerdiv.k-banner.info / .warn / .error{id}:act, {id}:close
side panelside_panelfixed div.k-side > div.k-side-head + div.k-side-body{id}:close
tabstabsdiv.k-tabs > button.k-tab (.on){id}:tab:{i}
segmentedsegmenteddiv.k-seg > button.k-seg-btn (.on){id}:{i}
listlistdiv.k-list > div.k-li (.sel){id}:row:{i}
tabletablediv.k-table > grid div.k-tr (.k-th, .sel) > div.k-td (.num){id}:row:{i}
menumenufixed div.k-menu > div.k-mi (.danger, .dis), div.k-sep{id}:item:{i}
dialogdialogfixed div.k-scrim + div.k-dialog > head, body, foot{id}:scrim, {id}:close, {id}:foot:{i}
tooltiptooltipfixed div.k-tip—
toaststoastsfixed div.k-toasts > div.k-toast (.ok, .warn, .error){id}:{i}:close
stat, progress, badge, kbd, fieldstat, progress, badge, kbd, fielddiv.k-stat, div.k-progress, span.k-badge, span.k-kbd, div.k-fieldid (stat)

The light look is LIGHT_VARS on the page root (theme_vars); every colour in KIT_CSS is a --k-* variable.

Inline markdown for bubbles is inline_md; long lists render only their visible rows with VirtualList. Kit widgets from uzor-framework go inside a DOM tree through an embed slot (El::slot + Dom::slots); a DOM tree goes inside a kit panel by laying it out in the panel’s rect.

Modules§

icons
Icon bodies used by the catalog.

Structs§

ListView
What part of a long option list a popover shows. The select’s own model (keyboard, wheel, type-to-filter) keeps it; the popover only draws it.
MenuItem
One entry of a menu.
NumberSpec
The rules of a number field (number_input): range, step, shown decimals. The value stays text while it is typed (-, 1. and an empty field are fine); the app reads it with NumberSpec::parse, the steppers and the arrow keys go through NumberSpec::stepped, and leaving the field tidies it with NumberSpec::normalized (uzor-framework’s kit::dom does all three).
SelectOpt
One option of a select.
VirtualList
A virtualized list: only the rows in (or near) the viewport are built and laid out; spacers stand for the rest. Row heights start at an estimate and are learned from laid-out rows (VirtualList::measure), so long chats stay cheap.
Window
The rows a VirtualList shows and the space around them.

Constants§

KIT_CSS
The catalog’s default look (dark, 13px Inter). Variables on :root theme it: --k-accent, --k-bg, --k-fg, --k-muted, --k-line, --k-panel.
KIT_TOUCH_CSS
Touch-sized targets, applied under @media (pointer: coarse) (a finger: iOS / Android builds, or the last input was touch). Apple asks for 44 pt, Material for 48 dp: controls grow to 44 px, list rows to 48 px, text to 15 px. The look stays the same; only sizes change. sheet and sheet_with include it after KIT_CSS; the app’s own rules still win.
LIGHT_VARS
Inline :root overrides for the light look: put them on the page root (El::new("div.k-root").css(LIGHT_VARS)); custom properties cascade to the subtree.

Functions§

action_row
A hover action row (reply, react, copy, more…): (key, icon body, name) per button, hits {id}:{key}.
badge
A small status pill (kind: "", ok, warn, error, muted).
banner
A banner (kind: info, warn, error) with an optional action button ({id}:act) and a close button ({id}:close).
bubble
A chat message bubble: optional sender line, markdown body (inline_md), time.
button
A push button.
card
A collapsible card: the head (hit id) toggles open; the body shows when open.
centered
A w × h box centred in viewport (where a dialog goes).
checkbox
A checkbox with its label; the row is the hit.
chip
A filter chip.
dialog
A modal dialog at at over a full-viewport scrim ({id}:scrim, a hit so a click outside can close it), with a title, a close button ({id}:close), body and footer buttons {id}:foot:{i} (the first is .primary).
field
A labelled form row: a small caption above control.
icon
A 24×24 stroke icon (currentColor) from its path markup.
inline_md
Inline markdown to DOM runs: **bold**, *italic* / _italic_, ***both***, `code` (verbatim), http(s) links (a.link, hit url:…) and @nick mentions (a.mention, hit nick:…). Unclosed markers stay literal; _ only opens at a word start and closes at a word end (snake_case stays as is).
input
A single-line text input showing edit.
kbd
A keyboard shortcut hint (span.k-kbd).
list
A list of rows (div.k-li, .sel for selected), each a main label and an optional muted side text; hits {id}:row:{i}.
menu
A context menu / command list as a position: fixed box at at (viewport coordinates; see popover_at). Enabled items are hits {id}:item:{i} (i counts separators too, so it is the index into items).
number_input
A number field: a text input (id) with up / down steppers ({id}:inc, {id}:dec). The rules are a NumberSpec; in uzor-framework register them with kit::dom(..).number(id, spec), which filters typing, steps on the buttons, the arrow keys and the wheel over the focused field, and tidies the text on blur.
picked
The tab, segment, row or item index a hit id names ({id}:{kind}:{i}, or {id}:{i} for an empty kind).
picked_opt
The option index a select popover hit id names ({id}:opt:{i}).
popover_at
Where a popover h tall goes for a trigger at anchor in viewport: below it, or above when it does not fit below and fits better above; at least the trigger’s width.
progress
A progress bar, v in 0 … 1.
segmented
A segmented control (one choice of a few, e.g. Dark / Light): hits {id}:{i}.
select_list
select_popover for a windowed, searchable list: rows view.top .. of opts (the already filtered options; hits keep their index in opts), the highlighted row, a search line and a scroll thumb. “No matches” when opts is empty. The popover is position: fixed at at, so at is in the coordinates of the viewport given to lay_out_in (the window, origin 0,0). Its rows’ --k-accent (the chosen row’s tick) can be set inline on the returned element.
select_popover
The open select’s list as a position: fixed popover at at (see popover_at): it paints above the page and does not scroll with it. Enabled rows are hits {id}:opt:{i}; chosen is marked .sel (with a tick).
select_trigger
The closed select: the chosen label and a chevron.
sheet
KIT_CSS (plus KIT_TOUCH_CSS) parsed against the current media environment.
sheet_with
KIT_CSS followed by the app’s own rules (later rules of equal specificity win).
side_panel
A side panel docked right (position: fixed: it stays while the page scrolls), with a title row and a close button ({id}:close).
slot
An embed slot box (div.k-slot) named key, w × h: a kit widget or canvas goes in its content box (see Dom::slots).
spinner
A busy spinner at time t seconds.
stat
A metric tile: a caption, a big value and a muted note.
switch
A switch (role="switch"): the track is the button’s box, the knob its control.
switch_at
A switch whose knob is at pos (0 … 1) while it slides.
table
A table: a header row and data rows on one CSS grid track list (columns, e.g. "1fr 80px"); num columns align right. Rows are hits {id}:row:{i}, .sel for selected.
tabs
A tab strip: one button.k-tab per label (.on for active), hits {id}:tab:{i}.
theme_vars
The page-root inline variables for the dark ("", the sheet’s own :root) or light look.
toasts
A toast stack in the bottom-right corner of the viewport: (kind, text) per toast (kind as for banner); each has a close hit {id}:{i}:close.
tooltip
A tooltip below anchor (fixed, viewport coordinates).