Skip to content

armgit / bento

Public Imported from GitHub
0

Bento, the office suite that fits in a file

slides: the slide list steps aside once you have picked a slide (#272)

iamgeo9253319c2822a9
diff --git a/slides/src/editor/editor.ts b/slides/src/editor/editor.ts
index 3f786ffe..202d75ba 100644
--- a/slides/src/editor/editor.ts
+++ b/slides/src/editor/editor.ts
@@ -726,6 +726,29 @@ export class Editor {
// the canvas wrap resizes; its ResizeObserver re-fits the stage
}
+ /**
+ * Below 700px the two side panels stop being columns and become overlay
+ * DRAWERS (styles.css) — they cover the canvas rather than sitting beside it.
+ * That is the width at which "leave the panel open" stops being free.
+ */
+ private get panelsAreDrawers(): boolean {
+ // The 700px here is the SAME constant as fitTopbar()'s phone check and the
+ // `@media (max-width: 700px)` block that turns the panels into drawers —
+ // this asks the panel question, not the topbar one. #239 replaced the bar's
+ // width-breakpoint machinery (a matchMedia `phoneQuery`) with measuring, and
+ // that is why the old `phoneQuery?.matches ??` prefix that used to sit here
+ // no longer compiles. It was only ever a cache of this same comparison.
+ return window.innerWidth <= 700
+ }
+
+ /** Close a panel if it is open — idempotent, unlike togglePanel. */
+ private closePanel(side: 'left' | 'right') {
+ const el = side === 'left' ? this.sidebar : this.props
+ if (el.classList.contains('ed-collapsed')) return
+ el.classList.add('ed-collapsed')
+ this.updatePanelChevrons()
+ }
+
// --- Save dropdown: copy / new deck / template -----------------------------
private saveDropdown(): HTMLElement {
@@ -1582,7 +1605,14 @@ export class Editor {
btn(ICONS.trash, '', (ev) => { ev.stopPropagation(); this.deleteSlide(i) }, t('Delete slide')),
)
item.append(num, surface, tools)
- item.addEventListener('click', () => this.store.goTo(i))
+ item.addEventListener('click', () => {
+ this.store.goTo(i)
+ // On a phone the slide list is a drawer laid OVER the canvas, so picking
+ // a slide left the answer hidden behind the question — you had to find
+ // and press the ☰ toggle again to see the slide you just chose. On a wide
+ // screen the list is a column beside the canvas and rightly stays put.
+ if (this.panelsAreDrawers) this.closePanel('left')
+ })
if (!isState) this.wireThumbDrag(item, i)
return item
}