Merge pull request #3 from cpvalente/feat/roll

Feat/roll
This commit is contained in:
Carlos Valente
2021-05-26 23:12:55 +02:00
committed by GitHub
9 changed files with 210 additions and 53 deletions
@@ -41,10 +41,7 @@ const Transport = ({ selectedId, playbackControl }) => {
<div className={style.playbackContainer}>
<PrevIconBtn clickhandler={() => playbackControl('previous')} />
<NextIconBtn clickhandler={() => playbackControl('next')} />
<UnloadIconBtn
clickhandler={() => playbackControl('unload')}
disabled={!selectedId}
/>
<UnloadIconBtn clickhandler={() => playbackControl('unload')} />
<ReloadIconButton
clickhandler={() => playbackControl('reload')}
disabled={!selectedId}
@@ -90,6 +90,7 @@ export default function PlaybackControl() {
<div className={style.mainContainer}>
<PlaybackTimer
timer={timer}
playback={playback}
handleIncrement={(amount) => socket.emit('increment-timer', amount)}
/>
<PlaybackButtons
@@ -35,18 +35,19 @@
height: 100%;
display: flex;
flex-direction: column;
justify-content: space-around;
justify-content: space-evenly;
}
.indRoll,
.indDelay,
.indNegative {
background-color: rgba(0, 0, 0, 0.05);
margin: 0 auto;
}
.indRoll,
.indRollActive,
.indDelay {
margin: 0 auto;
border-radius: 50%;
width: 0.8em;
height: 0.8em;
@@ -60,7 +61,7 @@
.indNegativeActive {
margin: 0 auto;
width: 90%;
height: 0.3em
height: 0.3em;
}
.indNegativeActive {
+26 -8
View File
@@ -8,16 +8,18 @@ const areEqual = (prevProps, nextProps) => {
return (
prevProps.timer.running === nextProps.timer.running &&
prevProps.timer.expectedFinish === nextProps.timer.expectedFinish &&
prevProps.timer.startedAt === nextProps.timer.startedAt
prevProps.timer.startedAt === nextProps.timer.startedAt &&
prevProps.playback === nextProps.playback
);
};
const PlaybackTimer = ({ timer, handleIncrement }) => {
const PlaybackTimer = (props) => {
const { timer, playback, handleIncrement } = props;
const started = stringFromMillis(timer.startedAt, true);
const finish = stringFromMillis(timer.expectedFinish, true);
const isNegative = timer.running < 0;
const isDelayed = false;
const isRolling = false;
const isRolling = playback === 'roll';
const incrementProps = {
size: 'sm',
@@ -31,7 +33,7 @@ const PlaybackTimer = ({ timer, handleIncrement }) => {
<>
<div className={style.timeContainer}>
<div className={style.indicators}>
<div className={style.indRoll} />
<div className={isRolling ? style.indRollActive : style.indRoll} />
<div
className={isNegative ? style.indNegativeActive : style.indNegative}
/>
@@ -49,16 +51,32 @@ const PlaybackTimer = ({ timer, handleIncrement }) => {
<span className={style.time}>{finish}</span>
</div>
<div className={style.btn}>
<Button {...incrementProps} onClick={() => handleIncrement(-1)}>
<Button
{...incrementProps}
disabled={isRolling}
onClick={() => handleIncrement(-1)}
>
-1
</Button>
<Button {...incrementProps} onClick={() => handleIncrement(1)}>
<Button
{...incrementProps}
disabled={isRolling}
onClick={() => handleIncrement(1)}
>
+1
</Button>
<Button {...incrementProps} onClick={() => handleIncrement(-5)}>
<Button
{...incrementProps}
disabled={isRolling}
onClick={() => handleIncrement(-5)}
>
-5
</Button>
<Button {...incrementProps} onClick={() => handleIncrement(5)}>
<Button
{...incrementProps}
disabled={isRolling}
onClick={() => handleIncrement(5)}
>
+5
</Button>
</div>
+2 -2
View File
@@ -37,7 +37,7 @@ const withSocket = (Component) => {
});
const [timer, setTimer] = useState({
clock: null,
currentSeconds: null,
running: null,
startedAt: null,
expectedFinish: null,
});
@@ -221,7 +221,7 @@ const withSocket = (Component) => {
// get clock string
const timeManager = {
...timer,
finished: timer.running <= 0 && timer.startedAt,
finished: playback === 'start' && timer.running <= 0 && timer.startedAt,
clock: stringFromMillis(timer.clock),
playstate: playback,
};
@@ -14,10 +14,9 @@ export default function PresenterView(props) {
document.title = 'ontime - Speaker Screen';
}, []);
const showOverlay = pres.text !== '' && pres.visible;
const isPlaying = time.playstate === 'start';
const isPlaying = time.playstate !== 'pause';
const normalisedTime = Math.max(time.running, 0);
// motion
const titleVariants = {
@@ -61,7 +60,7 @@ export default function PresenterView(props) {
<div className={style.finished}>TIME UP</div>
) : (
<div className={isPlaying ? style.countdown : style.countdownPaused}>
<Countdown time={time.currentSeconds} hideZeroHours />
<Countdown time={normalisedTime} hideZeroHours />
</div>
)}
</div>
@@ -73,7 +72,7 @@ export default function PresenterView(props) {
}
>
<MyProgressBar
now={time.currentSeconds}
now={normalisedTime}
complete={time.durationSeconds}
showElapsed
/>