mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-04 06:58:02 +00:00
2fa397548a
* feat/navigate upgrade react router * feat/navigate migrate to react router 6 * feat/navigate style modal * feat/navigate create endpoints for app settings * feat/navigate protect editor with pin * feat/navigate apply dynamic routing draft * feat/navigate upgrade relevant packages * feat/navigate restructure directory and add tests * feat/navigate test aliases validation * feat/navigate validate aliases before sending * feat/navigate create data endpoint * feat/navigate config: prettier * feat/navigate invalidate empty strings * feat/navigate create endpoints * feat/navigate parse on import * feat/navigate navigate to alias * feat/navigate user help and sample data * feat/navigate refact aliases modal * feat/navigate refact settings style * feat/navigate update sample db * feat/navigate link is relative to hostname * feat/navigate navigate to first match * feat/navigate update readme and version bump * feat/navigate config: create shared module * feat/navigate config: cheat module install * feat/navigate fix tests * feat/navigate run tests in pull request * Update ontime_cy.yml
116 lines
3.5 KiB
React
116 lines
3.5 KiB
React
import style from './PlaybackControl.module.scss';
|
|
import Countdown from 'common/components/countdown/Countdown';
|
|
import { stringFromMillis } from 'ontime-utils/time';
|
|
import {Tooltip} from '@chakra-ui/react';
|
|
import {Button} from '@chakra-ui/button';
|
|
import {memo} from 'react';
|
|
import PropTypes from "prop-types";
|
|
|
|
const areEqual = (prevProps, nextProps) => {
|
|
return (
|
|
prevProps.timer.running === nextProps.timer.running
|
|
&& prevProps.timer.expectedFinish === nextProps.timer.expectedFinish
|
|
&& prevProps.timer.startedAt === nextProps.timer.startedAt
|
|
&& prevProps.playback === nextProps.playback
|
|
&& prevProps.timer.secondary === nextProps.timer.secondary
|
|
&& prevProps.selectedId === nextProps.selectedId
|
|
);
|
|
};
|
|
|
|
const PlaybackTimer = (props) => {
|
|
const {timer, playback, handleIncrement, selectedId} = props;
|
|
const started = stringFromMillis(timer.startedAt, true);
|
|
const finish = stringFromMillis(timer.expectedFinish, true);
|
|
const isNegative = timer.running < 0;
|
|
const isRolling = playback === 'roll';
|
|
const isWaiting = timer.secondary > 0 && timer.running == null;
|
|
const disableButtons = (selectedId == null || isRolling);
|
|
|
|
const incrementProps = {
|
|
size: 'sm',
|
|
width: '2.9em',
|
|
colorScheme: 'whiteAlpha',
|
|
variant: 'outline',
|
|
_focus: {boxShadow: 'none'},
|
|
};
|
|
|
|
return (
|
|
<>
|
|
<div className={style.timeContainer}>
|
|
<div className={style.indicators}>
|
|
<Tooltip label='Roll mode active'>
|
|
<div className={isRolling ? style.indRollActive : style.indRoll}/>
|
|
</Tooltip>
|
|
<div
|
|
className={isNegative ? style.indNegativeActive : style.indNegative}
|
|
/>
|
|
<div className={style.indDelay}/>
|
|
</div>
|
|
<div className={style.timer}>
|
|
<Countdown
|
|
time={isWaiting ? timer.secondary : timer.running}
|
|
small
|
|
negative={isNegative}
|
|
/>
|
|
</div>
|
|
{isWaiting ? (
|
|
<div className={style.roll}>
|
|
<span className={style.rolltag}>Roll: Countdown to start</span>
|
|
<span className={style.time}>{''}</span>
|
|
</div>
|
|
) : (
|
|
<>
|
|
<div className={style.start}>
|
|
<span className={style.tag}>Started at </span>
|
|
<span className={style.time}>{started}</span>
|
|
</div>
|
|
<div className={style.finish}>
|
|
<span className={style.tag}>Finish at </span>
|
|
<span className={style.time}>{finish}</span>
|
|
</div>
|
|
</>
|
|
)}
|
|
<div className={style.btn}>
|
|
<Button
|
|
{...incrementProps}
|
|
disabled={disableButtons}
|
|
onClick={() => handleIncrement(-1)}
|
|
>
|
|
-1
|
|
</Button>
|
|
<Button
|
|
{...incrementProps}
|
|
disabled={disableButtons}
|
|
onClick={() => handleIncrement(1)}
|
|
>
|
|
+1
|
|
</Button>
|
|
<Button
|
|
{...incrementProps}
|
|
disabled={disableButtons}
|
|
onClick={() => handleIncrement(-5)}
|
|
>
|
|
-5
|
|
</Button>
|
|
<Button
|
|
{...incrementProps}
|
|
disabled={disableButtons}
|
|
onClick={() => handleIncrement(5)}
|
|
>
|
|
+5
|
|
</Button>
|
|
</div>
|
|
</div>
|
|
</>
|
|
);
|
|
};
|
|
|
|
export default memo(PlaybackTimer, areEqual);
|
|
|
|
PlaybackTimer.propTypes = {
|
|
timer: PropTypes.object.isRequired,
|
|
playback: PropTypes.string,
|
|
handleIncrement: PropTypes.func.isRequired,
|
|
selectedId: PropTypes.string,
|
|
};
|