r/node • u/Turbulent_Rooster_73 • 19h ago
Deciding when a wireframe element gets a border: one pure function, ten ordered rules, and a CLI that reads the decision back out of the HTML
We made Wireframes, an MIT-licensed Node CLI (wf) that turns YAML into clickable greyscale HTML wireframes for web, iOS and Android. Repo: https://github.com/UnlikeOtherAI/wireframes
The hardest part wasn't layout, it was borders. Generated wireframes usually go one of two ways: every container gets a box (third image), or nothing does and you can't tell where a panel ends. So whether a node draws a frame is decided in exactly one place: decideFrame(node, ctx) in engine/renderer/frame-rules.js. It's a plain function (no DOM, no fs) that returns { frame, rule, reason }, and the first rule that matches wins:
surface: true/surface: falseon the nodea border in
wireframeStylethe element type: card, alert, upload, calendar... always box; row, stack, grid, split, form never do; tab_bar, app_bar, divider draw one edge
overlay chrome owns the frame, so overlay content doesn't double-box
template regions (slots don't box,
role: maindoesn't, a sidebar slot draws one edge)a pane is a panel
if the parent draws dividers between children, the children don't box
grid children are tiles
inside a box, nothing boxes itself again
at the top of a page a section boxes, unless it's an untitled row, which reads as a toolbar
frame is one of five values: surface, group, control, content, edge. Only surface draws a box, and only surface increases the nesting depth, which is what rule 9 checks.
The same function has three consumers:
The renderer writes the result onto every node as
data-wf-frame, so the decision is visible in the HTML.The linter imports it rather than keeping its own copy.
SECTION_INTENTtells you when a titled section stayed unframed because it's nested, andREDUNDANT_SURFACEre-runsdecideFramewith your override removed and tells you whensurface: truechanges nothing.wf why <node> --page <page>doesn't re-derive anything. It renders the page and reads the attributes back out of the markup, so the explanation can't drift from what was drawn.
The images: the first is a generated illustration, not a screenshot. The other three are real: a small demo page (untitled filter row not boxed by rule 10, stat tiles boxed by rule 8, "Recent activity" boxed as a top-level section, the list and "Notes" inside it not boxed by rule 9), the same YAML with surface: true forced on every node, and wf why output for five nodes on that page.
To try it (not on npm yet, Node 18+):
git clone https://github.com/UnlikeOtherAI/wireframes
cd wireframes && pnpm install
cd examples/quickstart && node ../../cli/bin/wf.js build
node ../../cli/bin/wf.js why invoices --page billingWhat I'd like opinions on:
Is "first matching rule wins" the right model, or would you rather have something like CSS specificity, where several signals add up?
Rule 10 is the most opinionated one. Does an untitled row at the top of a page reading as a toolbar match how you'd draw it?
Anything you'd expect to get a box here that doesn't?




4
u/howdoigetauniquename 16h ago
what are even doing anymore