mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-12 10:53:51 +00:00
ba782d5d22
Fixes issues with approximating timers in the app views
33 lines
793 B
React
33 lines
793 B
React
import { memo } from 'react';
|
|
import { formatDisplay } from 'common/utils/dateConfig';
|
|
import PropTypes from 'prop-types';
|
|
import styles from './Countdown.module.css';
|
|
|
|
const Countdown = ({ time, small, isNegative, hideZeroHours }) => {
|
|
// prepare display string
|
|
const display =
|
|
time != null && !isNaN(time)
|
|
? formatDisplay(time, hideZeroHours)
|
|
: '-- : -- : --';
|
|
|
|
const colour = isNegative ? '#ff7597' : '#fffffa';
|
|
|
|
return (
|
|
<div
|
|
className={small ? styles.countdownClockSmall : styles.countdownClock}
|
|
style={{ color: colour }}
|
|
>
|
|
{display}
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export default memo(Countdown);
|
|
|
|
Countdown.propTypes = {
|
|
time: PropTypes.number.isRequired,
|
|
small: PropTypes.bool,
|
|
isNegative: PropTypes.bool,
|
|
hideZeroHour: PropTypes.bool,
|
|
};
|