Fusuma

Docs

Layout

What CSS does, and what to call for it.

Layout against CSS

What Fusuma's layout does of what CSS does, by W3C specification, and where each thing lives. There is no CSS parser: the words are builder methods on fusuma_ui::Style (the layout words are tsubo::style, re-exported), so this is a map from what you know to what to call.

Two crates share the work:

  • tsubo (crates/tsubo): pure layout over any tree you give it, no_std, no dependencies, no recursion. Flex rows and columns, wrapping, grids, pins, anchors. It knows nothing about widgets or drawing.
  • fusuma-ui (crates/fusuma-ui): the retained tree, the widgets, scrolling, sticky and snap, the screen-level policy (Screen::responsive). Its Style is the one place the words are set.

Some things need the box-model feature of fusuma-ui (every node grows by 16 bytes with it); a chip leaves it off.

Legend: yes, partly (what is missing is said), no, by choice, no, worth having.

CSS Flexible Box Layout Level 1

CSSFusumaWhere
display: flex, flex-direction row / columnyes: Tree::row, Tree::columntsubo/src/flex.rs, tsubo/src/tree.rs
row-reverse, column-reverseyes: Style::reverse (not in a scroll container)fusuma-ui/src/tree.rs
flex-wrapyes: Style::wrapping / wrap_to flows, Tree::flowtsubo/src/wrap.rs
wrap-reverseno, worth having only with a use
flex-grow, flex-shrink, flex-basisyes: Length::Fill(weight), Style::shrink, Style::basistsubo/src/flex.rs
orderno, by choice: there is no style bit left
justify-contentyes: Style::justify (Start, Center, End, SpaceBetween, SpaceAround, SpaceEvenly)tsubo/src/style.rs
align-items, align-selfyes: CrossAlign, SelfAlign (incl. Baseline)tsubo/src/style.rs
align-contentyes in a wrapping flow (Style::align_content); not in a gridfusuma-ui/src/tree.rs
gap, row-gap, column-gapyes: Style::gap, row_gap
min-width, max-width, min-height, max-heightyes: Style::min_size, max_size, and percent formsbox-model
auto marginsyes: Style::margin_auto(left, top, right, bottom)box-model
margin per sidepartly: one margin for all sidesworth having
padding per sideyes: Style::padding_sides

CSS Grid Layout Level 1 (and 2 where noted)

CSSFusumaWhere
display: grid, grid-template-columns (fixed, fr, auto; no minmax)yes: Tree::grid, Tree::grid_tracks, Track::{Equal, Auto, Fixed, Fill}tsubo/src/wrap.rs (Cells), style::Track
repeat(auto-fill, ...), auto-fityes: auto-fill; columns that fittsubo/src/wrap.rs
grid-column / grid-row spansyes: Style::span
grid-template-areasyes: Areastsubo/src/areas.rs
grid-auto-flow: denseyes: Style::dense (2 to 8 columns, needs alloc)tsubo/src/dense.rs
justify-items, align-items, justify-selfyes: Style::justify_items, justify_self
align-content, justify-content on the tracksno, worth having
subgrid (Level 2)no, by choice
masonryno

CSS Box Sizing and Box Model

CSSFusumaWhere
width, height: length, %, autoyes: Length::{Fixed, Fill, Content, Percent}tsubo/src/style.rs
min-content, max-content, fit-content()yes: Intrinsic, Style::fit_contenttsubo/src/style.rs
aspect-ratioyes: Style::aspect
box-sizingborder-box only
margin collapseno, by choice
calc(), clamp()no, by choice (a number is computed by the app)

CSS Positioned Layout

CSSFusumaWhere
position: absolute with top/left/right/bottomyes: Pin::{TopLeft, TopRight, BottomLeft, BottomRight}tsubo/src/pin.rs
inset with equal sides, margin: auto centringyes: Pin::{Center, Top, Bottom, Left, Right}; a fill keeps the offset free on both sidestsubo/src/pin.rs
position: stickyyes: Style::sticky, sticky_bottom (in a scroll container)fusuma-ui/src/tree.rs
position: fixed, z-indexpartly: dialogs, menus and toasts are layers over the page; no free z-indexfusuma-ui/src/dialog.rs
float, clearno, by choice

CSS Anchor Positioning

CSSFusumaWhere
position-anchor, anchor(), position-try fallbacksyes: popovers and tooltips placed on a side and an alignment, flipped to fittsubo/src/anchor.rs, fusuma-ui/src/anchor.rs

CSS Overflow and Scroll Snap

CSSFusumaWhere
overflow-y: auto / scrollyes: Tree::scroll (a column), wheel, drag, fling, barsfusuma-ui/src/scrollphys.rs, scrollbar.rs
overflow-x: auto / scrollyes: Tree::scroll_x, fusuma::scroll_x (left to right; drag, fling, snap, bar along the bottom)fusuma-ui/src/scrollx.rs (tests), layout.rs
scroll-snap-type: y mandatoryyes: Style::snapfusuma-ui/src/tree.rs
scroll-snap-type: x mandatoryyes: Style::snap on a row of cardsfusuma-ui/src/scrollphys.rs
overscroll-behavior, rubber bandyes: fusuma_anim::rubber_band
overflow: hiddenyes: clip to the box (rounded too)

CSS Text, Writing Modes, Bidi

CSSFusumaWhere
text-overflow: ellipsispartly: a label ends in … (pixels) or ~/… (cells); buttons, items, tabs and paragraphs still clipfusuma-ui/src/ellipsis.rs
-webkit-line-clampno, worth having for paragraphs
white-space, wrapping, overflow-wrapyes: paragraphs wrap at spaces and break long wordsfusuma-text
direction: rtl, bidiyes: right-to-left rows, flows and grids; the bidi algorithm for textfusuma-ui/src/layout.rs, fusuma-text
writing-mode: vertical-*no, by choice
columns (multi-column)no, by choice

CSS Display and Containment

CSSFusumaWhere
display: noneyes: a hidden node and its subtree take no room (Tree::set_hidden)fusuma-ui/src/hidden.rs
visibility: hiddenpartly: through fade to zero
container queriesno, by choice: Screen::responsive (height class, navigation, margins, columns) covers the screen casefusuma-ui/src/responsive.rs
media queriesthe screen is the one value: Screen, FormFactor, HeightClassfusuma-ui/src/screen.rs

What to build next

In this order: ellipsis on buttons, items and tabs and a line clamp for paragraphs; per-side margins; align-content in a grid. The rest above is left out on purpose.