Skip to content

armgit / bento

Public Imported from GitHub
0

Bento, the office suite that fits in a file

Whole-slide comment feedback where the user is looking

nyblnet2bf674f415ad
diff --git a/slides/src/editor/canvas.ts b/slides/src/editor/canvas.ts
index eeccfa06..7523ea4b 100644
--- a/slides/src/editor/canvas.ts
+++ b/slides/src/editor/canvas.ts
@@ -211,16 +211,23 @@ export class SlideCanvas {
this.commentCleanup()
return
}
- this.stage.style.cursor = 'crosshair'
+ this.wrap.style.cursor = 'crosshair' // the whole canvas area, grey included
// live feedback: an amber outline over the element the comment would
- // anchor to, or a pin-dot + coordinates where the point would land
+ // anchor to, a pin-dot + coordinates where the point would land, or the
+ // whole-slide outline plus a cursor-following chip out on the grey
const hl = document.createElement('div')
hl.className = 'ed-comment-hl'
this.stage.appendChild(hl)
+ const chip = document.createElement('div')
+ chip.className = 'ed-comment-chip'
+ chip.textContent = '💬 whole slide'
+ chip.style.display = 'none'
+ this.stage.appendChild(chip)
const cleanup = () => {
this.commentCleanup = null
- this.stage.style.cursor = ''
+ this.wrap.style.cursor = ''
hl.remove()
+ chip.remove()
document.removeEventListener('mousedown', onDown, true)
document.removeEventListener('mousemove', onMove, true)
document.removeEventListener('keydown', onKey, true)
@@ -231,20 +238,28 @@ export class SlideCanvas {
const a = inWrap ? this.commentAnchorAt(ev.clientX, ev.clientY) : null
if (!inWrap) {
hl.style.display = 'none'
+ chip.style.display = 'none'
return
}
hl.style.display = ''
if (!a) {
- // on the canvas but off the slide: the WHOLE SLIDE is the anchor
+ // on the canvas but off the slide: the WHOLE SLIDE is the anchor.
+ // Outline the slide AND pin a chip to the cursor — that's where the
+ // user is looking.
const { width, height } = this.store.doc.size
hl.className = 'ed-comment-hl slide'
hl.style.left = '-3px'
hl.style.top = '-3px'
hl.style.width = `${width * this.scale + 6}px`
hl.style.height = `${height * this.scale + 6}px`
- hl.textContent = 'whole slide'
+ hl.textContent = ''
+ const stageR = this.stage.getBoundingClientRect()
+ chip.style.display = ''
+ chip.style.left = `${ev.clientX - stageR.left + 14}px`
+ chip.style.top = `${ev.clientY - stageR.top + 6}px`
return
}
+ chip.style.display = 'none'
if (a.el) {
hl.className = 'ed-comment-hl element'
hl.style.left = `${a.el.x * this.scale - 3}px`
diff --git a/slides/src/styles.css b/slides/src/styles.css
index 46f69db3..b97efdb6 100644
--- a/slides/src/styles.css
+++ b/slides/src/styles.css
@@ -543,6 +543,18 @@ html, body {
border-radius: 6px;
background: color-mix(in srgb, var(--accent) 8%, transparent);
}
+.ed-comment-chip {
+ position: absolute;
+ z-index: 12;
+ pointer-events: none;
+ background: var(--accent);
+ color: #3a2800;
+ font: 700 10.5px/1 -apple-system, 'Segoe UI', system-ui, sans-serif;
+ padding: 5px 9px;
+ border-radius: 999px;
+ white-space: nowrap;
+ box-shadow: 0 2px 8px rgb(20 30 45 / 0.25);
+}
.ed-comment-hl.slide {
border: 2px dashed var(--accent);
border-radius: 8px;