feat: Add Operator List

This commit is contained in:
arihanv
2023-07-03 00:22:10 -05:00
parent 7a6158584a
commit 50f7bd1227
8 changed files with 116 additions and 13 deletions
@@ -1,4 +1,5 @@
// remember we are targeting phones and tablets // remember we are targeting phones and tablets
.operator { .operator {
width: 100vw; width: 100vw;
height: 100vh; height: 100vh;
@@ -7,10 +8,19 @@
display: flex; display: flex;
flex-direction: column; flex-direction: column;
gap: 2px; gap: 2px;
color:white;
}
.allBlocks{
flex: 1;
overflow: scroll;
} }
@mixin event-block() { @mixin event-block() {
padding: 0.5rem; padding: 0.2rem;
display: flex;
gap: 0.75rem;
align-items: center;
} }
.scheduledEvent { .scheduledEvent {
@@ -20,5 +30,5 @@
.block { .block {
@include event-block(); @include event-block();
background-color: wheat; background-color: gray;
} }
@@ -3,8 +3,9 @@ import { SupportedEvent } from 'ontime-types';
import useRundown from '../../common/hooks-query/useRundown'; import useRundown from '../../common/hooks-query/useRundown';
import style from './Operator.module.scss'; import style from './Operator.module.scss';
import OpEvent from './op-event/OpEvent';
import OpBlock from './op-block/OpBlock'; import OpBlock from './op-block/OpBlock';
import TimeBlock from './time-block/TimeBlock';
export default function Operator() { export default function Operator() {
// this is the data that you need, the status flag should give you possibility to create a loading state // this is the data that you need, the status flag should give you possibility to create a loading state
@@ -17,6 +18,7 @@ export default function Operator() {
return ( return (
<div className={style.operator}> <div className={style.operator}>
<div className={style.allBlocks}>
{data.map((entry) => { {data.map((entry) => {
// there are three types of events, you a filter them by using the type property // there are three types of events, you a filter them by using the type property
// for this view, we do not show the delay event // for this view, we do not show the delay event
@@ -25,23 +27,24 @@ export default function Operator() {
if (entry.type === SupportedEvent.Event) { if (entry.type === SupportedEvent.Event) {
return ( return (
<div key={entry.id} className={style.scheduledEvent}> <div key={entry.id} className={style.scheduledEvent}>
<OpBlock entry={JSON.stringify(entry, null, 2)} /> <OpEvent data={entry} />
</div> </div>
); );
} }
// this is a block entry (like a section title) // this is a block entry (like a section title)
if (entry.type === SupportedEvent.Block) { if (entry.type === SupportedEvent.Block) {
return ( return (
<div key={entry.id} className={style.block}> <div key={entry.id} className={style.block}>
{/* {JSON.stringify(entry, null, 2)} */} <OpBlock data={entry} />
<OpBlock entry={JSON.stringify(entry, null, 2)} />
</div> </div>
); );
} }
return null; return null;
})} })}
</div>
<TimeBlock/>
</div> </div>
); );
} }
@@ -0,0 +1,3 @@
.title{
font-size: 1rem;
}
@@ -1,11 +1,13 @@
import style from './OpBlock.module.scss'; import style from './OpBlock.module.scss';
type Props = { type Props = {
entry: string; data: any;
} };
export default function OpBlock({entry}: Props) { export default function OpBlock({ data }: Props) {
return ( return (
<div>OpBlock</div> <>
) <div className={style.title}>{data.title}</div>
} </>
);
}
@@ -0,0 +1,27 @@
.alias{
background-color: red;
width: fit-content;
height: fit-content;
padding: 0.2rem;
align-items: center;
}
.title{
font-size: 1rem;
}
.time{
display: flex;
flex-direction: column;
font-size: 0.65rem;
text-align: right;
}
.time > div {
margin-bottom: -4px; /* Adjust the value as needed */
}
.title{
flex: 1;
}
@@ -0,0 +1,26 @@
import { EventData } from 'ontime-types';
import style from './OpEvent.module.scss';
import { formatTime } from '../../../common/utils/time';
type Props = {
data: any;
};
export default function OpEvent({ data }: Props) {
const start = formatTime(data.timeStart, { format: 'hh:mm' });
const end = formatTime(data.timeEnd, { format: 'hh:mm' });
return (
<>
<div className={style.alias}>{data.note}</div>
<div className={style.title}>
{data.title} - {data.subtitle}
</div>
<div className={style.time}>
<div>
{start} - {end}
</div>
--:--:--
</div>
</>
);
}
@@ -0,0 +1,12 @@
.block{
padding: 0.65rem;
border: 1px solid hotpink;
display: flex;
justify-content: space-between;
}
.clock{
display: flex;
gap: 1.5rem;
margin-right:1rem;
}
@@ -0,0 +1,20 @@
import styles from './TimeBlock.module.scss';
import { Play } from 'lucide-react';
import { useTimer } from '../../../common/hooks/useSocket';
import { formatTime } from '../../../common/utils/time';
type Props = {};
export default function TimeBlock({}: Props) {
const timer = useTimer();
const timeNow = formatTime(timer.clock, {
showSeconds: true,
format: 'hh:mm:ss a',
});
return (
<div className={styles.block}>
<Play size={17} />
<div className={styles.clock}>{timeNow} <div>00:10:00</div></div>
</div>
);
}