Skip to content

Narrow a document's sidebar to the contents map's spine, and reveal its labels over the prose - #5772

Merged
max-sixty merged 4 commits into
mainfrom
toc-hide
Nov 10, 2026
Merged

max-sixty merged 4 commits into
mainfrom
toc-hide

Conversation

@max-sixty

@max-sixty max-sixty commented Nov 9, 2026 •

Copy link
Copy Markdown
Owner

The contents map rests as its spine again, and shows its labels over the page when the reader points at it, Tabs into it or presses g. A sidebar holding only the map now narrows to 56px, the spine's width, rather than taking a 240px column, so the prose starts beside the spine. That fixes the blank strip in #5619 without #5637's always-shown labels.

At rest (runbook fixture, 1440×900): before, the labels filled a column and the prose started at 288px. Now the spine, its dots and the thread and On Me marks stand in the narrowed sidebar, and the prose starts at 104px.

At rest, before
At rest, after

Revealed by keyboard focus on the first section (a resting mouse shows the same): the labels keep their 320px measure over a 92% paper ground, as before #5637.

Revealed, after

#5619's page of parts at 1295px: the prose started at 529px with 22px free on the right; it now starts at 345px with 230px free for wide blocks.

Parts, before
Parts, after

How the Layout and the map divide the work

  • lf-toc declares x-spine, a new registry key that delivery paints as data-lf-spine, the way a board declares x-space for the room it needs. The word follows the glossary's "contents spine"; "rail" stays the comment strip's (data-rail, --rail).
  • On a screen under a mouse, a sidebar whose aside comes before a layout-column body and whose track holds only such an element narrows to --sidebar-spine (layouts.css). Its track stops clipping and carries --lf-track-spine: 1, the aside paints over the body and the body is isolated, so the labels cover every box the body draws. The Layout names no widget.
  • The map takes its spine form only in a track the Layout narrowed for it, too narrow for words (toc.css); a track beside the body with room for words gets the open outline, and any other the disclosure. The map follows the Layout's decision rather than its own width alone, so a narrow sidebar a page sets, whose track clips, folds the map into the disclosure rather than hiding labels it would cut off. --lf-sidebar-slot is deleted.
  • At rest a clip-path limits the map's paint and pointer to its own box in the track, so the labels' measure past it never blocks the prose. The map stays in flow in the sticky track, so the fixed positioning and the clearance rule Draw the contents map inside its sidebar track #5637 deleted stay deleted.
  • toc.css now places everything by logical sides, so the map and the outline mirror on a right-to-left page, where the resting clip flips.
  • A row's thread and On Me marks moved beside its link (toc-view.js), so they show at rest next to the spine.

Calls to check

  • Only a track holding the map alone narrows. Narrowing every document sidebar broke a paragraph in one into a few letters a line, and page check --render passed it. A sidebar holding more keeps its column, and the map stands open there.
  • Only an aside before the body narrows. An aside after it keeps its column and open outline, as on main; narrowed, it would need the labels to spread the other way, toward the body on the inline-start side.
  • Under touch, and on paper, a document's sidebar keeps its column, and its outline stands open there, where under touch it was folded before.
  • The narrowed sidebar is 56px: its track's 40px holds the spine, the marks and a mouse's aim, and clears the render check's 40px widget floor, so the map needs no exemption.
  • x-spine stays for now, with a TODO beside the Layout rule. It and the names it brings (data-lf-spine, --sidebar-spine, --lf-track-spine) widen the public interface for one widget's look. Narrowing automatically needs some declaration, since the aside is a size container and takes no width from its content. The alternative, tried on this branch, lets the page narrow its sidebar with the existing --aside: the Layout lays any track narrower than words over the body, and the map takes its spine form from its own width. That matched this branch's geometry in Chromium and Firefox, but makes the spine a look each page opts into.

Verification

