Skip to content

✨ layout: render box and text element trees - #21

Closed
cowboyd wants to merge 1 commit into
tree-hostfrom
tree-layout
Closed

cowboyd wants to merge 1 commit into
tree-hostfrom
tree-layout

Conversation

@cowboyd

@cowboyd cowboyd commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

The Host describes what the UI contains, but it should not dictate how every element becomes terminal output. Treating layout as a middleware-extensible function allows each element type to interpret its own properties and yield @bomb.sh/tty operations while recursively composing its children. This avoids maintaining separate layout state and gives third-party elements the same extension point as built-ins, regardless of which framework created them.

box and text provide the first concrete proof of that model. Boxes establish layout containers, text elements establish text styling scopes, and adjacent literals are collected into terminal text runs rather than manufacturing extra layout containers.

import { layout } from '@clack/ui';

renderer.render(...layout(host.root));

This PR adds LayoutApi, root layout behavior, and middleware implementations for typed box and text elements. It converts ordered Host trees into @bomb.sh/tty operations and updates the basic example to construct and lay out those elements manually. Tests cover nested box and text layout independently.

@pkg-pr-new

pkg-pr-new Bot commented Aug 7, 2026 •

Copy link
Copy Markdown

commit: e57af45

@cowboyd
cowboyd force-pushed the tree-layout branch 2 times, most recently from 17c0b7b to d0b7b1b Compare August 11, 2026 04:27
@cowboyd
cowboyd force-pushed the tree-layout branch 2 times, most recently from a0be5b8 to e57af45 Compare August 23, 2026 17:28
@cowboyd

cowboyd commented Oct 23, 2026

Copy link
Copy Markdown
Contributor Author

closing out in favor of a DOM based substrate. See #37

@cowboyd cowboyd closed this Oct 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant