Skip to content

Decide what stands in a column page's margin with one measurement, and render where it changes - #1297

Merged
max-sixty merged 5 commits into
mainfrom
layout-survey
Sep 27, 2026
Merged

max-sixty merged 5 commits into
mainfrom
layout-survey

Conversation

@max-sixty

@max-sixty max-sixty commented Sep 27, 2026 •

Copy link
Copy Markdown
Owner

One measurement now decides what stands in a column page's margin: the rail, the contents map, the first sidebar and the sidenotes. The column moves off centre where a sidebar or note needs the room, and the render gate renders each page at the widths where its margin content changes.

Before, each resident moved into the margin at its own threshold:

  • the rail was measured by script (about 960px);
  • the contents map was a container query at 848px;
  • a sidebar was a container query at 1296px;
  • a note was a container query at 1536px.

The sidebar and note thresholds were pixel copies of tokens that assumed the default column, so a page that widened its column got a sidebar positioned off the window's edge. The gate reads at 1200px, so it never saw a sidebar or note in the margin.

Now, settleResidency (margin-layout.js) reads the room beside main once a frame and writes the answer on main:

  • data-lf-margin holds one token per posture standing: rail, map, sidebar or note;
  • --lf-shift holds the column's offset, which the column Layout applies as a relative offset (layouts.css).

It admits residents in order:

  1. The rail stands where the room right of the centred column holds --rail. It never moves the column.
  2. The first sidebar stands where the room on both sides together holds the rail and --sidebar. With a fine pointer, a sidebar holding the contents map stands as the map's spine (--map, 48px) where a full sidebar does not fit. It does the same where the map is all it holds, since a float would hold nothing. A map-only sidebar left in the flow takes no room there (Take no room for a sidebar the contents map has left, and drop the retired column variables #1273's rule, now keyed on the map token).
  3. The notes stand where the room holds everything admitted so far and --note.

Each element declares its postures in CSS (--lf-resident), so the media and Layout conditions stay in the stylesheet. The widths the script reads are registered lengths, so a page may restate them in any unit. A resident that a closed disclosure or an unchosen view hides takes no room, and a toggle asks for a new reading. One the page hides itself stays a resident, so a page can show it only once it stands in the margin. The stylesheet keys every posture on the tokens instead of @container lf-shell queries, and chrome-layout's syncLayout asks for the reading.

With the default column (768px box), a sidebar reaches the margin from 1130px and a note from 1152px. A sidebar and a note together need 1416px. The column moves over by what one side lacks, so at 1200px a note page's text sits 168px left of centre. A page that changes its column's width gets thresholds that follow it.

First paint. Residency is now decided by script, so a page whose residents stand in the margin paints with them in the flow and moves them on the first rendering frame. That is the trade chosen when measuring won over fixed widths ("layout waits one frame for script"). The bootstrap can't take the reading earlier: it is a classic script, and its first frame can come before the residents are parsed.

Page CSS can follow the margin by keying on the tokens. The feature gallery's copied 1151px width became main:not([data-lf-margin~="map"], [data-lf-margin~="sidebar"]) #bg-sidebar. page-authoring.md documents the tokens, and the registry's sidebar and sidenote descriptions say when each stands.

Render gate. The sweep now runs from 360 to 1920px and records the page's own residents at each width, without the rail, which holds only Leaf's markers. For each step where they change, the gate halves the step to the exact width and renders the page there in the light scheme. That is where each resident has the least room it will ever have. version check --render names those widths when it passes. The sidenote-in-a-clipping-box test that was strict xfail now passes, and the static test that compared the gate's 1200px to the theme's container floors is deleted.

Comment bar. Above or below a passage, the bar's lane started at its first measured width, which a restored draft's words widen. A reloaded draft opened 292px further left than the same draft typed fresh. The start is now the compact control's minimum, so one draft opens in one lane.

The corpus is unchanged. It still sets each example's body in one column page. Every example already gets the full gate, sweep included, in its own Layout through the nightly test_page_fixture_renders. A multi-Layout corpus would need the wide and workspace Layouts to work below main. TODO.md now says exactly this.