Ran locally, all passing: every test that composes a document sidebar or a contents map (found by scanning the suite), the journey test_a_contents_spine_maps_the_document_until_the_user_enters_it, the registry, schema and delivery tests in model/process, pnpm run check:framework, pnpm run test:runtime (907), and pre-commit. Probed docs/index.html at rest and revealed, and a right-to-left page at rest and focused, in Chromium and Firefox.

Test changes
  • The margin-map journey is the contents-spine journey again: labels hidden at rest, revealed by pointing, by go-to and by focus; the prose starts within 32px of the map; label presses go through the revealed words; under touch the outline stands open.
  • Restored test_the_revealed_contents_spine_covers_every_box_the_body_paints, which holds the Layout's paint order.
  • New test_a_contents_spine_rests_beside_the_prose_and_reveals_its_labels_over_it, left to right and right to left: at rest nothing of the map lies over the prose, pointing at the spine shows labels over the body inside the window, and on paper the sidebar is a column.
  • New test_a_sidebar_the_layout_does_not_narrow_keeps_the_map_s_words_shown, for a status beside the map, an aside after the body (both a column with the open outline) and a narrow sidebar a page sets (the disclosure). The last two failed on an earlier version of this branch, which narrowed a trailing aside and picked the map's form by the track's width.
  • test_a_route_taller_than_the_map_returns_to_an_open_outline now checks that the resting outline lays nothing over the title, instead of fitting a column's gutter.
  • Deleted test_a_status_line_in_the_map_s_track_follows_the_map: a status beside the map now keeps the sidebar a column, which the new test covers.
  • The history, crowded-map, marks and go-to tests reveal the map before pressing or hovering a label.

Refs #5619

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

…m to the prose

A document's contents map rests again as its spine and shows its labels over
the page when the reader points at it, focuses into it or arms go-to. The
sidebar now reserves only a 56px rail for it, so the prose starts beside the
spine instead of a column's width away (#5619), without the blank strip the
old hidden spine left and without #5637's always-shown labels.

- A widget declares `x-rail` (a new `$marks` entry, painted `data-lf-rail`),
  and `lf-toc` does. On a screen under a fine pointer, a sidebar whose aside
  comes before a `layout-column` body and whose track holds only such an
  element becomes a rail: the aside takes `--sidebar-rail`, its track doesn't
  clip and carries `--lf-track-rail: 1`, the aside paints over the body and
  the body is isolated. Every other sidebar keeps a column's room: a track
  holding anything else, an aside after the body, any track under touch, and
  paper. Making every document sidebar a rail broke a paragraph in one into a
  few letters a line and passed the render check.
- `--lf-sidebar-slot` is gone. `toc.css` takes the spine map only in a track
  the Layout marked as a rail and too narrow for words; the open outline in a
  track beside the body with room for words; the disclosure otherwise. The
  map follows the Layout's decision rather than its own width alone, so a
  narrow track a page asks for, which clips, folds the map into the
  disclosure instead of hiding labels the track would cut off.
- At rest the nav's clip-path limits paint and pointer to the map's box in
  the rail, so the labels' 320px measure lays nothing over the prose; the
  reveal removes the clip and fades the labels in. The map stays in flow in
  the sticky track, so no clearance rule or fixed positioning returns.
- `toc.css` places the map and the outline by logical sides, so both mirror
  on a right-to-left page. The resting clip flips there, since a clip path's
  insets are physical.
- A row's thread and On Me marks moved beside its link, so they show at rest
  next to the spine.

Behavior changes the tests now hold: the rail map's labels are hidden until
the reader points, focuses or arms go-to; the revealed map covers every box
the body paints; in either direction the resting rail lays nothing over the
prose and the revealed labels stay inside the window; a document sidebar
holding more than the map, an aside after the body and paper keep a column,
and a narrow sidebar a page sets folds its map into the disclosure; under touch a
document's sidebar stands its outline open instead of folding it. The
status-line-after-the-map test is gone, since a rail holds the map alone.

