mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-04 15:08:01 +00:00
7cfe7c0d78
* refactor: remove unused code * feat: add human readable values to message parsing --------- Co-authored-by: Fabian Posenau <fabian@fphome.de> Co-authored-by: cv <34649812+cpvalente@users.noreply.github.com>
34 lines
696 B
TypeScript
34 lines
696 B
TypeScript
import { memo } from 'react';
|
|
import { formatDisplay } from 'ontime-utils';
|
|
|
|
import './TimerDisplay.scss';
|
|
|
|
interface TimerDisplayProps {
|
|
time?: number | null;
|
|
}
|
|
|
|
/**
|
|
* Displays time in ms in formatted timetag
|
|
* @param props
|
|
* @constructor
|
|
*/
|
|
const TimerDisplay = (props: TimerDisplayProps) => {
|
|
const { time } = props;
|
|
|
|
let display = '';
|
|
|
|
if (time === null || typeof time === 'undefined' || isNaN(time)) {
|
|
display = '-- : -- : --';
|
|
} else {
|
|
display = formatDisplay(time);
|
|
}
|
|
|
|
const isNegative = (time ?? 0) < 0;
|
|
|
|
const classes = `timer ${isNegative ? 'timer--finished' : ''}`;
|
|
|
|
return <div className={classes}>{display}</div>;
|
|
};
|
|
|
|
export default memo(TimerDisplay);
|