style + cleanup

This commit is contained in:
cv
2021-05-26 13:10:23 +02:00
parent d311703025
commit f78c16fb8c
5 changed files with 74 additions and 44 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>
+42 -29
View File
@@ -544,18 +544,12 @@ class EventTimer extends Timer {
if (e == null) return;
// private title is always current
this.titles.titleNow = e.title;
this.titles.subtitleNow = e.subtitle;
this.titles.presenterNow = e.presenter;
this.selectedEventId = e.id;
// check if current is also public
if (e.isPublic) {
this.titlesPublic.titleNow = e.title;
this.titlesPublic.subtitleNow = e.subtitle;
this.titlesPublic.presenterNow = e.presenter;
this.selectedPublicEventId = e.id;
this._loadThisTitles(e, 'now');
} else {
this._loadThisTitles(e, 'now-private');
// assume there is no public event
this.titlesPublic.titleNow = null;
this.titlesPublic.subtitleNow = null;
@@ -571,45 +565,70 @@ class EventTimer extends Timer {
this._eventlist[i].type === 'event' &&
this._eventlist[i].isPublic
) {
this.titlesPublic.titleNow = this._eventlist[i].title;
this.titlesPublic.subtitleNow = this._eventlist[i].subtitle;
this.titlesPublic.presenterNow = this._eventlist[i].presenter;
this.selectedPublicEventId = this._eventlist[i].id;
this._loadThisTitles(this._eventlist[i], 'now-public');
break;
}
}
}
}
_loadThisTitles(eventIndex, type) {
if (eventIndex < 0 || eventIndex >= this.numEvents) return;
const e = this._eventlist[eventIndex];
_loadThisTitles(e, type) {
if (e == null) return;
switch (type) {
// now, load to both public and private
case 'now':
// public
this.titlesPublic.titleNow = e.title;
this.titlesPublic.subtitleNow = e.subtitle;
this.titlesPublic.presenterNow = e.presenter;
this.selectedPublicEventId = e.id;
// private
this.titles.titleNow = e.title;
this.titles.subtitleNow = e.subtitle;
this.titles.presenterNow = e.presenter;
this.selectedEventId = e.id;
break;
case 'now-public':
this.titlesPublic.titleNow = e.title;
this.titlesPublic.subtitleNow = e.subtitle;
this.titlesPublic.presenterNow = e.presenter;
this.selectedPublicEventId = e.id;
break;
case 'now-private':
this.titles.titleNow = e.title;
this.titles.subtitleNow = e.subtitle;
this.titles.presenterNow = e.presenter;
this.selectedEventId = e.id;
break;
// next, load to both public and private
case 'next':
this.titles.titleNext = e.title;
this.titles.subtitleNext = e.subtitle;
this.titles.presenterNext = e.presenter;
this.nextEventId = e.id;
// public
this.titlesPublic.titleNext = e.title;
this.titlesPublic.subtitleNext = e.subtitle;
this.titlesPublic.presenterNext = e.presenter;
this.nextPublicEventId = e.id;
// private
this.titles.titleNext = e.title;
this.titles.subtitleNext = e.subtitle;
this.titles.presenterNext = e.presenter;
this.nextEventId = e.id;
break;
case 'next-public':
this.titlesPublic.titleNext = e.title;
this.titlesPublic.subtitleNext = e.subtitle;
this.titlesPublic.presenterNext = e.presenter;
this.nextPublicEventId = e.id;
break;
case 'next-private':
this.titles.titleNext = e.title;
this.titles.subtitleNext = e.subtitle;
this.titles.presenterNext = e.presenter;
this.nextEventId = e.id;
break;
default:
@@ -641,19 +660,13 @@ class EventTimer extends Timer {
if (this._eventlist[i].type === 'event') {
// if we have not set private
if (!nextPrivate) {
this.titles.titleNext = this._eventlist[i].title;
this.titles.subtitleNext = this._eventlist[i].subtitle;
this.titles.presenterNext = this._eventlist[i].presenter;
this.nextEventId = this._eventlist[i].id;
this._loadThisTitles(this._eventlist[i], 'next-private');
nextPrivate = true;
}
// if event is public
if (this._eventlist[i].isPublic) {
this.titlesPublic.titleNext = this._eventlist[i].title;
this.titlesPublic.subtitleNext = this._eventlist[i].subtitle;
this.titlesPublic.presenterNext = this._eventlist[i].presenter;
this.nextPublicEventId = this._eventlist[i].id;
this._loadThisTitles(this._eventlist[i], 'next-public');
nextPublic = true;
}
}