mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-09 17:33:55 +00:00
dda92ba3a8
* refactor: implement import lint
33 lines
811 B
React
33 lines
811 B
React
import React from 'react';
|
|
import { clamp } from 'app/utils/math';
|
|
import PropTypes from 'prop-types';
|
|
|
|
import styles from './MyProgressBar.module.scss';
|
|
|
|
export default function MyProgressBar(props) {
|
|
const { now, complete, showElapsed } = props;
|
|
|
|
let percentComplete = showElapsed ? 0 : 100;
|
|
|
|
if (now != null && complete != null) {
|
|
percentComplete = showElapsed
|
|
? clamp(100 - (now * 100) / complete, 0, 100)
|
|
: clamp((now * 100) / complete, 0, 100);
|
|
}
|
|
|
|
return (
|
|
<div className={showElapsed ? styles.progress : styles.progressCountdown}>
|
|
<div
|
|
className={styles.progressBar}
|
|
style={{ width: `${percentComplete}%` }}
|
|
/>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
MyProgressBar.propTypes = {
|
|
now: PropTypes.number,
|
|
complete: PropTypes.number,
|
|
showElapsed: PropTypes.bool,
|
|
}
|