Veto-Timer als Leiste in Teamfarbe
Die verbleibende Zeit des Veto-Schritts erscheint als Leiste mit Sekundenanzeige, in den letzten 10 Sekunden rot. Der Server schickt die Schrittdauer mit, damit die Leiste zu VETO_STEP_SECONDS passt. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
364c0b57c2
commit
d560c15fef
3 files changed
+20
-2
No files matched your search
@@ -39,7 +39,7 @@ export default function VetoBoard({ state, viewer, act, busy, compact = false })
|
||||
? 'Live-Ansicht – nur Captains können wählen.'
|
||||
: 'Das andere Team ist am Zug.'}
|
||||
</span>
|
||||
{left !== null && <span className="turn-timer">Noch {Math.ceil(left / 1000)} s</span>}
|
||||
{left !== null && <TimerBar left={left} totalMs={(veto.stepSeconds || 30) * 1000} />}
|
||||
</div>
|
||||
)}
|
||||
{!current && veto.done && !compact && <div className="turn turn-done">Veto abgeschlossen</div>}
|
||||
@@ -132,6 +132,18 @@ function statusText(m, teams) {
|
||||
}
|
||||
}
|
||||
|
||||
/** Leiste für die verbleibende Zeit des Veto-Schritts. In den letzten 10 Sekunden wird sie rot. */
|
||||
function TimerBar({ left, totalMs }) {
|
||||
const seconds = Math.ceil(left / 1000);
|
||||
const percent = Math.max(0, Math.min(100, (left / totalMs) * 100));
|
||||
return (
|
||||
<div className={`turn-timer ${left <= 10_000 ? 'is-low' : ''}`} role="timer" aria-label={`Noch ${seconds} Sekunden`}>
|
||||
<div className="turn-bar"><span style={{ width: `${percent}%` }} /></div>
|
||||
<span className="turn-seconds">{seconds} s</span>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
/** Verbleibende Zeit des Veto-Schritts: der Server setzt sie bei jeder Änderung, danach zählt die Anzeige lokal herunter. */
|
||||
function useCountdown(ms) {
|
||||
const [left, setLeft] = useState(ms ?? null);
|
||||
|
||||
@@ -523,4 +523,9 @@ input:focus, select:focus { border-color: var(--link); outline: none; }
|
||||
.admin-tab:hover { color: var(--text); }
|
||||
.admin-tab.is-active { color: var(--text); border-bottom-color: var(--primary); }
|
||||
|
||||
.turn-timer { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; }
|
||||
.turn-timer { grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; margin-top: 8px; }
|
||||
.turn-bar { flex: 1; height: 6px; border-radius: 3px; background: color-mix(in srgb, var(--team) 18%, transparent); overflow: hidden; }
|
||||
.turn-bar span { display: block; height: 100%; background: var(--team); transition: width .25s linear; }
|
||||
.turn-seconds { min-width: 3ch; text-align: right; color: var(--muted); font-size: .875rem; font-variant-numeric: tabular-nums; }
|
||||
.turn-timer.is-low .turn-bar span { background: var(--error); }
|
||||
.turn-timer.is-low .turn-seconds { color: var(--error); font-weight: 600; }
|
||||
Reference in new issue
Block a user