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). ItsStyleis 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
| CSS | Fusuma | Where |
|---|---|---|
display: flex, flex-direction row / column | yes: Tree::row, Tree::column | tsubo/src/flex.rs, tsubo/src/tree.rs |
row-reverse, column-reverse | yes: Style::reverse (not in a scroll container) | fusuma-ui/src/tree.rs |
flex-wrap | yes: Style::wrapping / wrap_to flows, Tree::flow | tsubo/src/wrap.rs |
wrap-reverse | no, worth having only with a use | |
flex-grow, flex-shrink, flex-basis | yes: Length::Fill(weight), Style::shrink, Style::basis | tsubo/src/flex.rs |
order | no, by choice: there is no style bit left | |
justify-content | yes: Style::justify (Start, Center, End, SpaceBetween, SpaceAround, SpaceEvenly) | tsubo/src/style.rs |
align-items, align-self | yes: CrossAlign, SelfAlign (incl. Baseline) | tsubo/src/style.rs |
align-content | yes in a wrapping flow (Style::align_content); not in a grid | fusuma-ui/src/tree.rs |
gap, row-gap, column-gap | yes: Style::gap, row_gap | |
min-width, max-width, min-height, max-height | yes: Style::min_size, max_size, and percent forms | box-model |
| auto margins | yes: Style::margin_auto(left, top, right, bottom) | box-model |
margin per side | partly: one margin for all sides | worth having |
padding per side | yes: Style::padding_sides |
CSS Grid Layout Level 1 (and 2 where noted)
| CSS | Fusuma | Where |
|---|---|---|
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-fit | yes: auto-fill; columns that fit | tsubo/src/wrap.rs |
grid-column / grid-row spans | yes: Style::span | |
grid-template-areas | yes: Areas | tsubo/src/areas.rs |
grid-auto-flow: dense | yes: Style::dense (2 to 8 columns, needs alloc) | tsubo/src/dense.rs |
justify-items, align-items, justify-self | yes: Style::justify_items, justify_self | |
align-content, justify-content on the tracks | no, worth having | |
subgrid (Level 2) | no, by choice | |
masonry | no |
CSS Box Sizing and Box Model
| CSS | Fusuma | Where |
|---|---|---|
width, height: length, %, auto | yes: Length::{Fixed, Fill, Content, Percent} | tsubo/src/style.rs |
min-content, max-content, fit-content() | yes: Intrinsic, Style::fit_content | tsubo/src/style.rs |
aspect-ratio | yes: Style::aspect | |
box-sizing | border-box only | |
| margin collapse | no, by choice | |
calc(), clamp() | no, by choice (a number is computed by the app) |
CSS Positioned Layout
| CSS | Fusuma | Where |
|---|---|---|
position: absolute with top/left/right/bottom | yes: Pin::{TopLeft, TopRight, BottomLeft, BottomRight} | tsubo/src/pin.rs |
inset with equal sides, margin: auto centring | yes: Pin::{Center, Top, Bottom, Left, Right}; a fill keeps the offset free on both sides | tsubo/src/pin.rs |
position: sticky | yes: Style::sticky, sticky_bottom (in a scroll container) | fusuma-ui/src/tree.rs |
position: fixed, z-index | partly: dialogs, menus and toasts are layers over the page; no free z-index | fusuma-ui/src/dialog.rs |
float, clear | no, by choice |
CSS Anchor Positioning
| CSS | Fusuma | Where |
|---|---|---|
position-anchor, anchor(), position-try fallbacks | yes: popovers and tooltips placed on a side and an alignment, flipped to fit | tsubo/src/anchor.rs, fusuma-ui/src/anchor.rs |
CSS Overflow and Scroll Snap
| CSS | Fusuma | Where |
|---|---|---|
overflow-y: auto / scroll | yes: Tree::scroll (a column), wheel, drag, fling, bars | fusuma-ui/src/scrollphys.rs, scrollbar.rs |
overflow-x: auto / scroll | yes: 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 mandatory | yes: Style::snap | fusuma-ui/src/tree.rs |
scroll-snap-type: x mandatory | yes: Style::snap on a row of cards | fusuma-ui/src/scrollphys.rs |
overscroll-behavior, rubber band | yes: fusuma_anim::rubber_band | |
overflow: hidden | yes: clip to the box (rounded too) |
CSS Text, Writing Modes, Bidi
| CSS | Fusuma | Where |
|---|---|---|
text-overflow: ellipsis | partly: a label ends in … (pixels) or ~/… (cells); buttons, items, tabs and paragraphs still clip | fusuma-ui/src/ellipsis.rs |
-webkit-line-clamp | no, worth having for paragraphs | |
white-space, wrapping, overflow-wrap | yes: paragraphs wrap at spaces and break long words | fusuma-text |
direction: rtl, bidi | yes: right-to-left rows, flows and grids; the bidi algorithm for text | fusuma-ui/src/layout.rs, fusuma-text |
writing-mode: vertical-* | no, by choice | |
columns (multi-column) | no, by choice |
CSS Display and Containment
| CSS | Fusuma | Where |
|---|---|---|
display: none | yes: a hidden node and its subtree take no room (Tree::set_hidden) | fusuma-ui/src/hidden.rs |
visibility: hidden | partly: through fade to zero | |
| container queries | no, by choice: Screen::responsive (height class, navigation, margins, columns) covers the screen case | fusuma-ui/src/responsive.rs |
| media queries | the screen is the one value: Screen, FormFactor, HeightClass | fusuma-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.