feat: add stack auto-layout container with Tailwind-like class shorthand - #4
Merged
Conversation
Add a flexbox-style `stack` container (aliases `row`/`column`) that packs child elements along an axis with gap, padding, justify, and cross-axis alignment — children need no coordinates, the stack measures and positions them. Drawing is still delegated to the normal element handlers, so every registered element works as a child and existing absolute-coordinate payloads are unaffected (purely additive, no breaking change). - New `imagespec.classutil.parse_class`: optional Tailwind-like `class` string shorthand that desugars to the structured keys (explicit keys win). Only the layout subset is recognized; styling/color classes are ignored so colors and fonts stay on each element's own keys. Faithful Tailwind spacing scale (N x 4px), arbitrary values (`gap-[10]`/`p-[3px]`), fractions (`mt-0.5`), and negative margins (`-mt-2`) for fine nudges. - Per-child layout via the child's `class` or a `layout:` sub-dict (grow, self-align, margin) — kept separate from drawing keys so e.g. a diagram's own `margin` is never mistaken for a layout margin. - `_blit` helper composites tiles with clipping so negative margins / overflow are safe. Docs: - New self-contained `docs/authoring.md` LLM authoring guide (output contract, layout decision model, class shorthand, common pitfalls, device sizes, and worked examples — each verified by rendering), linked from the README. - Fix invalid one-line multi-key YAML examples in the README. Tests: stack packing/alignment/justify/grow/margin/padding/offset + class parser (scale, arbitrary, fractions, negative, unknown-token) + matrix samples for stack/row/column. 117 passing, ruff clean. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add a flexbox-style
stackcontainer (aliasesrow/column) that packs child elements along an axis with gap, padding, justify, and cross-axis alignment — children need no coordinates, the stack measures and positions them. Drawing is still delegated to the normal element handlers, so every registered element works as a child and existing absolute-coordinate payloads are unaffected (purely additive, no breaking change).imagespec.classutil.parse_class: optional Tailwind-likeclassstring shorthand that desugars to the structured keys (explicit keys win). Only the layout subset is recognized; styling/color classes are ignored so colors and fonts stay on each element's own keys. Faithful Tailwind spacing scale (N x 4px), arbitrary values (gap-[10]/p-[3px]), fractions (mt-0.5), and negative margins (-mt-2) for fine nudges.classor alayout:sub-dict (grow, self-align, margin) — kept separate from drawing keys so e.g. a diagram's ownmarginis never mistaken for a layout margin._blithelper composites tiles with clipping so negative margins / overflow are safe.Docs:
docs/authoring.mdLLM authoring guide (output contract, layout decision model, class shorthand, common pitfalls, device sizes, and worked examples — each verified by rendering), linked from the README.Tests: stack packing/alignment/justify/grow/margin/padding/offset + class parser (scale, arbitrary, fractions, negative, unknown-token) + matrix samples for stack/row/column. 117 passing, ruff clean.