oficina / slides Public

Editor: worded segments size to their words, with room inside

estilo shares a segmented row out equally and pads no segment, so in
the 248px card "Subheading" touched the edges of its segment, and
went past them when selected (bold). The card's worded segments
(Level, Size, an image's Fit) now size to their words with 8px inline
padding. Their tint, ring and weight stay estilo's.

TestQuieterSegmentsHaveRoom checks each label has at least 6px either
side, selected or not, and the row stays inside the card.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev 482c611e4058cf7c1b09fe49fb1cf459ec5df893 parent 9c9ad3a
2 files changed, +50 −0
  • internal/slides/static/editor.css +8 −0
  • internal/slidestest/browser_quieter_test.go +42 −0
diff --git a/internal/slides/static/editor.css b/internal/slides/static/editor.css
index 76c7f65..14461b6 100644
--- a/internal/slides/static/editor.css
+++ b/internal/slides/static/editor.css
@@ -1157,6 +1157,14 @@
margin-block-end: 4px;
padding: 0;
}
+/* Worded segments (Level, Size, Fit) size to their words, with room
+ inside each: estilo shares the row out equally and pads none, and
+ "Subheading" touched its edges. The look stays estilo's. */
+[slides-seg-field] [estilo-seg-item] {
+ flex: 1 1 auto;
+ padding-inline: var(--rst-sp-2);
+ white-space: nowrap;
+}
/* The card at rest (spec §3.1, fixtures/layout-pick.mjs): the slide's
layout as eight pictures, four across. Each is a label round its
radio (the state, not a thing to see, as in estilo's segments) and
diff --git a/internal/slidestest/browser_quieter_test.go b/internal/slidestest/browser_quieter_test.go
index 66a414f..26de00a 100644
--- a/internal/slidestest/browser_quieter_test.go
+++ b/internal/slidestest/browser_quieter_test.go
@@ -474,6 +474,48 @@ func boxMenuInWindow(t *testing.T, te *tidyEditor) string {
return strings.Trim(strings.Join([]string{button, menu}, "; "), "; ")
}
+// segRoomJS reports, for the card's segments of radio group name, each
+// segment whose words have under 6px of room either side inside it, or
+// that runs out of the card, with each of its segments selected in turn
+// (the selected one is bold). The radios are set without an event, so
+// the document is not changed; the one that was set is put back.
+const segRoomJS = `(name => {
+ const inputs = [...document.querySelectorAll('[slides-inspector] input[name="' + name + '"]')]
+ const was = inputs.find(i => i.checked), out = []
+ if (!inputs.length || !inputs[0].checkVisibility()) return name + ' is not drawn'
+ const card = inputs[0].closest('[estilo-inspector-group]').getBoundingClientRect()
+ for (const pick of inputs) {
+ pick.checked = true
+ for (const i of inputs) {
+ const seg = i.closest('[estilo-seg-item]'), r = seg.getBoundingClientRect()
+ const words = [...seg.childNodes].find(n => n.nodeType === 3 && n.textContent.trim()), q = document.createRange()
+ q.selectNodeContents(words)
+ const w = q.getBoundingClientRect(), room = Math.min(w.left - r.left, r.right - w.right)
+ if (room < 6) out.push(words.textContent.trim() + ' has ' + room.toFixed(1) + 'px of room with ' + pick.value + ' selected')
+ if (r.left < card.left - 0.5 || r.right > card.right + 0.5) out.push(words.textContent.trim() + ' runs out of the card')
+ }
+ }
+ if (was) was.checked = true
+ return out.join('; ')
+})`
+
+// TestQuieterSegmentsHaveRoom (review V2): the card's worded segments
+// (a heading's Level, a text's Size) size to their words, each with room
+// inside its segment, selected or not, and the group fits the card.
+func TestQuieterSegmentsHaveRoom(t *testing.T) {
+ te := openTidyEditorOn(t, 1280, 720, func(a *testApp, cookies []*http.Cookie) string { return quieterDeck(t, a, cookies, boxMenuDeck) })
+ for _, c := range []struct{ id, name string }{{"boxhead00001", "rst-block-level"}, {"boxtext00001", "rst-block-size"}} {
+ te.selectBoxByID(t, c.id)
+ var got string
+ te.rig.Run(chromedp.Evaluate(segRoomJS+`(`+jsString(c.name)+`)`, &got))
+ if got != "" {
+ t.Errorf("%s: %s", c.name, got)
+ }
+ }
+ te.selectBoxByID(t, "boxhead00001")
+ te.rig.Screen(`[slides-inspector]`, "a heading's level, three worded segments")
+}
+
// TestQuieterEmptyDeck: a deck with no slides.
func TestQuieterEmptyDeck(t *testing.T) {
te := newTidyEditor(t, 1280, 720, func(a *testApp, cookies []*http.Cookie) string { return emptyDeck(t, a, cookies) })