Big entry qr comes back while a closed vote waits for its results; progress ring fill uses real dash lengths (pathLength broke on some android webviews)

This commit is contained in:
2026-11-17 14:17:37 +01:00
parent 0697c27a01
commit cbc8fe9e98
3 changed files with 17 additions and 9 deletions
+3 -3
View File
@@ -128,12 +128,12 @@ button:disabled { opacity: .35; cursor: not-allowed; transform: none; }
.ring { display: block; overflow: visible; } .ring { display: block; overflow: visible; }
.ring .seg, .ring .fill { fill: none; stroke-linecap: round; } .ring .seg, .ring .fill { fill: none; stroke-linecap: round; }
.ring .seg { stroke: var(--line); } .ring .seg { stroke: var(--line); }
/* empty fill sits one length ahead and hidden, so the round cap dot doesn't show */ /* empty fill sits one length ahead (offset set in js) and hidden, so the round cap dot doesn't show */
.ring .fill { .ring .fill {
stroke: var(--ink); stroke-dasharray: 1 1; stroke-dashoffset: 1; opacity: 0; stroke: var(--ink); opacity: 0;
transition: stroke-dashoffset .5s cubic-bezier(.3, .7, .2, 1), opacity .12s, stroke .22s; transition: stroke-dashoffset .5s cubic-bezier(.3, .7, .2, 1), opacity .12s, stroke .22s;
} }
.ring .fill.on { stroke-dashoffset: 0; opacity: 1; } .ring .fill.on { opacity: 1; }
.ring .fill.last { stroke: var(--mark); } .ring .fill.last { stroke: var(--mark); }
@media (prefers-reduced-motion: reduce) { .ring .fill { transition: opacity .2s, stroke .2s; } } @media (prefers-reduced-motion: reduce) { .ring .fill { transition: opacity .2s, stroke .2s; } }
.ring text { font: 700 20px var(--round); fill: var(--ink); } .ring text { font: 700 20px var(--round); fill: var(--ink); }
+8 -2
View File
@@ -180,13 +180,18 @@ export function ring(n, total, size = 160, label = `${n}/${total}`) {
for (let i = 0; i < total; i++) { for (let i = 0; i < total; i++) {
const s0 = i * slot + (gap + sw) / 2; const s0 = i * slot + (gap + sw) / 2;
const d = `M ${at(s0)} A ${r} ${r} 0 ${seg / r > Math.PI ? 1 : 0} 1 ${at(s0 + seg)}`; const d = `M ${at(s0)} A ${r} ${r} 0 ${seg / r > Math.PI ? 1 : 0} 1 ${at(s0 + seg)}`;
// track underneath, fill on top sweeps clockwise through pathLength 1 // track underneath, fill on top sweeps clockwise. dash lengths in real units: some android webviews
// mishandle pathLength and draw the fill whole or not at all
for (const cls of ["seg", "fill"]) { for (const cls of ["seg", "fill"]) {
const el = document.createElementNS(SVGNS, "path"); const el = document.createElementNS(SVGNS, "path");
el.setAttribute("d", d); el.setAttribute("d", d);
el.setAttribute("stroke-width", sw); el.setAttribute("stroke-width", sw);
el.setAttribute("class", cls); el.setAttribute("class", cls);
if (cls === "fill") { el.setAttribute("pathLength", 1); fills.push(el); } if (cls === "fill") {
el.style.strokeDasharray = `${seg} ${seg + sw * 2}`;
el.style.strokeDashoffset = String(seg);
fills.push(el);
}
svg.append(el); svg.append(el);
} }
} }
@@ -199,6 +204,7 @@ export function ring(n, total, size = 160, label = `${n}/${total}`) {
fills.forEach((el, i) => { fills.forEach((el, i) => {
el.classList.toggle("on", i < k); el.classList.toggle("on", i < k);
el.classList.toggle("last", i === k - 1 && k < total); el.classList.toggle("last", i === k - 1 && k < total);
el.style.strokeDashoffset = String(i < k ? 0 : seg);
}); });
t.textContent = text; t.textContent = text;
}; };
+6 -4
View File
@@ -34,22 +34,24 @@ function layout() {
if (!st) return; if (!st) return;
// qr stays up while enrolling, and during a vote that needs a presence scan // qr stays up while enrolling, and during a vote that needs a presence scan
const qrOn = st.enrollment_open || st.presence; const qrOn = st.enrollment_open || st.presence;
const focus = st.focus; const ring = st.code_style === "ring";
const entryOn = !!(ring && st.enrollment_open && entry);
// a closed vote whose results aren't shown has nothing to say: with the big entry qr on, it steps aside
const f = st.focus, idleVote = f && f.state === "closed" && !f.results;
const focus = idleVote && entryOn && st.entry_big ? null : f;
reveal($("#enroll"), qrOn); reveal($("#enroll"), qrOn);
reveal($("#focus"), !!focus); reveal($("#focus"), !!focus);
reveal($("#idle"), !qrOn && !focus); reveal($("#idle"), !qrOn && !focus);
$(".s-main").classList.toggle("split", qrOn && !!focus); $(".s-main").classList.toggle("split", qrOn && !!focus);
document.body.classList.toggle("split-on", qrOn && !!focus); document.body.classList.toggle("split-on", qrOn && !!focus);
const ring = st.code_style === "ring";
// a vote waiting for presence scans takes the title, even while late arrivals can still enroll // a vote waiting for presence scans takes the title, even while late arrivals can still enroll
$("#qr-title").textContent = st.presence || !st.enrollment_open ? (ring ? "Visez le cercle pour voter" : "Scannez pour voter") : "Inscription"; $("#qr-title").textContent = st.presence || !st.enrollment_open ? (ring ? "Visez le cercle pour voter" : "Scannez pour voter") : "Inscription";
$("#qr-steps").hidden = !st.enrollment_open; $("#qr-steps").hidden = !st.enrollment_open;
// rings can't be opened by the camera app, so a small fixed qr leads to the page // rings can't be opened by the camera app, so a small fixed qr leads to the page
$("#step1").textContent = ring ? "Ouvrez la page de vote" : "Scannez ce code"; $("#step1").textContent = ring ? "Ouvrez la page de vote" : "Scannez ce code";
const entryOn = !!(ring && st.enrollment_open && entry);
reveal($("#entry"), entryOn); reveal($("#entry"), entryOn);
document.body.classList.toggle("has-entry", entryOn); document.body.classList.toggle("has-entry", entryOn);
// big entry qr next to the ring (start of a meeting), back to the corner once a question is up // big entry qr next to the ring (start of a meeting, between votes), back to the corner while a question is up
const big = entryOn && st.entry_big && !focus; const big = entryOn && st.entry_big && !focus;
document.body.classList.toggle("entry-big", big); document.body.classList.toggle("entry-big", big);
$("#entry-hint").textContent = big ? "Scannez ici, puis visez le cercle" : "Pas encore sur la page ?"; $("#entry-hint").textContent = big ? "Scannez ici, puis visez le cercle" : "Pas encore sur la page ?";