oficina / slides Public

Editor: a page that never scrolls; New slide pinned to the strip

From 1100px the editor is exactly the window: the desk row takes what
the bar and the font line leave, and every pane is held to it. The
strip's list is its only scroller, the stage scrolls when a frame does
not fit, and today's notes pane and inspector scroll inside themselves.
The root keeps no scrollbar gutter there. Below 1100px the stacked
column scrolls the page as before.

The strip is a surface of its own (the bar's, a hairline on its desk
edge). New slide moves into a non-scrolling [slides-strip-foot] inside
the strip's nav, as one pill joined with the layouts chevron; the
layouts open upward from it.

Tests: deckWithSlides (harness), TestEditorTidyNewSlideInStripFoot,
and browser_editor_tidy_test.go with TestTidyPageNeverScrolls and
TestTidyNewSlideStaysInView. newRigApp exposes the app a rig serves.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev 02b3de8eafe2876de1d5a16eda3172ae632f0a18 parent 59c9bd0
6 files changed, +326 −48
  • internal/slides/static/editor.css +104 −34
  • internal/slides/templates/editor.html +17 −13
  • internal/slidestest/browser_editor_tidy_test.go +136 −0
  • internal/slidestest/browser_test.go +12 −1
  • internal/slidestest/editor_tidy_test.go +21 −0
  • internal/slidestest/harness_test.go +36 −0
