2026-10-16 01:39:36 +03:00
|
|
|
import * as React from 'react';
|
|
|
|
|
import { FunctionComponent } from 'react';
|
2026-10-16 09:41:47 +03:00
|
|
|
import { CLOCK_LOW_TIME_MS, formatClock } from "@mancala/core";
|
2026-10-16 01:39:36 +03:00
|
|
|
|
2026-10-16 09:41:47 +03:00
|
|
|
// One player's clock: highlighted while it runs, in a warning colour when the running clock is low.
|
2026-10-16 01:39:36 +03:00
|
|
|
const GameClockView: FunctionComponent<{
|
|
|
|
|
timeMs: number,
|
|
|
|
|
running: boolean,
|
2026-10-16 09:41:47 +03:00
|
|
|
}> = ({ timeMs, running }) => {
|
2026-10-16 01:39:36 +03:00
|
|
|
const lowTime = running && timeMs < CLOCK_LOW_TIME_MS;
|
|
|
|
|
return (
|
2026-10-16 09:41:47 +03:00
|
|
|
<span className={"clock" + (lowTime ? " low" : running ? " run" : "")} role="timer">
|
2026-10-16 01:39:36 +03:00
|
|
|
{formatClock(timeMs)}
|
|
|
|
|
</span>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default GameClockView;
|