oficina / slides Public

Editor: the view switch is three icons

Desktop, Phone and Both become three icon buttons in one estilo segmented
pill, still three radios named slides-view (aria-label and title each;
the third reads "Both, side by side"). Adds the lucide icons monitor,
smartphone, monitor-smartphone and notebook-pen (the last for a later
task). The switcher's CSS shrinks to what estilo-seg does not provide.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev 94ec57a691ae5a501cfde20617f088a47da4a7a9 parent 41d9955
7 files changed, +170 −67
  • internal/slides/editor.go +1 −1
  • internal/slides/icons/icons.go +28 −24
  • internal/slides/locales/en.toml +1 −0
  • internal/slides/static/editor.css +16 −35
  • internal/slides/templates/editor.html +9 −7
  • internal/slidestest/browser_editor_tidy_test.go +72 −0
  • internal/slidestest/editor_tidy_test.go +43 −0
diff --git a/internal/slides/editor.go b/internal/slides/editor.go
index 9234df6..e216afb 100644
--- a/internal/slides/editor.go
+++ b/internal/slides/editor.go
@@ -182,7 +182,7 @@ func (p editorPage) L(key string) string { return p.S[key] }
// (rastrillo.T's own fallback) rather than a template failure.
var editorStrings = []string{
"strip.actions", "strip.reorder",
- "view", "view.desktop", "view.phone", "view.both", "view.phone.readonly",
+ "view", "view.desktop", "view.phone", "view.both", "view.both.title", "view.phone.readonly",
"inspector.deck", "inspector.slide", "inspector.block", "inspector.blocks", "inspector.blocks.none",
"deck.title", "deck.theme", "deck.accent", "deck.accent.reset", "deck.font.heading", "deck.font.body",
"font.theme", "font.system", "font.serif", "font.mono",
diff --git a/internal/slides/icons/icons.go b/internal/slides/icons/icons.go
index a1b3254..f004132 100644
--- a/internal/slides/icons/icons.go
+++ b/internal/slides/icons/icons.go
@@ -20,30 +20,34 @@ package icons
import "html/template"
var icons = map[string]template.HTML{
- "alert-triangle": `<svg class="icon" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" viewBox="0 0 24 24"><path d="m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3Z"/><path d="M12 9v4"/><path d="M12 17h.01"/></svg>`,
- "bold": `<svg class="icon" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" viewBox="0 0 24 24"><path d="M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8"/></svg>`,
- "code": `<svg class="icon" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" viewBox="0 0 24 24"><path d="m16 18 6-6-6-6"/><path d="m8 6-6 6 6 6"/></svg>`,
- "highlighter": `<svg class="icon" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" viewBox="0 0 24 24"><path d="m9 11-6 6v3h9l3-3"/><path d="m22 12-4.6 4.6a2 2 0 0 1-2.8 0l-5.2-5.2a2 2 0 0 1 0-2.8L14 4"/></svg>`,
- "italic": `<svg class="icon" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" viewBox="0 0 24 24"><line x1="19" x2="10" y1="4" y2="4"/><line x1="14" x2="5" y1="20" y2="20"/><line x1="15" x2="9" y1="4" y2="20"/></svg>`,
- "link": `<svg class="icon" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" viewBox="0 0 24 24"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"/><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"/></svg>`,
- "check": `<svg class="icon" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" viewBox="0 0 24 24"><path d="M20 6 9 17l-5-5"/></svg>`,
- "check-circle": `<svg class="icon" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><path d="m9 12 2 2 4-4"/></svg>`,
- "chevron-down": `<svg class="icon" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" viewBox="0 0 24 24"><path d="m6 9 6 6 6-6"/></svg>`,
- "help-circle": `<svg class="icon" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><path d="M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"/><path d="M12 17h.01"/></svg>`,
- "info": `<svg class="icon" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><path d="M12 16v-4"/><path d="M12 8h.01"/></svg>`,
- "kebab": `<svg class="icon" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" viewBox="0 0 24 24"><circle cx="12" cy="12" r="1"/><circle cx="12" cy="5" r="1"/><circle cx="12" cy="19" r="1"/></svg>`,
- "menu": `<svg class="icon" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" viewBox="0 0 24 24"><path d="M4 12h16"/><path d="M4 6h16"/><path d="M4 18h16"/></svg>`,
- "pencil": `<svg class="icon" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" viewBox="0 0 24 24"><path d="M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z"/><path d="m15 5 4 4"/></svg>`,
- "ellipsis": `<svg class="icon" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" viewBox="0 0 24 24"><circle cx="12" cy="12" r="1"/><circle cx="19" cy="12" r="1"/><circle cx="5" cy="12" r="1"/></svg>`,
- "panel-right": `<svg class="icon" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" viewBox="0 0 24 24"><rect width="18" height="18" x="3" y="3" rx="2"/><path d="M15 3v18"/></svg>`,
- "play": `<svg class="icon" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" viewBox="0 0 24 24"><polygon points="6 3 20 12 6 21 6 3"/></svg>`,
- "redo-2": `<svg class="icon" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" viewBox="0 0 24 24"><path d="m15 14 5-5-5-5"/><path d="M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13"/></svg>`,
- "undo-2": `<svg class="icon" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" viewBox="0 0 24 24"><path d="M9 14 4 9l5-5"/><path d="M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11"/></svg>`,
- "plus": `<svg class="icon" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" viewBox="0 0 24 24"><path d="M5 12h14"/><path d="M12 5v14"/></svg>`,
- "sparkles": `<svg class="icon" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" viewBox="0 0 24 24"><path d="M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z"/><path d="M20 3v4"/><path d="M22 5h-4"/><path d="M4 17v2"/><path d="M5 18H3"/></svg>`,
- "search": `<svg class="icon" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" viewBox="0 0 24 24"><circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/></svg>`,
- "x": `<svg class="icon" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" viewBox="0 0 24 24"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>`,
- "x-circle": `<svg class="icon" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><path d="m15 9-6 6"/><path d="m9 9 6 6"/></svg>`,
+ "alert-triangle": `<svg class="icon" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" viewBox="0 0 24 24"><path d="m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3Z"/><path d="M12 9v4"/><path d="M12 17h.01"/></svg>`,
+ "bold": `<svg class="icon" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" viewBox="0 0 24 24"><path d="M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8"/></svg>`,
+ "code": `<svg class="icon" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" viewBox="0 0 24 24"><path d="m16 18 6-6-6-6"/><path d="m8 6-6 6 6 6"/></svg>`,
+ "highlighter": `<svg class="icon" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" viewBox="0 0 24 24"><path d="m9 11-6 6v3h9l3-3"/><path d="m22 12-4.6 4.6a2 2 0 0 1-2.8 0l-5.2-5.2a2 2 0 0 1 0-2.8L14 4"/></svg>`,
+ "italic": `<svg class="icon" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" viewBox="0 0 24 24"><line x1="19" x2="10" y1="4" y2="4"/><line x1="14" x2="5" y1="20" y2="20"/><line x1="15" x2="9" y1="4" y2="20"/></svg>`,
+ "link": `<svg class="icon" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" viewBox="0 0 24 24"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"/><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"/></svg>`,
+ "check": `<svg class="icon" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" viewBox="0 0 24 24"><path d="M20 6 9 17l-5-5"/></svg>`,
+ "check-circle": `<svg class="icon" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><path d="m9 12 2 2 4-4"/></svg>`,
+ "chevron-down": `<svg class="icon" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" viewBox="0 0 24 24"><path d="m6 9 6 6 6-6"/></svg>`,
+ "help-circle": `<svg class="icon" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><path d="M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"/><path d="M12 17h.01"/></svg>`,
+ "info": `<svg class="icon" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><path d="M12 16v-4"/><path d="M12 8h.01"/></svg>`,
+ "kebab": `<svg class="icon" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" viewBox="0 0 24 24"><circle cx="12" cy="12" r="1"/><circle cx="12" cy="5" r="1"/><circle cx="12" cy="19" r="1"/></svg>`,
+ "menu": `<svg class="icon" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" viewBox="0 0 24 24"><path d="M4 12h16"/><path d="M4 6h16"/><path d="M4 18h16"/></svg>`,
+ "pencil": `<svg class="icon" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" viewBox="0 0 24 24"><path d="M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z"/><path d="m15 5 4 4"/></svg>`,
+ "ellipsis": `<svg class="icon" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" viewBox="0 0 24 24"><circle cx="12" cy="12" r="1"/><circle cx="19" cy="12" r="1"/><circle cx="5" cy="12" r="1"/></svg>`,
+ "panel-right": `<svg class="icon" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" viewBox="0 0 24 24"><rect width="18" height="18" x="3" y="3" rx="2"/><path d="M15 3v18"/></svg>`,
+ "play": `<svg class="icon" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" viewBox="0 0 24 24"><polygon points="6 3 20 12 6 21 6 3"/></svg>`,
+ "redo-2": `<svg class="icon" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" viewBox="0 0 24 24"><path d="m15 14 5-5-5-5"/><path d="M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13"/></svg>`,
+ "undo-2": `<svg class="icon" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" viewBox="0 0 24 24"><path d="M9 14 4 9l5-5"/><path d="M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11"/></svg>`,
+ "plus": `<svg class="icon" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" viewBox="0 0 24 24"><path d="M5 12h14"/><path d="M12 5v14"/></svg>`,
+ "sparkles": `<svg class="icon" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" viewBox="0 0 24 24"><path d="M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z"/><path d="M20 3v4"/><path d="M22 5h-4"/><path d="M4 17v2"/><path d="M5 18H3"/></svg>`,
+ "search": `<svg class="icon" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" viewBox="0 0 24 24"><circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/></svg>`,
+ "x": `<svg class="icon" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" viewBox="0 0 24 24"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>`,
+ "x-circle": `<svg class="icon" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><path d="m15 9-6 6"/><path d="m9 9 6 6"/></svg>`,
+ "monitor": `<svg class="icon" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" viewBox="0 0 24 24"><rect width="20" height="14" x="2" y="3" rx="2"/><line x1="8" x2="16" y1="21" y2="21"/><line x1="12" x2="12" y1="17" y2="21"/></svg>`,
+ "monitor-smartphone": `<svg class="icon" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" viewBox="0 0 24 24"><path d="M18 8V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h8"/><path d="M10 19v-3.96 3.15"/><path d="M7 19h5"/><rect width="6" height="10" x="16" y="12" rx="2"/></svg>`,
+ "notebook-pen": `<svg class="icon" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" viewBox="0 0 24 24"><path d="M13.4 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-7.4"/><path d="M2 6h4"/><path d="M2 10h4"/><path d="M2 14h4"/><path d="M2 18h4"/><path d="M21.378 5.626a1 1 0 1 0-3.004-3.004l-5.01 5.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z"/></svg>`,
+ "smartphone": `<svg class="icon" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" viewBox="0 0 24 24"><rect width="14" height="20" x="5" y="2" rx="2" ry="2"/><path d="M12 18h.01"/></svg>`,
}
// Icon renders one icon by its Lucide slug. An unknown slug renders
diff --git a/internal/slides/locales/en.toml b/internal/slides/locales/en.toml
index 8d92222..9373df9 100644
--- a/internal/slides/locales/en.toml
+++ b/internal/slides/locales/en.toml
@@ -333,6 +333,7 @@ slides.editor.view = "View"
slides.editor.view.desktop = "Desktop"
slides.editor.view.phone = "Phone"
slides.editor.view.both = "Both"
+slides.editor.view.both.title = "Both, side by side"
slides.editor.view.phone.readonly = "Phone preview, read-only"
# The inspector's three sections and the Blocks list.
diff --git a/internal/slides/static/editor.css b/internal/slides/static/editor.css
index 4b32895..041c301 100644
--- a/internal/slides/static/editor.css
+++ b/internal/slides/static/editor.css
@@ -987,45 +987,26 @@
gap: var(--rst-sp-2) var(--rst-sp-4);
justify-content: center;
}
-/* Three radios drawn as a segmented control. The input is visually
- hidden and keyboard-intact (arrows move between them), the label
- is the target, the checked one is lifted; focus is drawn on the
- label from the input's own focus-visible. */
+/* Three radios drawn as estilo's segmented control ([estilo-seg]): it
+ styles the segments, hides each radio over its label (still focusable
+ and arrow-key operable) and draws the checked and focused ones. What
+ is left is the fieldset's own box, the legend (read, not seen: the
+ <legend> is the fieldset's first child, so :first-child never matches
+ the first segment and its corner is rounded here) and the icon's
+ size, set small enough to keep the pill compact. */
[slides-switcher] {
- background: light-dark(rgb(40 28 12 / 0.07), rgb(255 255 255 / 0.07));
- border: 0;
- border-radius: var(--rst-radius);
- display: flex;
- gap: 2px;
+ flex: 0 0 auto;
margin: 0;
- padding: 2px;
-}
-[slides-switcher] > label {
- border-radius: var(--rst-radius-sm);
- color: var(--rst-text-muted);
- cursor: pointer;
- font-size: var(--rst-fs-sm);
- font-weight: 550;
- min-height: 24px;
- padding: 4px 14px;
- position: relative;
-}
-[slides-switcher] > label > input {
- height: 1px;
- opacity: 0;
- position: absolute;
- width: 1px;
-}
-[slides-switcher] > label:has(input:checked) {
- background: var(--rst-surface);
- box-shadow: var(--rst-shadow-lift);
- color: var(--rst-text);
- font-weight: 600;
+ min-inline-size: 0;
+ padding: 0;
+ border: 0;
}
-[slides-switcher] > label:has(input:focus-visible) {
- outline: 2px solid var(--rst-accent);
- outline-offset: 2px;
+[slides-switcher] > label:nth-child(2) {
+ border-start-start-radius: 8px;
+ border-end-start-radius: 8px;
}
+[slides-switcher] > label { min-inline-size: 36px; }
+[slides-switcher] svg { inline-size: 16px; block-size: 16px; }
/* ── The stages: one, or two side by side ─────────────────────────── */
diff --git a/internal/slides/templates/editor.html b/internal/slides/templates/editor.html
index 6700682..17ef736 100644
--- a/internal/slides/templates/editor.html
+++ b/internal/slides/templates/editor.html
@@ -359,15 +359,17 @@
</nav>
<section slides-stage-pane aria-label="{{.StageLabel}}" data-view="desktop">
- {{/* The switcher (spec §3.2): three real radios with visible words.
- Which one is on decides where a layout edit lands — the desktop
- block, or its phone override map — so it is never an icon. */}}
+ {{/* The switcher (spec §3.2): three real radios drawn as one
+ segmented pill of icons. Which one is on decides where a layout
+ edit lands — the desktop block, or its phone override map — so
+ each carries its name (aria-label) and tooltip, and the lit one
+ has estilo's ring as well as its tint. */}}
<div slides-stage-bar>
- <fieldset slides-switcher>
+ <fieldset slides-switcher estilo-seg>
<legend class="rst-sr-only">{{.L "view"}}</legend>
- <label><input type="radio" name="slides-view" value="desktop" checked> {{.L "view.desktop"}}</label>
- <label><input type="radio" name="slides-view" value="phone"> {{.L "view.phone"}}</label>
- <label><input type="radio" name="slides-view" value="both"> {{.L "view.both"}}</label>
+ <label estilo-seg-item aria-label="{{.L "view.desktop"}}" title="{{.L "view.desktop"}}"><input type="radio" name="slides-view" value="desktop" checked>{{icon "monitor"}}</label>
+ <label estilo-seg-item aria-label="{{.L "view.phone"}}" title="{{.L "view.phone"}}"><input type="radio" name="slides-view" value="phone">{{icon "smartphone"}}</label>
+ <label estilo-seg-item aria-label="{{.L "view.both.title"}}" title="{{.L "view.both.title"}}"><input type="radio" name="slides-view" value="both">{{icon "monitor-smartphone"}}</label>
</fieldset>
{{/* The text marks the schema has (§2.6: b, i, c, h, href), as
buttons: each runs the same ProseMirror command its key does, on
diff --git a/internal/slidestest/browser_editor_tidy_test.go b/internal/slidestest/browser_editor_tidy_test.go
index 9baf03f..ca8333a 100644
--- a/internal/slidestest/browser_editor_tidy_test.go
+++ b/internal/slidestest/browser_editor_tidy_test.go
@@ -12,6 +12,7 @@ import (
"amadan.net/rastrillo/rastrillo/harness"
"github.com/chromedp/cdproto/network"
"github.com/chromedp/chromedp"
+ "github.com/chromedp/chromedp/kb"
)
// tidyEditor is a signed-in browser with the editor open on a deck.
@@ -154,3 +155,74 @@ func TestTidyNewSlideStaysInView(t *testing.T) {
}
te.rig.Screen(`[slides-strip-nav]`, "the strip with the layouts open")
}
+
+// TestTidyViewSwitch (spec §3): the three icons and the View menu's
+// three rows each light exactly one view and show the frames it names;
+// ArrowRight from the first icon moves to the next.
+func TestTidyViewSwitch(t *testing.T) {
+ te := openTidyEditor(t, 3, 1280, 720)
+
+ // state: which radios are checked, how the one editable stage is
+ // drawn (full width, the phone's 390px plus its padding, or sharing the
+ // row with the preview; the phone view narrows it to 390px; it is not
+ // the read-only [slides-stage-phone], which only "both" shows), and
+ // whether the read-only phone preview is showing.
+ const state = `(() => {
+ const shown = el => !!el && !el.hidden && getComputedStyle(el).display !== 'none'
+ const checked = [...document.querySelectorAll('input[name="slides-view"]')].filter(i => i.checked).map(i => i.value)
+ const stage = document.querySelector('[data-vp="desktop"]')
+ const w = shown(stage) ? stage.getBoundingClientRect().width : 0
+ const kind = !w ? '' : w > 600 ? 'wide' : w >= 390 && w <= 460 ? 'phone-width' : 'shared'
+ return checked.join(',') + '|' + kind + '|' + (shown(document.querySelector('[slides-stage-phone]')) ? 'preview' : '')
+ })()`
+ want := map[string]string{"desktop": "desktop|wide|", "phone": "phone|phone-width|", "both": "both|shared|preview"}
+ check := func(how, view string) {
+ t.Helper()
+ var got string
+ te.rig.Run(chromedp.Evaluate(state, &got))
+ if got != want[view] {
+ t.Errorf("%s: state is %q, want %q", how, got, want[view])
+ }
+ }
+ center := func(sel string) {
+ var pt struct{ X, Y float64 }
+ te.rig.Run(chromedp.Evaluate(`(() => { const r = document.querySelector('`+sel+`').getBoundingClientRect(); return {X: r.x + r.width / 2, Y: r.y + r.height / 2} })()`, &pt))
+ te.rig.Run(chromedp.MouseClickXY(pt.X, pt.Y))
+ }
+
+ for _, v := range []string{"phone", "both", "desktop"} {
+ center(`[slides-switcher] label:has(input[value="` + v + `"])`)
+ te.rig.Run(waitFor(fmt.Sprintf(`document.querySelector('[slides-stage-pane]').dataset.view === %q`, v)))
+ check("clicking the "+v+" icon", v)
+ }
+
+ // ArrowRight from the first (focused) moves to the second.
+ te.rig.Run(chromedp.Focus(`input[name="slides-view"][value="desktop"]`, chromedp.ByQuery), chromedp.KeyEvent(kb.ArrowRight))
+ te.rig.Run(waitFor(`document.querySelector('[slides-stage-pane]').dataset.view === 'phone'`))
+ check("ArrowRight from the first icon", "phone")
+
+ // The View menu's rows do the same.
+ for _, v := range []string{"both", "desktop", "phone"} {
+ te.rig.Run(chromedp.Evaluate(`document.querySelector('[data-view-choice="`+v+`"]').click()`, nil))
+ te.rig.Run(waitFor(fmt.Sprintf(`document.querySelector('[slides-stage-pane]').dataset.view === %q`, v)))
+ check("the View menu's "+v+" row", v)
+ }
+
+ // One pill: each segment is at least 24x24, the pill's ends are
+ // rounded and its two inner joins square.
+ var pill string
+ te.rig.Run(chromedp.Evaluate(`(() => {
+ const items = [...document.querySelectorAll('[slides-switcher] > label')], out = []
+ items.forEach((l, i) => {
+ const r = l.getBoundingClientRect(), s = getComputedStyle(l)
+ if (r.width < 24 || r.height < 24) out.push(i + ' is ' + r.width + 'x' + r.height)
+ const left = parseFloat(s.borderStartStartRadius) > 0, right = parseFloat(s.borderStartEndRadius) > 0
+ if (left !== (i === 0) || right !== (i === items.length - 1)) out.push(i + ' corners: left ' + left + ', right ' + right)
+ })
+ return out.join('; ')
+ })()`, &pill))
+ if pill != "" {
+ t.Errorf("the view switch is not one pill of 24px targets: %s", pill)
+ }
+ te.rig.Screen(`[slides-stage-bar]`, "the view switch")
+}
diff --git a/internal/slidestest/editor_tidy_test.go b/internal/slidestest/editor_tidy_test.go
index ae4b12e..6183dbe 100644
--- a/internal/slidestest/editor_tidy_test.go
+++ b/internal/slidestest/editor_tidy_test.go
@@ -96,3 +96,46 @@ func TestEditorTidyNewSlideInStripFoot(t *testing.T) {
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>"):])
}
}
+
+// TestEditorTidyViewSwitchIsThreeIconRadios (spec §3): the view switch
+// is still three radios named slides-view, each inside an estilo-seg
+// item label with an accessible name, a tooltip and an icon.
+func TestEditorTidyViewSwitchIsThreeIconRadios(t *testing.T) {
+ a := newApp(t)
+ cookies := signedIn(t, a, allowedAddress)
+ page := mustGet(t, a, deckWithSlides(t, a, cookies, 2), http.StatusOK, cookies).Body.String()
+
+ if n := strings.Count(page, `name="slides-view"`); n != 3 {
+ t.Fatalf("the editor has %d name=\"slides-view\" radios, want 3", n)
+ }
+ set := regexp.MustCompile(`(?s)<fieldset slides-switcher estilo-seg>.*?</fieldset>`).FindString(page)
+ if set == "" {
+ t.Fatal("no <fieldset slides-switcher estilo-seg> in the editor")
+ }
+ for _, c := range []struct{ value, name, title string }{
+ {"desktop", "Desktop", "Desktop"},
+ {"phone", "Phone", "Phone"},
+ {"both", "Both, side by side", "Both, side by side"},
+ } {
+ var label string
+ for _, l := range regexp.MustCompile(`(?s)<label estilo-seg-item.*?</label>`).FindAllString(set, -1) {
+ if strings.Contains(l, `<input type="radio" name="slides-view" value="`+c.value+`"`) {
+ label = l
+ }
+ }
+ if label == "" {
+ t.Errorf("no estilo-seg-item label wrapping the %q radio in:\n%s", c.value, set)
+ continue
+ }
+ open := label[:strings.Index(label, ">")+1]
+ if !strings.Contains(open, `aria-label="`+c.name+`"`) {
+ t.Errorf("%s: label has no aria-label=%q: %s", c.value, c.name, open)
+ }
+ if !strings.Contains(open, `title="`+c.title+`"`) {
+ t.Errorf("%s: label has no title=%q: %s", c.value, c.title, open)
+ }
+ if !strings.Contains(label, `<svg class="icon"`) {
+ t.Errorf("%s: label has no icon: %s", c.value, label)
+ }
+ }
+}