Refs #5619

@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.

"Rail" now names two different things in the shipped interface. data-rail="right"|"none" on body already names the comment rail (the region where threads stand, which the same page-layout.md section, "The rail and the margin", describes). This PR uses the same word for a sidebar that narrows to the map's spine: the registry key x-rail, its paint data-lf-rail, --sidebar-rail, --lf-track-rail, and the reference prose. In that section the two meanings now sit in back-to-back paragraphs: "under a mouse it is a narrow rail" and then "data-rail="right" on body gives a sidebar page a rail". An author reading it could fairly conclude that data-rail="none" turns off the map's resting form, or that x-rail is how a widget joins the comment rail.

x-rail is a new public registry key that package authors will declare, so its name is cheapest to settle now. A name for what the element does, such as resting at its spine width and revealing the rest over the page, would keep it separate from the comment rail. The alternative is to keep the key and have the reference define the word once, distinguishing it from data-rail.

Comment thread skills/leaf/references/page-layout.md Resolved
…he comment strip's

The glossary keeps "rail" for the strip right of `main` where margin rows sit
(`data-rail`, `--rail`), and rejects Material's "navigation rail" for it, yet
this branch called the sidebar narrowed to the map a rail too: `x-rail`,
`data-lf-rail`, `--sidebar-rail` and `--lf-track-rail`, beside `data-rail` in
the same reference section. They are now `x-spine`, `data-lf-spine`,
`--sidebar-spine` and `--lf-track-spine`, after the glossary's "contents
spine", and the prose says the sidebar narrows to the map's spine.

The spine journey's spacing check goes back to main's pair: the long stretch
before the last section against the two close rows. On CI's fonts the
stretch before the next section fitted to exactly one label apart, as the
close rows did.
@max-sixty max-sixty changed the title Rest the contents map as a spine in a rail, and give the column's room to the prose Narrow a document's sidebar to the contents map's spine, and reveal its labels over the prose Nov 9, 2026
leaf-agent
leaf-agent previously approved these changes Nov 9, 2026
@max-sixty

Copy link
Copy Markdown
Owner Author

why do we need a new public registry key??

@leaf-agent

Copy link
Copy Markdown
Collaborator

It isn't strictly needed. The narrowing rule sits in the Layout's layouts.css, and Keep the layer open bars core from naming lf-toc. A stylesheet can't read the registry, so the Layout needs a painted attribute to find "a track holding only an element that rests as a spine". That attribute is data-lf-spine, following the x-space → data-lf-space pattern. So the key is the price of keeping that rule in core.

A cheaper option that keeps the same behavior: move the rule into the map's own stylesheet. toc.css already names lf-toc and already reads --lf-track-spine, so it could hold .layout-sidebar:has(> aside:only-of-type ~ .layout-column):has(> aside > .layout-track:only-child > lf-toc:only-child) itself. That deletes the key and everything copied from it: its entries in browser/registry.json and kernel-registry.json, its schema in schema.py, contract.d.ts, the lf-toc declaration, and the registry prose. Only the map can rest this way, so no package composition is lost. Another widget wanting the same form could write the same selector against the documented layout-sidebar/layout-track structure.

What that gives up:

  • A package stylesheet sets four of the Layout's own properties: --aside, the aside's z-index, the track's overflow and the body's isolation. The body's paint order would then be guaranteed from toc.css rather than from the Layout's file. --aside is already an author-facing input (page-layout.md), but the other three aren't.
  • The second package to want this form copies the selector rather than declaring one key.

With one consumer and no compatibility constraint, I think the move is the better trade. It removes a public key no other widget has asked for, and the paint-order test (test_the_revealed_contents_spine_covers_every_box_the_body_paints) still holds the guarantee wherever the rule lives. The key earns its place once a second widget wants to rest as a spine, and adding it then costs no more than it does now. I approved without weighing this alternative; I should have raised it.