Behaviour the tests pin moved:

  • test_margin_residents_stand_where_the_room_beside_the_column_holds_them derives each threshold from the tokens and checks one pixel either side.
  • test_a_note_hangs_in_the_margin_where_the_room_holds_it: at 1190px the note now hangs, with the column moved left.
  • test_a_left_sidebar_uses_the_margin_until_the_page_needs_it_back: its sidebar holds a line beside the map, so it still floats. A map-only copy checks that sidebar takes no room at 1100 and 1400px.
  • The contents-map widget test expects a map-only sidebar not to float.
  • test_unchanged_margin_refresh_cost_is_bounded_by_refresh_count allows one more read of main per refresh, for the residency reading.
  • test_a_thread_beside_its_cluster_takes_the_room_to_the_visible_edge removes the gallery's note, which would otherwise move the column at the width the case was picked for.
  • test_the_render_gate_exercises_both_schemes_at_both_viewports expects the margin renders after the four fixed ones.
  • New: test_a_note_the_page_does_not_show_takes_no_room, test_the_render_gate_renders_where_the_margin_content_changes and test_a_draft_below_its_passage_keeps_its_lane_whatever_it_holds (bug-back checked).

Still open, in TODO.md: data-rail="right" reserves the rail at every width, so a phone keeps a 295px column.

This was written by Claude Code on behalf of max-sixty

🤖 Generated with Claude Code

max-sixty and others added 4 commits September 26, 2026 23:43
…d render where it changes

The rail, the contents map, the first sidebar and the sidenotes each moved into the margin
at their own threshold: the rail by script, the others by container queries at 848, 1296
and 1536px that copied tokens and assumed the default column. `settleResidency`
(margin-layout.js) now reads the room beside `main` once a frame, admits the rail, then the
sidebar (or, with a fine pointer, the contents map's spine), then the notes, and writes
`data-lf-margin` and `--lf-shift` on `main`; the column Layout moves over by the shift and
the stylesheet keys every posture on the tokens.

The render gate sweeps to 1920px, finds each width where `data-lf-margin` changes and
renders the page there. The comment bar's lane above or below a passage starts from the
compact control's minimum rather than its first measured width, which a restored draft
widened.

Behaviour the tests pin moved: residents' thresholds are derived from the tokens, a note
hangs from 1152px with the column moved left, one more read of `main` per refresh, and the
render order includes the margin widths.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
# Conflicts:
#	skills/leaf/assets/layouts.css
#	skills/leaf/assets/theme.css
…and render only where the page's own residents change

Review follow-ups to the residency pass: a sidebar holding only the contents map
stands as the map rather than floating an empty box and moving the column; --map,
--sidebar and --note are registered lengths so a page may restate them in any unit; the
pass reads the offset the column stands at rather than the one it wrote; a resident
inside a box the page does not show needs no room; and the render gate leaves the rail
out of the widths it renders at, since the rail holds only Leaf's markers.

Tests that moved: the left-sidebar test's sidebar holds a line beside the map so it
still floats, and a map-only copy checks it takes no room; the contents-map test
expects a map-only sidebar not to float; the gate finds two margin widths on a sidebar
and note page; the note-strip test opens the view its note is in; SPILLING_PAGE is
65vw, which the sweep to 1920px no longer finds scrolling the page.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
… prettier hook

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

@leaf-agent leaf-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A hidden sidenote still moves the reading column. In settleResidency, the parent visibility check counts a note inside a closed <details>: the <details> itself is visible, while its note is not. I reproduced this at 1200px; main was marked rail note and shifted -168px with the disclosure closed. Residency needs to follow whether the resident can render, and opening or closing that disclosure needs to request a new residency reading. Otherwise a page changes its column position for content the user cannot see.

…w hides

A sidenote inside a closed <details> still moved the column, because the pass asked
whether the note's parent rendered and the <details> does. The pass now asks whether
the resident itself renders, keeping one the page hides itself (the feature gallery
hides its sidebar until it stands in the margin), and a toggle anywhere asks for a new
reading. New test: a note in a disclosure takes no room while closed and hangs once
opened.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@max-sixty
max-sixty merged commit d6f06cb into main Sep 27, 2026
5 checks passed
@max-sixty
max-sixty deleted the layout-survey branch September 27, 2026 08:19
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.

2 participants