diff --git a/internal/slides/static/editor.css b/internal/slides/static/editor.css
index b3e52de..309af55 100644
--- a/internal/slides/static/editor.css
+++ b/internal/slides/static/editor.css
@@ -477,32 +477,44 @@
font-weight: 500;
white-space: pre;
}
-/* New slide, at the foot of the list: a button and its layouts. */
+/* New slide, in the strip's foot: one pill, the button and the
+ chevron that opens its layouts. The two share one border — the
+ chevron sits a pixel over the button's end edge, so the line between
+ them is a single hairline — and only the pill's outer ends are
+ round. The one hovered or focused comes forward, so its whole
+ border shows. */
+[slides-strip-foot] {
+ padding: var(--rst-sp-2) var(--rst-sp-2);
+}
[slides-strip-add] {
+ anchor-name: --slides-strip-add;
display: flex;
- gap: 2px;
max-inline-size: 20rem;
- padding: var(--rst-sp-2) 6px;
+}
+[slides-strip-add] > [rst-btn] {
+ border-radius: 0;
}
[slides-strip-add] > [rst-btn]:first-child {
- border-end-end-radius: 4px;
- border-start-end-radius: 4px;
+ border-end-start-radius: 999px;
+ border-start-start-radius: 999px;
flex: 1 1 auto;
gap: 6px;
justify-content: center;
}
-[slides-strip-add] {
- anchor-name: --slides-strip-add;
-}
[slides-layouts-toggle] {
+ border-end-end-radius: 999px;
+ border-start-end-radius: 999px;
flex: none;
- border-end-start-radius: 4px;
- border-start-start-radius: 4px;
- padding-inline: 8px;
+ margin-inline-start: -1px;
+ padding-inline: 8px 10px;
}
-/* The layouts, over everything, above the New slide button where the
- engine can anchor it (and in the middle of the window where it
- cannot). */
+[slides-strip-add] > [rst-btn]:is(:hover, :focus-visible) {
+ position: relative;
+ z-index: 1;
+}
+/* The layouts, over everything, opening upward from the New slide
+ pill where the engine can anchor them (and in the middle of the
+ window where it cannot). */
[slides-layout-grid] {
background: var(--rst-surface);
border: 0;
@@ -1282,42 +1294,69 @@
/* ── Three panes side by side ────────────────────────────────────── */
+/* From 1100px the page never scrolls (the editor tidied, spec §2): the
+ editor is exactly the window, the desk takes what the bar and the
+ font line leave, and every pane is held to the desk's height and
+ scrolls inside itself — the strip's list, the stage when a frame does
+ not fit, the notes, the inspector. Below 1100px the panes stack and
+ the page scrolls, as it always has. */
@media (min-width: 1100px) {
+ /* No gutter kept for a scrollbar the page will never have (as
+ estilo's own fill shell does): it was an empty band down the
+ window's end edge. */
+ :root:has([slides-editor]) {
+ scrollbar-gutter: auto;
+ }
+ [slides-editor] {
+ block-size: 100dvh;
+ grid-template-rows: auto auto minmax(0, 1fr);
+ overflow: hidden;
+ }
+ @media (scripting: none) {
+ [slides-editor] {
+ grid-template-rows: auto auto auto minmax(0, 1fr);
+ }
+ }
+ /* The strip runs the desk's full height against the start edge, so
+ the desk's padding is on the other three sides only and the strip
+ reaches back over it top and bottom. */
[slides-desk] {
- align-items: start;
+ align-items: stretch;
gap: var(--rst-sp-4);
grid-template-areas: "strip stage inspector";
grid-template-columns: 212px minmax(0, 1fr) 300px;
- padding: var(--rst-sp-4) var(--rst-sp-4) var(--rst-sp-6) var(--rst-sp-2);
+ grid-template-rows: minmax(0, 1fr);
+ min-block-size: 0;
+ padding: var(--rst-sp-4) var(--rst-sp-4) var(--rst-sp-4) 0;
}
[slides-editor][data-inspector-off] [slides-desk] {
grid-template-areas: "strip stage";
grid-template-columns: 212px minmax(0, 1fr);
}
- /* The strip and the inspector stay in view while the stage and
- its notes scroll: each scrolls inside itself, under the header. */
- [slides-strip-nav],
- [slides-inspector] {
- max-height: calc(100dvh - 64px - 2 * var(--rst-sp-4));
- overflow-y: auto;
- position: sticky;
- top: calc(64px + var(--rst-sp-4));
- }
+ /* The strip: a surface of its own, the bar's, with a hairline on its
+ desk edge. The list scrolls; the foot under it, New slide, does
+ not. */
[slides-strip-nav] {
- display: flex;
- flex-direction: column;
- scrollbar-width: thin;
+ background: var(--rst-surface);
+ border-inline-end: 1px solid var(--rst-line);
+ display: grid;
+ grid-template-rows: minmax(0, 1fr) auto;
+ margin-block: calc(-1 * var(--rst-sp-4));
+ min-block-size: 0;
}
[slides-strip] {
+ align-content: start;
flex-direction: column;
- overflow-x: visible;
- padding: 0;
+ min-block-size: 0;
+ overflow: hidden auto;
+ padding: var(--rst-sp-3) var(--rst-sp-2) var(--rst-sp-2);
+ scrollbar-width: thin;
+ }
+ [slides-strip-foot] {
+ border-block-start: 1px solid var(--rst-line);
}
[slides-strip-add] {
- background: linear-gradient(transparent, var(--slides-desk) 30%);
- bottom: 0;
- margin-top: auto;
- position: sticky;
+ max-inline-size: none;
}
[slides-strip-item] {
width: 100%;
@@ -1328,6 +1367,37 @@
[slides-strip-item][data-drop="after"] {
box-shadow: 0 4px 0 0 var(--rst-accent);
}
+ /* The stage pane: its bar, then the stages, as tall as the slide
+ but never taller than what is left over the notes' least height;
+ the notes take the rest and scroll inside themselves. With the
+ notes off, the stages have it all. */
+ [slides-stage-pane] {
+ grid-template-rows: auto minmax(0, auto) minmax(6rem, 1fr);
+ min-block-size: 0;
+ }
+ [slides-stage-pane]:has(> [slides-notes-pane][hidden]) {
+ grid-template-rows: auto minmax(0, auto);
+ }
+ [slides-stages] {
+ grid-template-rows: minmax(0, 1fr);
+ min-block-size: 0;
+ }
+ [slides-stage-phone] {
+ min-block-size: 0;
+ }
+ [slides-notes-pane] {
+ min-block-size: 0;
+ overflow-y: auto;
+ }
+ /* The inspector is as tall as what it holds, and no taller than the
+ desk: past that it scrolls inside itself. */
+ [slides-inspector] {
+ align-self: start;
+ box-sizing: border-box;
+ max-block-size: 100%;
+ min-block-size: 0;
+ overflow-y: auto;
+ }
}
/* ── Placeholders ────────────────────────────────────────────────────
diff --git a/internal/slides/templates/editor.html b/internal/slides/templates/editor.html
index 491f532..6700682 100644
--- a/internal/slides/templates/editor.html
+++ b/internal/slides/templates/editor.html
@@ -337,19 +337,23 @@
</li>
{{end}}
</ol>
- {{/* New slide, at the foot of the list where the next slide goes: the
- button makes the layout that usually follows the current slide
- (fixtures/slide-layouts.mjs's layoutAfter), and the chevron opens
- the layouts as pictures. Inside the strip's <nav> so a font wait
- makes it inert with the rest of the strip. */}}
- <div slides-strip-add>
- <button rst-btn type="button" data-command="new-slide">{{icon "plus"}}<span>{{.L "head.newslide"}}</span></button>
- {{/* A popover, in the top layer: the strip scrolls and the stage
- paints over it, and a dropdown inside either is clipped. */}}
- <button rst-btn type="button" slides-layouts-toggle popovertarget="slides-layouts" aria-label="{{.L "head.layouts"}}" title="{{.L "head.layouts"}}"><span aria-hidden="true">{{icon "chevron-down"}}</span></button>
- <div popover id="slides-layouts" slides-layout-grid role="group" aria-label="{{.L "head.layouts"}}">
- {{range .Layouts}}<button type="button" slides-lit slides-press data-layout-choice="{{.Name}}"><span slides-layout-glyph aria-hidden="true">{{template "slides-layout-glyph" .Name}}</span><span>{{.Label}}</span></button>
- {{end}}
+ {{/* New slide, in the strip's foot, under the list (spec E6): the
+ list scrolls, the foot does not, so New slide is in view however
+ long the deck is. One pill: the button makes the layout that
+ usually follows the current slide (fixtures/slide-layouts.mjs's
+ layoutAfter), and the chevron joined to it opens the layouts as
+ pictures, upward. Inside the strip's <nav> so a font wait makes
+ it inert with the rest of the strip. */}}
+ <div slides-strip-foot>
+ <div slides-strip-add>
+ <button rst-btn type="button" data-command="new-slide">{{icon "plus"}}<span>{{.L "head.newslide"}}</span></button>
+ {{/* A popover, in the top layer: the strip scrolls and the stage
+ paints over it, and a dropdown inside either is clipped. */}}
+ <button rst-btn type="button" slides-layouts-toggle popovertarget="slides-layouts" aria-label="{{.L "head.layouts"}}" title="{{.L "head.layouts"}}"><span aria-hidden="true">{{icon "chevron-down"}}</span></button>
+ <div popover id="slides-layouts" slides-layout-grid role="group" aria-label="{{.L "head.layouts"}}">
+ {{range .Layouts}}<button type="button" slides-lit slides-press data-layout-choice="{{.Name}}"><span slides-layout-glyph aria-hidden="true">{{template "slides-layout-glyph" .Name}}</span><span>{{.Label}}</span></button>
+ {{end}}
+ </div>
</div>
</div>
</nav>
diff --git a/internal/slidestest/browser_editor_tidy_test.go b/internal/slidestest/browser_editor_tidy_test.go
new file mode 100644
index 0000000..21b8b4e
--- /dev/null
+++ b/internal/slidestest/browser_editor_tidy_test.go
@@ -0,0 +1,136 @@
+//go:build browser
+
+// The editor, tidied (docs/superpowers/specs/2026-11-16-editor-tidy-design.md),
+// held in a real Chromium: what only geometry can show — the page that
+// never scrolls, the New slide that stays in view.
+package slidestest
+
+import (
+ "fmt"
+ "testing"
+
+ "amadan.net/rastrillo/rastrillo/harness"
+ "github.com/chromedp/cdproto/network"
+ "github.com/chromedp/chromedp"
+)
+
+// tidyEditor is a signed-in browser with the editor open on a deck.
+type tidyEditor struct {
+ rig *harness.Rig
+ app *testApp
+ path string // the deck's editor path, /d/{sqid}/edit
+}
+
+// openTidyEditor signs a browser in, makes a deck of n slides
+// (deckWithSlides: the first with 400 words of notes), and opens its
+// editor at width×height, bound.
+func openTidyEditor(t *testing.T, n int, width, height int64) *tidyEditor {
+ t.Helper()
+ rig, app := newRigApp(t, nil)
+ cookies := signedIn(t, app, allowedAddress)
+ var set []chromedp.Action
+ for _, c := range cookies {
+ set = append(set, network.SetCookie(c.Name, c.Value).WithURL(rig.Origin+"/").
+ WithHTTPOnly(c.HttpOnly).WithSecure(c.Secure).WithSameSite(network.CookieSameSiteLax))
+ }
+ rig.Run(set...)
+ te := &tidyEditor{rig: rig, app: app, path: deckWithSlides(t, app, cookies, n)}
+ te.size(width, height)
+ rig.Run(
+ chromedp.Navigate(rig.Origin+te.path),
+ chromedp.WaitVisible(`[slides-editor]`, chromedp.ByQuery),
+ waitFor(editorBound),
+ )
+ return te
+}
+
+// size sets the viewport, and waits until the page has laid out at it.
+func (te *tidyEditor) size(width, height int64) {
+ te.rig.Run(
+ chromedp.EmulateViewport(width, height),
+ waitFor(fmt.Sprintf(`innerWidth === %d && innerHeight === %d`, width, height)),
+ )
+}
+
+// scrolls reports how far the document is bigger than the window, in
+// each direction; "" is the pass.
+func (te *tidyEditor) scrolls(t *testing.T) string {
+ t.Helper()
+ var got string
+ te.rig.Run(chromedp.Evaluate(`(() => {
+ const d = document.documentElement, out = []
+ if (d.scrollHeight !== innerHeight) out.push('scrollHeight ' + d.scrollHeight + ' != innerHeight ' + innerHeight)
+ if (d.scrollWidth !== innerWidth) out.push('scrollWidth ' + d.scrollWidth + ' != innerWidth ' + innerWidth)
+ return out.join('; ')
+ })()`, &got))
+ return got
+}
+
+// TestTidyPageNeverScrolls (spec §2, §8): with forty slides and long
+// notes, the page is exactly the window, at a laptop's size and a
+// desktop's. The strip, the stage, the inspector and the notes scroll
+// inside themselves.
+func TestTidyPageNeverScrolls(t *testing.T) {
+ te := openTidyEditor(t, 40, 1280, 720)
+ for _, vp := range [][2]int64{{1280, 720}, {1920, 1080}} {
+ te.size(vp[0], vp[1])
+ if got := te.scrolls(t); got != "" {
+ t.Errorf("at %dx%d the page scrolls: %s", vp[0], vp[1], got)
+ }
+ }
+ te.rig.Screen(`[slides-editor]`, "the editor, forty slides")
+}
+
+// TestTidyNewSlideStaysInView (spec §2, E6): New slide is pinned to the
+// strip's foot, so it is on screen and inside the strip with the list
+// scrolled to either end; it still adds a slide; and the layouts open
+// upward from it.
+func TestTidyNewSlideStaysInView(t *testing.T) {
+ te := openTidyEditor(t, 40, 1280, 720)
+
+ const inView = `(() => {
+ const add = document.querySelector('[slides-strip-add]').getBoundingClientRect()
+ const nav = document.querySelector('[slides-strip-nav]').getBoundingClientRect()
+ const out = []
+ if (add.width === 0 || add.height === 0) out.push('New slide has no box')
+ if (add.top < 0 || add.left < 0 || add.bottom > innerHeight || add.right > innerWidth)
+ out.push('New slide ' + JSON.stringify(add) + ' is outside the window ' + innerWidth + 'x' + innerHeight)
+ if (add.top < nav.top - 0.5 || add.left < nav.left - 0.5 || add.bottom > nav.bottom + 0.5 || add.right > nav.right + 0.5)
+ out.push('New slide ' + JSON.stringify(add) + ' is outside the strip ' + JSON.stringify(nav))
+ return out.join('; ')
+ })()`
+ for _, end := range []struct{ name, js string }{
+ {"top", `document.querySelector('[slides-strip]').scrollTop = 0`},
+ {"end", `(s => s.scrollTop = s.scrollHeight)(document.querySelector('[slides-strip]'))`},
+ } {
+ var got string
+ te.rig.Run(
+ chromedp.Evaluate(end.js, nil),
+ chromedp.Evaluate(inView, &got),
+ )
+ if got != "" {
+ t.Errorf("with the strip scrolled to its %s: %s", end.name, got)
+ }
+ }
+ var scrolled bool
+ te.rig.Run(chromedp.Evaluate(`(s => s.scrollHeight > s.clientHeight && s.scrollTop > 0)(document.querySelector('[slides-strip]'))`, &scrolled))
+ if !scrolled {
+ t.Error("forty slides did not make the strip scroll inside itself: nothing above was measured scrolled")
+ }
+
+ te.rig.Run(
+ chromedp.Click(`[slides-strip-add] [data-command="new-slide"]`, chromedp.ByQuery),
+ waitFor(`document.querySelectorAll('[slides-strip] > [slides-strip-item]').length === 41`),
+ )
+
+ var gap float64
+ te.rig.Run(
+ chromedp.Click(`[slides-layouts-toggle]`, chromedp.ByQuery),
+ waitFor(`document.querySelector('#slides-layouts').matches(':popover-open')`),
+ chromedp.Evaluate(`document.querySelector('[slides-strip-add]').getBoundingClientRect().top - document.querySelector('#slides-layouts').getBoundingClientRect().bottom`, &gap),
+ )
+ if gap < 0 {
+ t.Errorf("the layouts open %gpx over the New slide pill; want them above it", -gap)
+ }
+ te.rig.Screen(`[slides-strip-nav]`, "the strip with the layouts open")
+}
diff --git a/internal/slidestest/browser_test.go b/internal/slidestest/browser_test.go
index ed97e79..227230b 100644
--- a/internal/slidestest/browser_test.go
+++ b/internal/slidestest/browser_test.go
@@ -60,8 +60,18 @@ func newRigWithStore(t *testing.T) (*harness.Rig, *fakeMailer) {
}
func newRigWith(t *testing.T, store blobs.Store) (*harness.Rig, *fakeMailer) {
+ t.Helper()
+ rig, served := newRigApp(t, store)
+ return rig, served.mailer
+}
+
+// newRigApp is newRigWith that also hands back the app the rig serves,
+// behind the same serving stack, so a test can make what it needs over
+// HTTP (signedIn, an agent, a deck) before the browser looks at it.
+func newRigApp(t *testing.T, store blobs.Store) (*harness.Rig, *testApp) {
t.Helper()
mailer := &fakeMailer{}
+ served := &testApp{mailer: mailer}
rig := harness.New(t, func(origin string) http.Handler {
// The same wiring main.go does, origin included: the rig hands
// the app its localhost origin before serving — the same seam
@@ -96,9 +106,10 @@ func newRigWith(t *testing.T, store blobs.Store) (*harness.Rig, *fakeMailer) {
t.Fatalf("rastrillo.Handler: %v", err)
}
t.Cleanup(func() { _ = closeFn() })
+ served.Handler, served.db, served.mux, served.app = h, d, mux, a
return h
})
- return rig, mailer
+ return rig, served
}
// TestBrowserWalk is the minimal loud walk: the front door arrives with
diff --git a/internal/slidestest/editor_tidy_test.go b/internal/slidestest/editor_tidy_test.go
index eac4121..ae4b12e 100644
--- a/internal/slidestest/editor_tidy_test.go
+++ b/internal/slidestest/editor_tidy_test.go
@@ -75,3 +75,24 @@ func readStatic(t *testing.T, name string) string {
}
return string(b)
}
+
+// TestEditorTidyNewSlideInStripFoot: New slide is in a foot of the
+// strip's <nav>, after the list and outside it, so the list can scroll
+// under it and the font wait's inert list still covers it.
+func TestEditorTidyNewSlideInStripFoot(t *testing.T) {
+ a := newApp(t)
+ cookies := signedIn(t, a, allowedAddress)
+ page := mustGet(t, a, deckWithSlides(t, a, cookies, 40), http.StatusOK, cookies).Body.String()
+
+ if n := strings.Count(page, "<li slides-strip-item"); n != 41 { // 40 and the template's
+ t.Errorf("the strip lists %d items (the template's included), want 41", n)
+ }
+ nav := regexp.MustCompile(`(?s)<nav slides-strip-nav.*?</nav>`).FindString(page)
+ if nav == "" {
+ t.Fatal("no <nav slides-strip-nav> in the editor")
+ }
+ foot := regexp.MustCompile(`(?s)</ol>\s*<div slides-strip-foot>\s*<div slides-strip-add>`).FindStringIndex(nav)
+ if foot == nil {
+ t.Errorf("[slides-strip-add] is not the first thing in a <div slides-strip-foot> after the list:\n%s", nav[strings.LastIndex(nav, "</ol>"):])
+ }
+}
diff --git a/internal/slidestest/harness_test.go b/internal/slidestest/harness_test.go
index 39d5305..6af6665 100644
--- a/internal/slidestest/harness_test.go
+++ b/internal/slidestest/harness_test.go
@@ -8,6 +8,7 @@ package slidestest
import (
"context"
+ "fmt"
"html"
"io"
"log/slog"
@@ -316,3 +317,38 @@ func signedIn(t *testing.T, a *testApp, address string) []*http.Cookie {
}
return cookies
}
+
+// deckWithSlides makes a deck of n slides over the API, as an agent of
+// the person whose cookies these are, and returns its editor path
+// (/d/{sqid}/edit). The first slide carries 400 words of notes: the
+// long deck and the long notes the editor's layout is held against
+// (the editor tidied, spec §8).
+func deckWithSlides(t *testing.T, a *testApp, cookies []*http.Cookie, n int) string {
+ t.Helper()
+ token := mintAgent(t, a, cookies, "deck-with-slides")
+ sqid := apiDeck(t, a, token, fmt.Sprintf("%d slides", n))
+ view := apiJSON(t, a, http.MethodGet, "/api/v1/decks/"+sqid, token, "", http.StatusOK)
+ slides, _ := view["slides"].([]any)
+ if len(slides) == 0 || len(slides) > n {
+ t.Fatalf("a new deck has %d slides; deckWithSlides(%d) cannot make that %d", len(slides), n, n)
+ }
+ first, _ := slides[0].(map[string]any)["id"].(string)
+
+ words := make([]string, 0, 400)
+ for i := range 400 {
+ words = append(words, notesWords[i%len(notesWords)])
+ }
+ var paras []string
+ for i := 0; i < len(words); i += 50 {
+ paras = append(paras, strings.Join(words[i:i+50], " ")+".")
+ }
+ ops := []string{`{"op":"set_notes","id":` + quote(first) + `,"markdown":` + quote(strings.Join(paras, "\n\n")) + `}`}
+ for range n - len(slides) {
+ ops = append(ops, `{"op":"add_slide","layout":"flow","template":"title-body"}`)
+ }
+ apiJSON(t, a, http.MethodPost, "/api/v1/decks/"+sqid+"/ops", token, `{"ops":[`+strings.Join(ops, ",")+`]}`, http.StatusOK)
+ return "/d/" + sqid + "/edit"
+}
+
+// notesWords is what deckWithSlides' notes say, over and over.
+var notesWords = strings.Fields("pause here and look at the room before the next slide because the numbers need a moment to land")