Slides: one desk for list, viewer and editor; the light on the editor; a new deck opens blank
- static/desk.css is the desk colour once, for the deck list, the viewer and the editor (it was in two places and the list had none), so going from the list into a deck never changes the room. The list keeps its wash of Slides' hue over it. - The editor takes brand/light.css and pointer.js (merged from the index work): the strip's slides and the layout picker are lit, the header's tools and the history buttons press in, and every rst-btn blooms. - A deck made by the list's New deck (no name) opens on a title slide whose heading and subtitle are EMPTY — "Add a title", "Add text" — instead of the words "Untitled deck" to select and replace (blankOpeningOps). The deck is still titled "Untitled deck" until renamed. A named create (the API, a script) is unchanged. - An empty block keeps a placeholder's width on the stage: the title and quote templates size blocks to their content, and an empty one (the width of a line break) left nothing to see or click.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
8 files changed,
+132
−37
internal/slides/decks.go+36 −2internal/slides/decks_test.go+53 −0internal/slides/static/decks.css+4 −2internal/slides/static/desk.css+18 −0internal/slides/static/editor.css+9 −15internal/slides/templates/decks.html+2 −1internal/slides/templates/editor.html+9 −6internal/slides/templates/viewer.html+1 −11
CI failed — run details
Intent
diff --git a/internal/slides/decks.go b/internal/slides/decks.go| index 9fdeba1..5ac28ec 100644 |
| --- a/internal/slides/decks.go |
| +++ b/internal/slides/decks.go |
| @@ -1086,7 +1086,8 @@ func (a *app) createDeck(w http.ResponseWriter, r *http.Request) { |
| } |
| title := strings.TrimSpace(r.PostFormValue("title")) |
| - if title == "" { |
| + untitled := title == "" |
| + if untitled { |
| title = rastrillo.T(r, "slides.deck.untitled") |
| } |
| theme := r.PostFormValue("theme") |
| @@ -1108,7 +1109,11 @@ func (a *app) createDeck(w http.ResponseWriter, r *http.Request) { |
| a.fail(w, r, "create deck", err) |
| return |
| } |
| - ops, err := openingOps(title, theme) |
| + open := openingOps |
| + if untitled { |
| + open = blankOpeningOps |
| + } |
| + ops, err := open(title, theme) |
| if err != nil { |
| a.fail(w, r, "build the opening ops", err) |
| return |
| @@ -1142,6 +1147,35 @@ func openingOps(title, theme string) ([]byte, error) { |
| }) |
| } |
| +// blankOpeningOps is the first batch of a deck made with no name (the |
| +// list's New deck, which opens in the editor): the same title slide as |
| +// fixtures/slide-layouts.mjs's "title" layout, its heading and subtitle |
| +// empty, so the editor shows "Add a title" and "Add text" to type into |
| +// rather than the words "Untitled deck" to select and replace. The |
| +// deck's own title is still "Untitled deck" until it is renamed. |
| +func blankOpeningOps(title, theme string) ([]byte, error) { |
| + slide, err := newID() |
| + if err != nil { |
| + return nil, err |
| + } |
| + heading, err := newID() |
| + if err != nil { |
| + return nil, err |
| + } |
| + sub, err := newID() |
| + if err != nil { |
| + return nil, err |
| + } |
| + return opsJSON([]op{ |
| + {"op": "set_meta", "title": title, "theme": theme}, |
| + {"op": "add_slide", "id": slide, "layout": "flow", "template": "title"}, |
| + {"op": "add_block", "slide": slide, "id": heading, "type": "heading", |
| + "props": map[string]any{"level": 1}, "region": "heading", "markdown": ""}, |
| + {"op": "add_block", "slide": slide, "id": sub, "type": "text", |
| + "props": map[string]any{"size": "l"}, "region": "body", "markdown": ""}, |
| + }) |
| +} |
| + |
| // --- GET/POST /d/{sqid}/settings --- |
| type deckSettingsPage struct { |
diff --git a/internal/slides/decks_test.go b/internal/slides/decks_test.go| index 2a2e37f..6438cac 100644 |
| --- a/internal/slides/decks_test.go |
| +++ b/internal/slides/decks_test.go |
| @@ -174,3 +174,56 @@ func TestConcurrentWritersConflictThenRetry(t *testing.T) { |
| t.Errorf("document meta title = %q, want %q", view.Meta.Title, "Second writer") |
| } |
| } |
| + |
| +// TestBlankOpeningSlideIsEmptyToTypeInto: a deck made from the list's |
| +// New deck (no name) opens on a title slide whose heading and subtitle |
| +// are empty, so the editor shows its placeholders, while the deck itself |
| +// is still called what it was given. |
| +func TestBlankOpeningSlideIsEmptyToTypeInto(t *testing.T) { |
| + d := testDB(t) |
| + a, _, err := newApp(d, Config{Env: EnvDevelopment, Logger: quietLogger()}) |
| + if err != nil { |
| + t.Fatalf("newApp: %v", err) |
| + } |
| + t.Cleanup(func() { a.Close() }) |
| + ctx := context.Background() |
| + owner, _, err := ensureUser(ctx, d.G, "paul@example.test") |
| + if err != nil { |
| + t.Fatalf("ensureUser: %v", err) |
| + } |
| + row, err := a.createDeckRow(ctx, owner, "Untitled deck", defaultTheme, nil) |
| + if err != nil { |
| + t.Fatalf("createDeckRow: %v", err) |
| + } |
| + ops, err := blankOpeningOps("Untitled deck", defaultTheme) |
| + if err != nil { |
| + t.Fatalf("blankOpeningOps: %v", err) |
| + } |
| + if err := a.editDeck(ctx, &row, actorFor(owner), ops, nil, nil); err != nil { |
| + t.Fatalf("editDeck: %v", err) |
| + } |
| + h, view, err := a.openDeck(ctx, row) |
| + if err != nil { |
| + t.Fatalf("openDeck: %v", err) |
| + } |
| + defer h.Close(ctx) |
| + if view.Meta.Title != "Untitled deck" { |
| + t.Errorf("deck title %q, want the name it was given", view.Meta.Title) |
| + } |
| + if len(view.Slides) != 1 || view.Slides[0].Template != "title" { |
| + t.Fatalf("slides %+v, want one title slide", view.Slides) |
| + } |
| + blocks := view.Slides[0].Blocks |
| + if len(blocks) != 2 || blocks[0].Type != "heading" || blocks[1].Type != "text" { |
| + t.Fatalf("blocks %+v, want a heading and a text", blocks) |
| + } |
| + for _, b := range blocks { |
| + for _, p := range b.Text { |
| + for _, r := range p { |
| + if r.T != "" { |
| + t.Errorf("%s block carries %q, want it empty for its placeholder", b.Type, r.T) |
| + } |
| + } |
| + } |
| + } |
| +} |
diff --git a/internal/slides/static/decks.css b/internal/slides/static/decks.css| index dc49cee..d19f3e1 100644 |
| --- a/internal/slides/static/decks.css |
| +++ b/internal/slides/static/decks.css |
| @@ -7,14 +7,16 @@ |
| Slides' own hue (the icon's glow, estilo theme/apps.go hue 56, at the |
| aurora's lightness). One hue only, as the app icons have; the suite's |
| full aurora stays on Home. Painted on the body so it reaches the bar |
| - and the edges without anything here overflowing. */ |
| + and the edges without anything here overflowing. Over the desk the |
| + editor and the viewer sit on too (static/desk.css), so going from the |
| + list into a deck never changes the room. */ |
| body:has([slides-decks]) { |
| background: |
| radial-gradient(ellipse 70rem 28rem at 50% -6rem, |
| light-dark(oklch(0.88 0.06 56 / 0.5), oklch(0.42 0.08 56 / 0.14)), |
| transparent 70%) |
| no-repeat, |
| - var(--rst-bg); |
| + var(--slides-desk, var(--rst-bg)); |
| } |
| [slides-decks] { |
| padding-block: var(--rst-sp-4) var(--rst-sp-6); |
diff --git a/internal/slides/static/desk.css b/internal/slides/static/desk.css| new file mode 100644 |
| index 0000000..ca770f3 |
| --- /dev/null |
| +++ b/internal/slides/static/desk.css |
| @@ -0,0 +1,18 @@ |
| +/* desk.css — the desk the slides sit on (I2, after Docs' editor): one |
| + colour for the deck list, the viewer and the editor, so moving between |
| + them never changes the room. A warm grey from Slides' own hue in light, |
| + near-black in dark, so a slide reads as a lit page on a surface. |
| + |
| + Registered as a <color> so light-dark() resolves on :root, in the |
| + reader's scheme, and the resolved colour is what inherits. */ |
| +@property --slides-desk { |
| + syntax: "<color>"; |
| + inherits: true; |
| + initial-value: #ebe7e2; |
| +} |
| +:root { |
| + --slides-desk: light-dark(#ebe7e2, #0e1014); |
| +} |
| +body:has(:is([slides-editor], [slides-viewer], [slides-decks])) { |
| + background: var(--slides-desk); |
| +} |
diff --git a/internal/slides/static/editor.css b/internal/slides/static/editor.css| index 96997a4..31525fd 100644 |
| --- a/internal/slides/static/editor.css |
| +++ b/internal/slides/static/editor.css |
| @@ -13,28 +13,14 @@ |
| at 320px (spec §8): the stage scrolls inside its own region, which |
| is the one allowance the spec makes. */ |
| -/* The desk the slide sits on (I2, after Docs' editor): the whole |
| - window under the header, a warm grey from Slides' own hue in light |
| - and near-black in dark, so the slide reads as a lit page on a surface |
| - and the strip and inspector float over it. Registered as a <color> |
| - so light-dark() resolves on :root, in the reader's scheme. */ |
| -@property --slides-desk { |
| - syntax: "<color>"; |
| - inherits: true; |
| - initial-value: #ebe7e2; |
| -} |
| +/* The desk (static/desk.css) and the layout pictures' inks. */ |
| :root { |
| - --slides-desk: light-dark(#ebe7e2, #0e1014); |
| - /* The layout pictures' inks (editor.html's slides-layout-glyph). */ |
| --slides-glyph-paper: light-dark(#ffffff, #23211f); |
| --slides-glyph-edge: light-dark(#cfc8bf, #4a4540); |
| --slides-glyph-ink: light-dark(#3d3832, #d8d2cb); |
| --slides-glyph-soft: light-dark(#cdc5bb, #5a544d); |
| --slides-glyph-accent: var(--rst-accent); |
| } |
| -body:has([slides-editor]) { |
| - background: var(--slides-desk); |
| -} |
| /* `hidden` must actually hide. The bundle shows and hides most of the |
| inspector with the hidden PROPERTY, and the UA's own |
| @@ -1342,6 +1328,14 @@ body:has([slides-editor]) { |
| white-space: nowrap; |
| text-overflow: ellipsis; |
| } |
| +/* An empty block has the width of a line break: where a template sizes |
| + blocks to their content (title and quote centre them), it, and the |
| + placeholder over it, would be nothing to see or click. So an empty |
| + one keeps a placeholder's width on the stage. The server's markup and |
| + ProseMirror's are the same shape, so binding still moves nothing. */ |
| +[slides-stage] [slides-block][data-placeholder]:has(:only-child > br.ProseMirror-trailingBreak:only-child) { |
| + min-inline-size: min(10em, 60cqi); |
| +} |
| /* A heading's placeholder sits on its first line, wherever the |
| template aligns it; a list's sits after its marker. */ |
| [slides-stage] [slides-block][data-block="list"][data-placeholder]::before { |
diff --git a/internal/slides/templates/decks.html b/internal/slides/templates/decks.html| index 87de174..fb41550 100644 |
| --- a/internal/slides/templates/decks.html |
| +++ b/internal/slides/templates/decks.html |
| @@ -32,7 +32,8 @@ |
| The light (brand/light.css, brand/pointer.js) is opted into with |
| [slides-lift] on the covers and [slides-lit] on the rows; with no |
| script or under reduced motion the page is the still design. */}} |
| -{{define "page-head"}}<link rel="stylesheet" href="{{asset "static/brand/light.css"}}"> |
| +{{define "page-head"}}<link rel="stylesheet" href="{{asset "static/desk.css"}}"> |
| +<link rel="stylesheet" href="{{asset "static/brand/light.css"}}"> |
| <link rel="stylesheet" href="{{asset "static/decks.css"}}"> |
| <script defer src="{{asset "static/brand/pointer.js"}}"></script> |
| <script defer src="{{asset "static/brand/decks.js"}}"></script>{{end}} |
diff --git a/internal/slides/templates/editor.html b/internal/slides/templates/editor.html| index 957b8d1..525c3ee 100644 |
| --- a/internal/slides/templates/editor.html |
| +++ b/internal/slides/templates/editor.html |
| @@ -29,7 +29,10 @@ |
| the one surface that needs scripts — and it points at the viewer, |
| which does not. */}} |
| {{define "page-head"}}<link rel="stylesheet" href="{{asset "static/slides.css"}}"> |
| +<link rel="stylesheet" href="{{asset "static/desk.css"}}"> |
| +<link rel="stylesheet" href="{{asset "static/brand/light.css"}}"> |
| <link rel="stylesheet" href="{{asset "static/editor.css"}}"> |
| +<script defer src="{{asset "static/brand/pointer.js"}}"></script> |
| <link rel="stylesheet" href="{{asset "static/estilo/save-status.css"}}"> |
| <script type="module" src="{{.BundleSrc}}"></script>{{end}} |
| {{/* The editor draws its own header (I2, after Docs' editor; Paul, |
| @@ -186,10 +189,10 @@ |
| the editor unusable with a screen reader. */}} |
| <p slides-presence-live class="rst-sr-only" aria-live="polite" aria-atomic="true"></p> |
| <div slides-history role="group" aria-label="{{.L "head.history"}}"> |
| - <button type="button" data-command="undo" aria-label="{{.UndoLabel}}" title="{{.UndoLabel}} ({{index .Keys "undo"}})">{{icon "undo-2"}}</button> |
| - <button type="button" data-command="redo" aria-label="{{.RedoLabel}}" title="{{.RedoLabel}} ({{index .Keys "redo"}})">{{icon "redo-2"}}</button> |
| + <button type="button" slides-press data-command="undo" aria-label="{{.UndoLabel}}" title="{{.UndoLabel}} ({{index .Keys "undo"}})">{{icon "undo-2"}}</button> |
| + <button type="button" slides-press data-command="redo" aria-label="{{.RedoLabel}}" title="{{.RedoLabel}} ({{index .Keys "redo"}})">{{icon "redo-2"}}</button> |
| </div> |
| - <button type="button" slides-head-tool data-view-toggle="inspector" aria-pressed="true" aria-controls="slides-inspector">{{icon "panel-right"}}<span>{{.L "head.inspector"}}</span></button> |
| + <button type="button" slides-head-tool slides-press data-view-toggle="inspector" aria-pressed="true" aria-controls="slides-inspector">{{icon "panel-right"}}<span>{{.L "head.inspector"}}</span></button> |
| {{- with .ShareHref}} |
| <a rst-btn slides-head-share href="{{.}}">{{$.L "head.share"}}</a> |
| {{- end}} |
| @@ -231,7 +234,7 @@ |
| itself (draggable), with Alt+arrows and the menu as the keyboard's |
| equivalents. */}} |
| <template slides-strip-item-template> |
| - <li slides-strip-item draggable="true"> |
| + <li slides-strip-item slides-lit draggable="true"> |
| <div slides-thumb inert><img slides-thumb-img alt="" width="1920" height="1080"></div> |
| <a slides-strip-link href="#"> |
| <span slides-strip-label></span> |
| @@ -254,7 +257,7 @@ |
| <p id="slides-strip-help" class="rst-sr-only">{{.L "strip.reorder"}}</p> |
| <ol slides-strip aria-describedby="slides-strip-help"> |
| {{range .Strip}} |
| - <li slides-strip-item draggable="true" data-slide-id="{{.ID}}"{{if .Current}} data-current="true"{{end}}> |
| + <li slides-strip-item slides-lit draggable="true" data-slide-id="{{.ID}}"{{if .Current}} data-current="true"{{end}}> |
| <div slides-thumb inert><img slides-thumb-img src="{{.Thumb}}" alt="{{.Label}}" width="1920" height="1080" loading="lazy"></div> |
| <a slides-strip-link href="#{{.ID}}"{{if .Current}} aria-current="true"{{end}}> |
| <span slides-strip-label>{{.Label}}</span> |
| @@ -284,7 +287,7 @@ |
| 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" data-layout-choice="{{.Name}}"><span slides-layout-glyph aria-hidden="true">{{template "slides-layout-glyph" .Name}}</span><span>{{.Label}}</span></button> |
| + {{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> |
diff --git a/internal/slides/templates/viewer.html b/internal/slides/templates/viewer.html| index 9aca78d..77ef5ad 100644 |
| --- a/internal/slides/templates/viewer.html |
| +++ b/internal/slides/templates/viewer.html |
| @@ -20,6 +20,7 @@ |
| nowhere else: it is a document's look, not the app's chrome, and |
| every other screen would pay for it without using it. */}} |
| {{define "page-head"}}<link rel="stylesheet" href="{{asset "static/slides.css"}}"> |
| +<link rel="stylesheet" href="{{asset "static/desk.css"}}"> |
| <style> |
| /* The chrome around the slide. Everything a slide itself looks like |
| is slides.css; these rules only place the viewer's own parts, each |
| @@ -27,17 +28,6 @@ |
| rst-* vocabulary. The look is the editor's (I2, after Docs): the |
| slide is paper on a desk, the deck's actions one set of pills, and |
| the filmstrip the slides' own pictures. */ |
| - @property --slides-desk { |
| - syntax: "<color>"; |
| - inherits: true; |
| - initial-value: #ebe7e2; |
| - } |
| - :root { |
| - --slides-desk: light-dark(#ebe7e2, #0e1014); |
| - } |
| - body:has([slides-viewer]) { |
| - background: var(--slides-desk); |
| - } |
| [slides-viewer] { |
| margin-inline: auto; |
| max-inline-size: 72rem; |