Phase 6: scoreboard visibility toggle and reveal mode
- setVisibility: visible / frozen / hidden. Freezing snapshots the scores on the server with the same engine the scoreboard uses; freezing twice keeps the original snapshot. - Reveal mode: start, reveal next (last place first, one click per team), finish (sets visible) and cancel. The host sees who is next; the scoreboard plays a visual drum-roll for teams revealed while watching. - H cycles visibility in the control room. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -36,6 +36,12 @@ export function Scoreboard({ token, initial }: { token: string; initial: Scorebo
|
||||
const socket = useRefreshChannel(channelNames.scoreboard(token), refetch);
|
||||
const connection = fetchFailed || socket === "disconnected" ? "offline" : socket === "connected" ? "live" : "connecting";
|
||||
|
||||
// Teams already revealed when this page loaded appear at once; only teams revealed
|
||||
// while watching get the drum-roll.
|
||||
const [revealedOnLoad] = useState(
|
||||
() => new Set(initial.teams.filter((team) => team.rank !== undefined).map((team) => team.id)),
|
||||
);
|
||||
|
||||
const rowElements = useRef(new Map<string, HTMLElement>());
|
||||
const lastTops = useRef(new Map<string, number>());
|
||||
|
||||
@@ -126,7 +132,7 @@ export function Scoreboard({ token, initial }: { token: string; initial: Scorebo
|
||||
key={team.id}
|
||||
team={team}
|
||||
showScore={!hidden}
|
||||
justRevealed={revealing}
|
||||
drumRoll={revealing && !revealedOnLoad.has(team.id)}
|
||||
register={(element) => {
|
||||
if (element) rowElements.current.set(team.id, element);
|
||||
else rowElements.current.delete(team.id);
|
||||
@@ -164,12 +170,13 @@ export function Scoreboard({ token, initial }: { token: string; initial: Scorebo
|
||||
function TeamRow({
|
||||
team,
|
||||
showScore,
|
||||
justRevealed,
|
||||
drumRoll,
|
||||
register,
|
||||
}: {
|
||||
team: ScoreboardTeam;
|
||||
showScore: boolean;
|
||||
justRevealed: boolean;
|
||||
/** Play the reveal build-up when this row first appears. */
|
||||
drumRoll: boolean;
|
||||
register: (element: HTMLLIElement | null) => void;
|
||||
}) {
|
||||
const isLeader = showScore && team.rank === 1 && (team.total ?? 0) > 0;
|
||||
@@ -179,10 +186,19 @@ function TeamRow({
|
||||
ref={register}
|
||||
// Container units (cqh/cqw) size the text from the row itself, so rows fill the
|
||||
// screen whether there are 3 teams or 12.
|
||||
className={`flex max-h-[20vh] min-h-0 flex-1 basis-0 items-stretch overflow-hidden rounded-[1vh] bg-white/10 [container-type:size] ${
|
||||
className={`relative flex max-h-[20vh] min-h-0 flex-1 basis-0 items-stretch overflow-hidden rounded-[1vh] bg-white/10 [container-type:size] ${
|
||||
isLeader ? "outline-[0.5vh] outline-floodlight outline-solid" : ""
|
||||
} ${justRevealed ? "animate-reveal-in" : ""}`}
|
||||
} ${drumRoll ? "animate-reveal-in" : ""}`}
|
||||
>
|
||||
{drumRoll && (
|
||||
// Visual drum-roll: a shaking "?" covers the row for a beat before the team appears.
|
||||
<div
|
||||
aria-hidden
|
||||
className="reveal-cover absolute inset-0 z-10 flex items-center justify-center rounded-[1vh] border-2 border-dashed border-floodlight bg-stage font-display text-[60cqh] font-bold text-floodlight"
|
||||
>
|
||||
<span className="reveal-shake">?</span>
|
||||
</div>
|
||||
)}
|
||||
<div
|
||||
className="flex aspect-square h-full shrink-0 items-center justify-center font-display text-[62cqh] leading-none font-bold tabular-nums"
|
||||
style={{ backgroundColor: team.color, color: readableTextColor(team.color) }}
|
||||
|
||||
Reference in New Issue
Block a user