redesign clock card on manual submission

This commit is contained in:
Joren de Graaf
2026-10-07 09:46:19 +02:00
parent 686f536676
commit a1662384dc
23 changed files with 77 additions and 5 deletions
+9 -1
View File
@@ -19,6 +19,8 @@
const compassRose = document.querySelector("#manual-compass-rose");
const compassHeading = document.querySelector("#manual-compass-heading");
const reportTime = document.querySelector("#manual-report-time");
const reportHours = document.querySelector("#report-clock-hours");
const reportMinutes = document.querySelector("#report-clock-minutes");
let orientationListener;
let compassUnavailableTimeout;
let compassRotation = null;
@@ -34,7 +36,13 @@
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" });
const parts = new Intl.DateTimeFormat(document.documentElement.lang || undefined, { hour: "2-digit", minute: "2-digit", hourCycle: "h23" }).formatToParts(now);
const hours = parts.find((part) => part.type === "hour")?.value;
const minutes = parts.find((part) => part.type === "minute")?.value;
if (!hours || !minutes || !reportHours || !reportMinutes) return;
reportHours.textContent = hours;
reportMinutes.textContent = minutes;
reportTime.setAttribute("aria-label", `${hours}:${minutes}`);
};
updateReportTime();
if (reportTime) window.setInterval(updateReportTime, 60000);
@@ -151,8 +151,39 @@
.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-report__intro, .dashboard-report .manual-report__intro { margin-bottom: .85rem; }
.report-clock {
box-sizing: border-box;
width: 100%;
max-width: 36rem;
margin: 0 0 1rem;
padding: .65rem .95rem .7rem;
border: 1px solid #69539d;
border-radius: .85rem;
background: linear-gradient(115deg, #17162d, #10182c);
box-shadow: inset 0 1px #ffffff0a;
}
.report-clock__label { color: #cbbce5; font-size: .66rem; font-weight: 750; letter-spacing: .13em; text-transform: uppercase; }
.report-clock__display { display: flex; align-items: end; justify-content: space-between; gap: .75rem; }
.report-clock__time {
display: inline-flex;
align-items: center;
color: #ffbf72;
font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
font-size: clamp(2rem, 9vw, 2.45rem);
font-weight: 700;
line-height: 1.1;
letter-spacing: 0;
font-variant-numeric: tabular-nums;
text-shadow: 0 0 .7rem #ff963b55;
white-space: nowrap;
}
.report-clock__time span { display: inline-block; }
.report-clock__time #report-clock-hours, .report-clock__time #report-clock-minutes { width: 2ch; }
.report-clock__colon { width: 1ch; flex: none; margin-inline: -.08em; line-height: 1; text-align: center; transform: translateY(-.06em); animation: report-clock-blink 2s steps(1, end) infinite; }
.report-clock__now { display: inline-flex; align-items: center; gap: .4rem; flex: none; padding: .2rem .45rem; border: 1px solid #93634d; border-radius: 999px; color: #ffd2a2; font-size: .7rem; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; }
.report-clock__dot { width: .4rem; height: .4rem; border-radius: 50%; background: #ffab5d; }
@keyframes report-clock-blink { 50% { opacity: 0; } }
.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; }
@@ -178,9 +209,10 @@
: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"] .report-clock { border-color: #8b6bab; background: linear-gradient(115deg, #221b37, #182039); }
: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; }
.report-clock__colon { animation: none; opacity: 1; }
}
+5
View File
@@ -4,6 +4,7 @@ import { JSDOM } from "jsdom";
test("compass stays hidden until permission and a heading, then rotates and hides when stopped", async () => {
const dom = new JSDOM(`<!doctype html><html><body>
<time id="manual-report-time"><span id="report-clock-hours">--</span><span class="report-clock__colon">:</span><span id="report-clock-minutes">--</span></time>
<form id="manual-report-form" action="/submit">
<input id="manual-latitude"><input id="manual-longitude">
<input id="manual-direction-degrees"><input id="manual-direction-accuracy">
@@ -32,6 +33,10 @@ test("compass stays hidden until permission and a heading, then rotates and hide
}
try {
await import("../src/scripts/manual-report.js?compass=visual");
const reportTime = window.document.querySelector("#manual-report-time");
assert.match(reportTime.getAttribute("aria-label"), /^\d{2}:\d{2}$/);
assert.equal(reportTime.querySelector(".report-clock__colon").textContent, ":");
assert.match(reportTime.dateTime, /^\d{4}-\d{2}-\d{2}T/);
const compass = window.document.querySelector("#manual-compass");
const rose = window.document.querySelector("#manual-compass-rose");
const button = window.document.querySelector("#manual-capture-direction");