manual submission redesign phase F

This commit is contained in:
Joren de Graaf
2026-10-06 19:57:14 +02:00
parent 21bf9c72a7
commit faa466dd69
7 changed files with 73 additions and 13 deletions
@@ -2,8 +2,9 @@
<section class="manual-report" aria-labelledby="manual-report-title">
<header class="manual-report__header">
<p class="eyebrow">{% trans "Quick report" %}</p>
<h2 class="manual-report__title" id="manual-report-title">{% trans "Report fireworks now" %}</h2>
<p class="manual-report__intro">{% trans "Choose how many times you heard fireworks, then send it straight to Pending. The report is timestamped now." %}</p>
<div class="manual-report__heading-row"><span class="manual-report__fire" aria-hidden="true">🔥</span><h2 class="manual-report__title" id="manual-report-title">{% trans "Report fireworks now" %}</h2></div>
<p class="manual-report__intro">{% trans "Did you hear a bang? Report what you heard in a few taps." %}</p>
<p class="manual-report__context"><span aria-hidden="true">◷</span> <time id="manual-report-time">{% trans "Now" %}</time></p>
</header>
<form id="manual-report-form" action="{% url "fireworks_detect:submit_manual_pending" %}" method="post" enctype="multipart/form-data">
{% csrf_token %}
@@ -49,17 +50,19 @@
</section>
</form>
<div id="manual-submission" class="manual-report__submission" aria-live="polite"></div>
<div id="manual-compass" class="manual-compass" role="img" aria-label="{% trans 'Compass direction' %}" hidden>
<div class="manual-compass__dial" aria-hidden="true">
<div id="manual-compass-rose" class="manual-compass__rose">
<span class="manual-compass__north">N</span>
<span class="manual-compass__east">E</span>
<span class="manual-compass__south">S</span>
<span class="manual-compass__west">W</span>
<div id="manual-compass-home">
<div id="manual-compass" class="manual-compass" role="img" aria-label="{% trans 'Compass direction' %}" hidden>
<div class="manual-compass__dial" aria-hidden="true">
<div id="manual-compass-rose" class="manual-compass__rose">
<span class="manual-compass__north">N</span>
<span class="manual-compass__east">E</span>
<span class="manual-compass__south">S</span>
<span class="manual-compass__west">W</span>
</div>
<span class="manual-compass__pointer"></span>
<span class="manual-compass__center"></span>
</div>
<span class="manual-compass__pointer"></span>
<span class="manual-compass__center"></span>
<span id="manual-compass-heading" class="manual-compass__heading"></span>
</div>
<span id="manual-compass-heading" class="manual-compass__heading"></span>
</div>
</section>
+18 -1
View File
@@ -15,8 +15,10 @@
const directionStatus = () => document.querySelector("#manual-direction-status");
const directionPanel = () => document.querySelector("#manual-direction-panel");
const compass = document.querySelector("#manual-compass");
const compassHome = document.querySelector("#manual-compass-home");
const compassRose = document.querySelector("#manual-compass-rose");
const compassHeading = document.querySelector("#manual-compass-heading");
const reportTime = document.querySelector("#manual-report-time");
let orientationListener;
let compassUnavailableTimeout;
let compassRotation = null;
@@ -25,6 +27,14 @@
const isUsableNumber = (value) => Number.isFinite(value);
const cardinalDirection = (heading) => ["N", "NE", "E", "SE", "S", "SW", "W", "NW"][Math.floor(((heading + 22.5) % 360) / 45)];
const displayDegrees = (value) => Number(value.toFixed(1)).toString();
const updateReportTime = () => {
if (!reportTime) return;
const now = new Date();
reportTime.dateTime = now.toISOString();
reportTime.textContent = now.toLocaleTimeString(document.documentElement.lang || undefined, { hour: "2-digit", minute: "2-digit" });
};
updateReportTime();
if (reportTime) window.setInterval(updateReportTime, 60000);
const idleSubmitLabel = submitLabel?.textContent || "I heard fireworks";
const setSubmissionState = (next, message = "") => {
@@ -198,10 +208,17 @@
manualForm.addEventListener("click", (event) => {
if (event.target.closest("#manual-capture-direction")) captureDirection();
if (event.target.closest(".manual-direction-panel__close")) stopCompassReading();
if (event.target.closest(".manual-direction-panel__close")) {
stopCompassReading();
if (compassHome) compassHome.append(compass);
}
});
document.body.addEventListener("htmx:beforeSwap", (event) => {
if (event.detail.target?.id === "manual-direction-panel" && compassHome) compassHome.append(compass);
});
document.body.addEventListener("htmx:afterSwap", (event) => {
if (event.detail.target?.id !== "manual-direction-panel") return;
if (captureDirectionButton()) directionPanel().querySelector(".manual-direction-panel__copy")?.after(compass);
const summary = document.querySelector("#manual-direction-summary");
if (summary && directionDegrees.value !== "") {
const heading = Number(directionDegrees.value);
@@ -141,3 +141,39 @@
.manual-report__stepper { grid-template-columns: 3rem minmax(0, 1fr) 3rem; gap: .25rem; }
.manual-report__stepper button { width: 3rem; min-height: 3rem; }
}
.manual-report__heading-row { display: flex; align-items: center; gap: .7rem; }
.manual-report__fire { flex: none; font-size: clamp(1.8rem, 5vw, 2.5rem); filter: drop-shadow(0 .2rem .65rem #ff703b88); }
.manual-report__context { display: flex; align-items: center; gap: .35rem; margin: -.65rem 0 1.25rem; color: #bdafd8; font-size: .88rem; font-variant-numeric: tabular-nums; }
.manual-report__context span { font-size: 1.1rem; }
.manual-direction-panel__open { width: 100%; text-align: left; }
.manual-direction-panel--open .manual-compass { width: 100%; margin: .5rem auto 1rem; }
.manual-direction-panel--open .manual-compass__dial { width: min(100%, 12rem); border-color: #8b67d4; background: radial-gradient(circle, #302054 0 20%, #17132d 70%); box-shadow: 0 0 0 .35rem #6640a228, 0 0 2rem #ac6aff35; }
.manual-direction-panel--open .manual-compass__pointer { border-bottom-color: #ff925f; }
.manual-direction-panel--open .manual-compass__heading { font-size: 1.1rem; }
.manual-report__stepper button, .manual-direction-panel__open, .manual-direction-panel__close, .manual-report__submit { transition: transform .15s ease, box-shadow .15s ease, filter .15s ease; }
.manual-report__stepper button:not(:disabled):active, .manual-direction-panel__open:active, .manual-report__submit:not(:disabled):active { transform: scale(.97); }
.manual-report__submit:not(:disabled):hover { filter: brightness(1.05); }
.manual-submission--success .manual-submission__icon { animation: manual-confirm .35s ease-out both; }
@keyframes manual-confirm { from { transform: scale(.75); opacity: .3; } to { transform: scale(1); opacity: 1; } }
:root[data-theme="dark"] .home-grid .manual-report,
:root[data-theme="dark"] .dashboard-report { border-color: #7256ab; background: radial-gradient(circle at 88% 5%, #58254a55, transparent 13rem), linear-gradient(155deg, #151326, #0d1022 72%); box-shadow: 0 1rem 3rem #02041399; }
:root[data-theme="dark"] .manual-report__title { color: #fff8f3; }
:root[data-theme="dark"] .manual-report__intro { color: #d6cce4; }
:root[data-theme="dark"] .manual-report__quantity { border-color: #514896; background: linear-gradient(145deg, #19183a, #121834); box-shadow: inset 0 0 0 1px #ffffff08; }
:root[data-theme="dark"] .home-grid .manual-direction-panel,
:root[data-theme="dark"] .dashboard-report .manual-direction-panel { border-color: #59499b; background: linear-gradient(145deg, #211945, #151835); }
:root[data-theme="dark"] .manual-report__supporting { border-color: #493d7d; background: linear-gradient(145deg, #15142f, #10162d); }
:root[data-theme="dark"] .manual-report__stepper button { box-shadow: 0 .25rem .7rem #07041655; }
:root[data-theme="dark"] .manual-report__submit { background: linear-gradient(110deg, #ffc276, #ff7654); box-shadow: 0 .55rem 1.35rem #e2633a4d; }
:root[data-theme="dark"] .manual-direction-panel[data-state="measuring"] { border-color: #a27cff; }
:root[data-theme="dark"] .manual-direction-panel[data-state="captured"] { border-color: #68dba1; }
:root[data-theme="dark"] .manual-direction-panel[data-state="unavailable"] { border-color: #d38b7a; }
:root[data-theme="light"] .manual-report__context { color: #70466d; }
:root[data-theme="light"] .manual-direction-panel--open .manual-compass__dial { background: radial-gradient(circle, #f8ebf8 0 25%, #e8d7e9 75%); }
@media (prefers-reduced-motion: reduce) {
.manual-report__stepper button, .manual-direction-panel__open, .manual-direction-panel__close, .manual-report__submit { transition: none; }
.manual-submission--success .manual-submission__icon { animation: none; }
}
@@ -0,0 +1 @@
/* empty css */import"./fireworks-home.js-BqdOneRR.js";import"./map.js-BLPiBo7S.js";import"../../../manual-report-CFrtzjan.js";import"../../../theme-DXAi27ON.js";
@@ -0,0 +1 @@
import"../../../manual-report-CFrtzjan.js";import"../../../theme-DXAi27ON.js";
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long