Home: two-window explainer, code settings tucked away; projector: light entrance and exit motion

This commit is contained in:
2026-11-17 01:46:18 +01:00
parent d4902da7c2
commit efa671a367
5 changed files with 119 additions and 49 deletions
+12
View File
@@ -162,3 +162,15 @@ button:disabled { opacity: .35; cursor: not-allowed; transform: none; }
.code-cell { break-inside: avoid; }
}
.center { text-align: center; }
/* home: the two windows a poll opens */
.duo { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 2px 0 6px; }
.duo > div { display: flex; align-items: center; gap: 12px; background: var(--bg); border-radius: var(--r-field); padding: 12px 14px; }
.duo p { margin: 0; display: grid; gap: 1px; min-width: 0; }
.duo b { font: 700 .92rem var(--round); }
.duo span { font-size: .78rem; color: var(--ink-3); }
label.with-icon { display: flex; align-items: center; gap: 8px; }
details.advanced { margin-top: 14px; }
details.advanced summary { font-size: .82rem; color: var(--ink-3); cursor: pointer; width: fit-content; padding: 4px 0; }
details.advanced summary:hover { color: var(--ink-2); }
details.advanced[open] summary { color: var(--ink-2); }
+25
View File
@@ -88,3 +88,28 @@ body.screen {
.s-main.split .s-steps .entry { grid-column: 1; grid-row: auto; }
}
.qr-wrap.ring .tick { display: none; }
/* light motion: blocks rise in, fade out, the question lands piece by piece, result bars grow */
@keyframes s-in { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes s-out { to { opacity: 0; transform: translateY(-8px); } }
@keyframes s-grow { from { transform: scaleX(0); } }
@keyframes s-bump { 40% { transform: scale(1.18); } }
.s-main:not(.split) > section { grid-area: 1 / 1; }
.s-main > section:not([hidden]), .entry:not([hidden]) { animation: s-in .5s cubic-bezier(.2, .7, .2, 1) both; }
.s-main > section.leaving, .entry.leaving { animation: s-out .22s ease both; }
#focus.enter .q-text { animation: s-in .5s cubic-bezier(.2, .7, .2, 1) both; }
#focus.enter .opts li, #focus.enter .bar-row { animation: s-in .45s cubic-bezier(.2, .7, .2, 1) both; }
#focus.enter :is(.opts li, .bar-row):nth-child(1) { animation-delay: .08s; }
#focus.enter :is(.opts li, .bar-row):nth-child(2) { animation-delay: .14s; }
#focus.enter :is(.opts li, .bar-row):nth-child(3) { animation-delay: .2s; }
#focus.enter :is(.opts li, .bar-row):nth-child(4) { animation-delay: .26s; }
#focus.enter :is(.opts li, .bar-row):nth-child(n+5) { animation-delay: .32s; }
#focus.enter .turnout, #focus.enter .results-foot, #focus.enter .status { animation: s-in .45s .3s cubic-bezier(.2, .7, .2, 1) both; }
#focus.enter .bar-fill { transform-origin: left; animation: s-grow .9s .25s cubic-bezier(.2, .7, .2, 1) both; }
.turnout .progress > div { transition: width .5s cubic-bezier(.2, .7, .2, 1); }
#voters { display: inline-block; }
#voters.bump { animation: s-bump .35s ease; }
@media (prefers-reduced-motion: reduce) {
.s-main > section, .entry, #focus.enter *, #voters.bump { animation: none !important; }
.turnout .progress > div { transition: none; }
}
+28 -22
View File
@@ -14,28 +14,13 @@
<section id="create" class="card">
<h1>Nouveau scrutin</h1>
<div class="duo">
<div><svg class="icon" viewBox="0 0 24 24" width="26" height="26" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M2 4h20"/><path d="M4 4v10h16V4"/><path d="M12 14v3"/><path d="M8.5 21l3.5-4 3.5 4"/></svg><p><b>Projecteur</b><span>Affiché à la salle</span></p></div>
<div><svg class="icon" viewBox="0 0 24 24" width="26" height="26" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M4 5h16v11H4z"/><path d="M2 19.5h20"/><path d="M8 9h8"/><path d="M8 12.5h5"/></svg><p><b>Administration</b><span>Sur votre écran</span></p></div>
</div>
<form id="form">
<label for="title">Titre</label>
<input id="title" type="text" required maxlength="200" placeholder="Assemblée générale 2026">
<div class="row">
<div>
<label for="interval">Rotation du code</label>
<select id="interval">
<option value="500">0,5 s</option>
<option value="700">0,7 s</option>
<option value="800" selected>0,8 s</option>
<option value="1000">1 s</option>
<option value="1500">1,5 s</option>
<option value="2000">2 s</option>
</select>
</div>
<div>
<label for="scans">Codes à scanner</label>
<input id="scans" type="number" min="2" max="20" value="5">
</div>
</div>
<p class="hint" id="duration-hint"></p>
<input id="title" type="text" required maxlength="200" placeholder="Conseil d'administration">
<div class="row">
<div>
@@ -55,6 +40,27 @@
<input id="codes" type="number" min="1" max="5000" value="50">
</div>
<details class="advanced">
<summary>Réglages du code</summary>
<div class="row">
<div>
<label for="interval">Rotation du code</label>
<select id="interval">
<option value="500">0,5 s</option>
<option value="700">0,7 s</option>
<option value="800" selected>0,8 s</option>
<option value="1000">1 s</option>
<option value="1500">1,5 s</option>
<option value="2000">2 s</option>
</select>
</div>
<div>
<label for="scans">Codes à scanner</label>
<input id="scans" type="number" min="2" max="20" value="5">
</div>
</div>
</details>
<div id="pw-box" hidden>
<label for="pw">Mot de passe de création</label>
<input id="pw" type="password" autocomplete="current-password">
@@ -68,9 +74,9 @@
<section id="done" class="card" hidden>
<h1>Scrutin créé</h1>
<div class="notice warn">Conservez le lien d'administration : il ne pourra pas être récupéré.</div>
<label>Lien d'administration</label>
<label class="with-icon"><svg class="icon" viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M4 5h16v11H4z"/><path d="M2 19.5h20"/><path d="M8 9h8"/><path d="M8 12.5h5"/></svg>Lien d'administration</label>
<div class="linkbox"><input id="admin-link" type="text" readonly><button id="copy-admin" class="small" type="button">Copier</button></div>
<label>Lien du projecteur</label>
<label class="with-icon"><svg class="icon" viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M2 4h20"/><path d="M4 4v10h16V4"/><path d="M12 14v3"/><path d="M8.5 21l3.5-4 3.5 4"/></svg>Lien du projecteur</label>
<div class="linkbox"><input id="screen-link" type="text" readonly><button id="copy-screen" class="small" type="button">Copier</button></div>
<p class="hint">Pour l'ordinateur du vidéoprojecteur. Ne pas diffuser.</p>
<div class="actions"><a id="go-admin" class="btn primary block" href="#">Ouvrir l'administration</a></div>
-8
View File
@@ -3,14 +3,6 @@ import { $, api, toast } from "./common.js";
const cfg = await api("GET", "/api/config").catch(() => ({}));
$("#pw-box").hidden = !cfg.create_password;
function hint() {
const s = (+$("#interval").value * +$("#scans").value) / 1000;
$("#duration-hint").textContent = `≈ ${s.toLocaleString("fr-FR")} s de scan`;
}
$("#interval").addEventListener("change", hint);
$("#scans").addEventListener("input", hint);
hint();
$("#codes-on").addEventListener("change", (e) => { $("#codes-box").hidden = !e.target.checked; });
$("#form").addEventListener("submit", async (e) => {
+42 -7
View File
@@ -8,22 +8,43 @@ let qr = null; // current code message, qr or ring
let raf = 0;
let entry = null;
let prevBits = null, switchedAt = 0;
let focusView = "";
// shows at once (css plays the entrance), hides after a short exit so blocks don't just vanish
function reveal(el, on) {
if (on) {
clearTimeout(el._leave);
el.classList.remove("leaving");
el.hidden = false;
return;
}
if (el.hidden || el.classList.contains("leaving")) return;
el.classList.add("leaving");
el._leave = setTimeout(() => { el.hidden = true; el.classList.remove("leaving"); }, 220);
}
// restarts a css animation class on an element that stays in the dom
function replay(el, cls) {
el.classList.remove(cls);
void el.offsetWidth;
el.classList.add(cls);
}
function layout() {
if (!st) return;
// qr stays up while enrolling, and during a vote that needs a presence scan
const qrOn = st.enrollment_open || st.presence;
const focus = st.focus;
$("#enroll").hidden = !qrOn;
$("#focus").hidden = !focus;
$("#idle").hidden = qrOn || !!focus;
reveal($("#enroll"), qrOn);
reveal($("#focus"), !!focus);
reveal($("#idle"), !qrOn && !focus);
$(".s-main").classList.toggle("split", qrOn && !!focus);
const ring = st.code_style === "ring";
$("#qr-title").textContent = st.enrollment_open ? "Inscription" : ring ? "Visez le cercle pour voter" : "Scannez pour voter";
$("#qr-steps").hidden = !st.enrollment_open;
// 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";
$("#entry").hidden = !(ring && st.enrollment_open && entry);
reveal($("#entry"), !!(ring && st.enrollment_open && entry));
$(".qr-wrap").classList.toggle("ring", ring);
}
@@ -31,21 +52,33 @@ function render() {
$("#s-title").textContent = st.title;
$("#idle-title").textContent = st.title;
document.title = st.title;
if ($("#voters").textContent !== String(st.voters)) {
$("#voters").textContent = st.voters;
replay($("#voters"), "bump");
}
$("#voters-label").textContent =
`inscription${st.voters > 1 ? "s" : ""}` + (st.expected ? ` sur ${st.expected}` : "");
$("#secs").textContent = Math.ceil((st.scans_required * st.interval_ms) / 1000);
const f = st.focus;
const box = $("#focus");
box.replaceChildren();
const view = f ? `${f.id}|${f.state}|${f.results ? 1 : 0}|${f.text}` : "";
if (f && view === focusView && f.state === "open") {
// same question still open: only the turnout moves, in place so the bar slides
const t = box.querySelector(".turnout");
t.querySelector("b").textContent = f.participants;
t.querySelector(".t-of").textContent = ` vote${f.participants > 1 ? "s" : ""} sur ${st.voters}`;
t.querySelector(".progress > div").style.width = `${pct(f.participants, st.voters)}%`;
} else if (view !== focusView) {
focusView = view;
if (f) {
box.append(h("div", { class: "q-text" }, f.text));
// the old question fades with the section when there is no new one
box.replaceChildren(h("div", { class: "q-text" }, f.text));
if (f.state === "open") {
box.append(
h("ul", { class: "opts" }, f.options.map((o) => h("li", {}, o))),
h("div", { class: "turnout" },
h("b", {}, f.participants), ` vote${f.participants > 1 ? "s" : ""} sur ${st.voters}`,
h("b", {}, f.participants), h("span", { class: "t-of" }, ` vote${f.participants > 1 ? "s" : ""} sur ${st.voters}`),
h("div", { class: "progress" }, fill(pct(f.participants, st.voters), ""))),
);
} else if (f.results) {
@@ -53,6 +86,8 @@ function render() {
} else {
box.append(h("p", { class: "status" }, `Vote clos, ${f.participants} vote${f.participants > 1 ? "s" : ""}`));
}
replay(box, "enter");
}
}
layout();
}