@max-sixty

Copy link
Copy Markdown
Owner Author

yes please move, thx

@leaf-agent

Copy link
Copy Markdown
Collaborator

I didn't push the move. Making it showed a cost my earlier comment missed: it breaks a stated boundary between the Layouts and packages, so I'm holding off until you've weighed that.

What blocks it. Package sheets compose into lf-base, which sits below the Layouts' lf-layouts. So toc.css can't override the Layout's --aside. The rule has to go in a new packages/default/overrides.css, which composes into lf-overrides. Built that way, the move works: the spine, contents and go-to browser tests all pass, and so does the spine journey. But test_layout_style_and_widgets_never_read_each_other fails, since the selector names .layout-sidebar and .layout-track.

What that rule protects. layouts.css says "nothing reads a Layout back", and that test enforces it: no package sheet or module names a layout-* class. A Layout hands packages what they need through custom properties such as --lf-track-beside. A widget hands the Layout what it needs through painted registry declarations such as x-space and x-flow. x-spine is one more of those declarations. That is why it's there.

What lifting it costs. The default package would be the first to depend on the Layout's markup and to set the Layout's own properties: --aside, the aside's z-index, the track's overflow and the body's isolation. The test would also need to drop its package half or allow this one file. After that, renaming or restructuring layout-sidebar would silently break the map.

So the choice is:

  • Keep x-spine (the current head, unchanged). One registry key, and the boundary holds.
  • Move the rule into packages/default/overrides.css and lift the boundary for it. This deletes the key's six entries (registry, kernel table, schema, type, lf-toc declaration and the --sidebar-spine token). In exchange, a package reads Layout classes.

Given the boundary, I now lean toward keeping the key. Reply with whichever you want and I'll do it. The move is a ready ~50-line diff (12 insertions, 52 deletions).

`x-spine` brings four public names (`x-spine`, `data-lf-spine`,
`--sidebar-spine`, `--lf-track-spine`) for one widget's look. A spike showed
the page could narrow its sidebar with the existing `--aside` instead, with
the Layout laying any too-narrow track's overflow over the body and the map
choosing its spine form from its own width, matching this branch's geometry
in Chromium and Firefox. That makes the spine opt-in per page, so the
branch keeps the declaration for now and the TODO beside the Layout rule
records the alternative.
@max-sixty
max-sixty merged commit 197b474 into main Nov 10, 2026
5 checks passed
@max-sixty
max-sixty deleted the toc-hide branch November 10, 2026 18:17
max-sixty added a commit that referenced this pull request Nov 15, 2026
)

A sidebar page's prose now stands where a column page's would: centred
in the window, moving right only as far as the sidebar needs. Since
#4724 the body started its prose at its own start edge beside the
sidebar. Once #5772 narrowed a contents-only sidebar to its 56px spine,
that put the prose at x=104 on a 1728px window, with 880px empty past it
and the panel centred 400px off it. In Firefox the prose now stands at
504px beside the spine or an outline column at 1728, 360px at 1440 and
280px at 1280, and below about 930px where it did. Pointing at the spine
on a wide window shows its titles in the empty margin rather than over
the words.

The body pads its start by a new `--lf-room-before` and splits its room
into `--lf-free-start` and `--lf-free-end`, so `available` blocks still
reach the whole room and `wide` grows from the prose. An aside after the
body centres the prose short of the aside. Two limits carry over from
the room math, which predicts flex geometry from `--aside` and the gap:
a percentage `--aside` zeroes the room, as before this change, and
nested flows written in alternating directions don't grow their box
toward a wide block's start side, as on column pages.

Max picked this layout from three drawn candidates. Tests: the spine,
outline and other-direction-flow tests assert the centred prose; the
sidebar browser tests and the contents journey pass.

> _This was written by Claude Code on behalf of max-sixty_
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