From 3efb80b802828cb930bc9cd300443a40eb510c89 Mon Sep 17 00:00:00 2001 From: Showdown76py Date: Tue, 17 Nov 2026 12:08:25 +0100 Subject: [PATCH] Vote screen: ring keeps the wider column and title shares a line with the entry qr; camera zoom button where the phone supports it --- static/css/screen.css | 19 ++++++++++--------- static/css/vote.css | 7 ++++++- static/js/vote.js | 20 +++++++++++++++++--- 3 files changed, 33 insertions(+), 13 deletions(-) diff --git a/static/css/screen.css b/static/css/screen.css index 2fe1e85..4e4849b 100644 --- a/static/css/screen.css +++ b/static/css/screen.css @@ -38,17 +38,18 @@ body.screen { font-weight: 700; font-size: .8em; } -/* enrollment + a question at the same time: qr shrinks to the side */ -.s-main.split { grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); gap: 5vw; } +/* a question on screen while the ring is up (vote with presence scans, late enrollment). the back rows read + the ring, so it keeps the wider column and as much height as possible: title and entry qr share one line */ +.s-main.split { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 4vw; } .s-main.split .s-enroll { grid-template-columns: 1fr; justify-items: center; gap: 3vh; } -.s-main.split .s-enroll { grid-template-rows: minmax(0, 1fr) auto; gap: 2vh; height: 100%; } +.s-main.split .s-enroll { grid-template-rows: minmax(0, 1fr) auto; gap: 1.5vh; height: 100%; } .s-main.split .qr-wrap { height: 100%; width: auto; max-width: 100%; max-height: none; } -.s-main.split .entry { margin-top: 1.5vh; } -/* the question owns the screen, the ring keeps the room the step list would take */ .s-main.split #qr-steps { display: none; } -.s-main.split .entry canvas { width: clamp(90px, min(10vw, 15vh), 220px); } -.s-main.split .s-steps { display: grid; justify-items: center; text-align: center; } -.s-main.split .s-steps h2 { font-size: clamp(1.4rem, 2.4vw, 2.6rem); } +.s-main.split .s-steps { display: flex; align-items: center; justify-content: center; gap: 2vw; text-align: left; } +.s-main.split .s-steps h2 { font-size: clamp(1.2rem, 2.1vw, 2.4rem); margin: 0; } +.s-main.split .entry { margin: 0; padding: .8vh .8vw; gap: .8vw; } +.s-main.split .entry canvas { width: clamp(70px, min(7vw, 11vh), 160px); } +.s-main.split .entry div { font-size: clamp(.7rem, .9vw, 1rem); } .s-main.split .s-steps li { font-size: clamp(1rem, 1.5vw, 1.6rem); } .s-focus { align-self: center; max-width: 1400px; width: 100%; margin: 0 auto; } @@ -88,7 +89,7 @@ body.screen { /* upright + question: ring and entry share one row above the question */ .s-main.split .s-enroll { grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: none; height: auto; align-items: center; justify-items: stretch; } .s-main.split .qr-wrap { height: auto; width: 100%; max-height: 38vh; justify-self: center; } - .s-main.split .s-steps { grid-template-columns: auto; justify-items: center; row-gap: 1vh; } + .s-main.split .s-steps { display: grid; grid-template-columns: auto; justify-items: center; row-gap: 1vh; text-align: center; } .s-main.split .s-steps .entry { grid-column: 1; grid-row: auto; } } .qr-wrap.ring .tick { display: none; } diff --git a/static/css/vote.css b/static/css/vote.css index 5312a7c..03a4428 100644 --- a/static/css/vote.css +++ b/static/css/vote.css @@ -76,4 +76,9 @@ dialog .actions button { flex: 1; } display: grid; place-items: center; border: 0; color: #fff; background: rgba(20, 22, 36, .55); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); } -.cam-switch:hover { border: 0; background: rgba(20, 22, 36, .75); } +.cam-switch:hover, .cam-zoom:hover { border: 0; background: rgba(20, 22, 36, .75); } +.cam-zoom { + position: absolute; left: 10px; bottom: 10px; min-width: 44px; height: 44px; padding: 0 12px; border-radius: 22px; + border: 0; color: #fff; background: rgba(20, 22, 36, .55); font: 700 .95rem var(--round); + -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); +} diff --git a/static/js/vote.js b/static/js/vote.js index 46acaab..924f28c 100644 --- a/static/js/vote.js +++ b/static/js/vote.js @@ -104,14 +104,28 @@ function makeScanner(video, onToken, onOther) { setTimeout(loop, Math.max(0, 66 - (performance.now() - t0))); } const swap = h("button", { class: "cam-switch", type: "button", "aria-label": "Changer de caméra", hidden: true }, icon("swap", 20)); - video.parentElement.append(swap); + // sensor zoom (mostly android): a far ring gets real pixels instead of an upscaled 720p crop + const zoom = h("button", { class: "cam-zoom", type: "button", "aria-label": "Zoom", hidden: true }, "1×"); + video.parentElement.append(swap, zoom); + let zooms = [1]; async function attach(s) { stream = s; + const track = s.getVideoTracks()[0]; // not every browser knows focusMode, those ignore it - s.getVideoTracks()[0]?.applyConstraints({ advanced: [{ focusMode: "continuous" }] }).catch(() => {}); + track?.applyConstraints({ advanced: [{ focusMode: "continuous" }] }).catch(() => {}); + const cap = track?.getCapabilities?.().zoom; + zooms = cap && cap.max >= 1.5 ? [1, 2, 3].filter((z) => z >= cap.min && z <= cap.max) : [1]; + zoom.hidden = zooms.length < 2; + zoom.textContent = "1×"; video.srcObject = s; await video.play(); } + zoom.onclick = async () => { + const track = stream?.getVideoTracks()[0]; + if (!track) return; + const next = zooms[(zooms.indexOf(+zoom.textContent.replace("×", "")) + 1) % zooms.length]; + try { await track.applyConstraints({ advanced: [{ zoom: next }] }); zoom.textContent = `${next}×`; } catch { zoom.hidden = true; } + }; swap.onclick = async () => { const cams = rankCameras(await videoInputs()); if (cams.length < 2) return; @@ -146,7 +160,7 @@ function makeScanner(video, onToken, onOther) { stream?.getTracks().forEach((t) => t.stop()); video.srcObject = null; }, - destroy() { swap.remove(); }, + destroy() { swap.remove(); zoom.remove(); }, }; }