oficina / slides Public

Editor: the desktop slide fits the room above the notes, both ways

The slide took the stage's whole width and derived its height from
16:9, so at 1280x720 with the notes open its foot was under the card
and the stage scrolled. From 1100px, in desktop view and in Both, the
stage is a size container and the slide is min(100cqi, 100cqb * 16/9)
wide, centred (final review, finding 5, V1). slides.css, the viewer and
the presenter are untouched; the canvas overlay is placed from rects.

TestTidyDesktopSlideFits measures the slide's own rect at 1280x720 and
1920x1080, desktop and Both, notes at default, maximum and closed, card
shown and hidden.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev 9ac636dc773e63969b7a80c7b048ff95ba0007d9 parent fcfdcb8
2 files changed, +126 −0
  • internal/slides/static/editor.css +19 −0
  • internal/slidestest/browser_editor_tidy_test.go +107 −0
diff --git a/internal/slides/static/editor.css b/internal/slides/static/editor.css
index 06d6d8d..73f303b 100644
--- a/internal/slides/static/editor.css
+++ b/internal/slides/static/editor.css
@@ -1692,6 +1692,25 @@
[slides-stage-phone] {
min-block-size: 0;
}
+ /* The desktop slide, in desktop view and in Both, fits the stage
+ both ways: as wide as the stage where that leaves it short enough,
+ otherwise as tall as the stage, at 16:9 either way, and centred in
+ the room it has. Without this it took the stage's width and grew
+ down under the notes card. The stage is a size container (its size
+ is the grid's, never its content's, from 1100px), so the slide's
+ width reads both its sides; inside the slide every cqw is still
+ the slide's own, as the viewer's are. The editor's only: slides.css,
+ the viewer and the presenter are as they were. The canvas overlay
+ and the presence marks are placed from rects and re-placed when
+ the stage changes size (canvas.mjs, presence-view.mjs). */
+ [slides-stage-pane]:not([data-view="phone"]) [slides-stage]:has(> [slides-slide]) {
+ container-type: size;
+ display: grid;
+ place-content: center;
+ }
+ [slides-stage-pane]:not([data-view="phone"]) [slides-stage] > [slides-slide] {
+ inline-size: min(100cqi, 100cqb * 16 / 9);
+ }
/* The inspector card floats over the desk's top end corner, Docs'
inset from its edges and Docs' width; it is as tall as what it
holds and stops the inset short of the desk's foot, past which it
diff --git a/internal/slidestest/browser_editor_tidy_test.go b/internal/slidestest/browser_editor_tidy_test.go
index 995d92a..c098151 100644
--- a/internal/slidestest/browser_editor_tidy_test.go
+++ b/internal/slidestest/browser_editor_tidy_test.go
@@ -2344,3 +2344,110 @@ func TestTidyLastSlideRemovedFromTheNotes(t *testing.T) {
t.Errorf("the last slide removed by a colleague while the caret was in its notes: the card is %+v with %d marks drawn; want data-inspect=slide, the Deck section alone, no marks", s, drawn)
}
}
+
+// fitJS is the desktop slide against the room it has: the slide's own
+// rect, the stage's (the visible stage area), the notes card's top (or
+// null when it is not drawn) and the inspector card's left (null when
+// hidden), the stage's scroll and client heights, and its width over
+// its height.
+const fitJS = `(() => {
+ const q = s => document.querySelector(s)
+ const drawn = el => !!el && el.checkVisibility() && el.getBoundingClientRect().height > 0
+ const box = el => { const r = el.getBoundingClientRect(); return {L: r.left, T: r.top, R: r.right, B: r.bottom, W: r.width, H: r.height} }
+ const stage = q('[slides-stage]'), slide = q('[slides-stage] > [slides-slide]')
+ const notes = q('[slides-notes-pane]'), card = q('[slides-inspector]')
+ return {
+ Slide: box(slide), Stage: box(stage),
+ NotesTop: drawn(notes) ? notes.getBoundingClientRect().top : -1,
+ CardLeft: drawn(card) ? card.getBoundingClientRect().left : -1,
+ ScrollH: stage.scrollHeight, ClientH: stage.clientHeight,
+ ScrollW: stage.scrollWidth, ClientW: stage.clientWidth
+ }
+})()`
+
+type fitState struct {
+ Slide, Stage edges4
+ NotesTop, CardLeft float64
+ ScrollH, ClientH, ScrollW, ClientW float64
+}
+
+// fits says how the slide fails to fit its room; "" is the pass.
+func (f fitState) fits() string {
+ var out []string
+ const e = 0.5
+ if f.Slide.L < f.Stage.L-e || f.Slide.T < f.Stage.T-e || f.Slide.R > f.Stage.R+e || f.Slide.B > f.Stage.B+e {
+ out = append(out, fmt.Sprintf("the slide %+v is not inside the stage %+v", f.Slide, f.Stage))
+ }
+ if f.NotesTop >= 0 && f.Slide.B > f.NotesTop+e {
+ out = append(out, fmt.Sprintf("the slide ends at %.1f, under the notes card's top %.1f", f.Slide.B, f.NotesTop))
+ }
+ if f.CardLeft >= 0 && f.Slide.R > f.CardLeft+e {
+ out = append(out, fmt.Sprintf("the slide ends at %.1f, under the inspector card's left %.1f", f.Slide.R, f.CardLeft))
+ }
+ if f.Slide.H <= 0 || math.Abs(f.Slide.W/f.Slide.H-16.0/9)/(16.0/9) > 0.01 {
+ out = append(out, fmt.Sprintf("the slide is %.1f×%.1f, not 16:9 within 1%%", f.Slide.W, f.Slide.H))
+ }
+ if f.ScrollH != f.ClientH {
+ out = append(out, fmt.Sprintf("the stage scrolls: scrollHeight %g, clientHeight %g", f.ScrollH, f.ClientH))
+ }
+ return strings.Join(out, "; ")
+}
+
+// TestTidyDesktopSlideFits (final review, finding 5, V1): the desktop
+// slide fits the room above the notes, both ways, at 16:9. At 1280×720
+// and 1920×1080, in desktop view and in Both, with the notes open at
+// their default height, at their maximum and closed, and with the card
+// shown and hidden: the slide's own rect is inside the stage, above the
+// notes card, left of the inspector card, 16:9 within 1%, and the stage
+// does not scroll.
+func TestTidyDesktopSlideFits(t *testing.T) {
+ te := openTidyEditor(t, 2, 1280, 720)
+ notes := map[string]func(){
+ "the notes at their default height": func() {
+ te.rig.Run(
+ chromedp.Evaluate(`(p => { if (p.dataset.state !== 'open') document.querySelector('[data-view-toggle="notes"]').click() })(document.querySelector('[slides-notes-pane]'))`, nil),
+ waitFor(`document.querySelector('[slides-notes-pane]').dataset.state === 'open'`),
+ chromedp.Focus(`[slides-notes-resize]`, chromedp.ByQuery),
+ chromedp.KeyEvent(kb.Home),
+ )
+ // From the minimum up to the default, 144px, by script: the
+ // default is not a multiple of the arrow's step.
+ te.rig.Run(chromedp.Evaluate(`document.querySelector('[slides-notes-pane]').style.setProperty('--slides-notes-block-size', '144px')`, nil))
+ },
+ "the notes at their maximum": func() {
+ te.rig.Run(
+ chromedp.Focus(`[slides-notes-resize]`, chromedp.ByQuery),
+ chromedp.KeyEvent(kb.End),
+ )
+ },
+ "the notes closed": func() {
+ te.rig.Run(
+ chromedp.Evaluate(`document.querySelector('[data-view-toggle="notes"]').click()`, nil),
+ waitFor(`document.querySelector('[slides-notes-pane]').dataset.state === 'closed'`),
+ )
+ },
+ }
+ for _, vp := range [][2]int64{{1280, 720}, {1920, 1080}} {
+ te.size(vp[0], vp[1])
+ for _, v := range []string{"desktop", "both"} {
+ te.view(v)
+ for _, card := range []string{"open", "closed"} {
+ var now string
+ te.rig.Run(chromedp.Evaluate(`document.querySelector('[slides-inspector]').dataset.state`, &now))
+ if now != card {
+ te.pressFormat(card)
+ }
+ for _, n := range []string{"the notes at their default height", "the notes at their maximum", "the notes closed"} {
+ notes[n]()
+ te.rig.Run(chromedp.Sleep(100 * time.Millisecond))
+ var f fitState
+ te.rig.Run(chromedp.Evaluate(fitJS, &f))
+ if got := f.fits(); got != "" {
+ t.Errorf("%dx%d, %s view, the card %s, %s: %s", vp[0], vp[1], v, card, n, got)
+ }
+ }
+ }
+ }
+ }
+ te.view("desktop")
+}