style: Styling Operator Block (#468)

* Operator Layout
This commit is contained in:
arihanv
2023-07-23 15:17:25 -05:00
committed by GitHub
parent 465550130b
commit bf7ca81e02
6 changed files with 123 additions and 15 deletions
@@ -30,9 +30,21 @@
.scheduledEvent { .scheduledEvent {
@include event-block(); @include event-block();
background-color: $gray-1300; background-color: $gray-1300;
align-items: start;
}
.activeEvent {
border-top: 1.5px white;
border-style: solid;
}
.runningTimer {
border-top: 0.5px white;
border-style: solid;
background-color: $green-700;
} }
.block { .block {
@include event-block(); @include event-block();
background-color: $gray-1350; background-color: $gray-1350;
} }
+24 -5
View File
@@ -1,7 +1,10 @@
import React from 'react';
import { SupportedEvent } from 'ontime-types'; import { SupportedEvent } from 'ontime-types';
import NavigationMenu from '../.././common/components/navigation-menu/NavigationMenu';
import useRundown from '../../common/hooks-query/useRundown'; import useRundown from '../../common/hooks-query/useRundown';
import FocusBlock from './focus-block/focus-block';
import OpBlock from './op-block/OpBlock'; import OpBlock from './op-block/OpBlock';
import OpEvent from './op-event/OpEvent'; import OpEvent from './op-event/OpEvent';
import TimeBlock from './time-block/TimeBlock'; import TimeBlock from './time-block/TimeBlock';
@@ -12,6 +15,14 @@ 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
// for debugging data use the react query dev tools (flower thing in the bottom left corner) // for debugging data use the react query dev tools (flower thing in the bottom left corner)
const { data, status } = useRundown(); const { data, status } = useRundown();
const [showChild, setShowChild] = React.useState(false);
const handleScroll = (event: any) => {
const scrollThreshold = 50; // Set the scroll threshold here
const scrollPosition = event.target.scrollTop;
setShowChild(scrollPosition > scrollThreshold);
};
if (!data || status === 'loading') { if (!data || status === 'loading') {
return <>loading</>; return <>loading</>;
@@ -19,16 +30,23 @@ export default function Operator() {
return ( return (
<div className={style.operatorContainer}> <div className={style.operatorContainer}>
<div className={style.operatorEvents}> <NavigationMenu />
{data.map((entry) => {
<div className={style.operatorEvents} onScroll={handleScroll}>
{data.map((entry, i) => {
// 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
// this is a scheduled event // this is a scheduled event
if (entry.type === SupportedEvent.Event) { if (entry.type === SupportedEvent.Event) {
return ( return (
<div key={entry.id} className={style.scheduledEvent}> <div
<OpEvent data={entry} /> key={entry.id}
className={`${style.scheduledEvent} ${i % 3 == 0 ? style.activeEvent : ''} ${
i == 4 ? style.runningTimer : ''
}`}
>
<OpEvent id={i} data={entry} />
</div> </div>
); );
} }
@@ -43,8 +61,9 @@ export default function Operator() {
} }
return null; return null;
})} })}
{showChild && <FocusBlock />}
</div> </div>
<TimeBlock /> <TimeBlock />
</div> </div>
); );
} }
@@ -0,0 +1,14 @@
import { BiTargetLock } from '@react-icons/all-files/bi/BiTargetLock';
import style from './focusBlock.module.scss';
export default function FocusBlock() {
return (
<button className={style.focusBlock}>
<div className={style.focusButton}>
<BiTargetLock size={20} />
Follow
</div>
</button>
);
}
@@ -0,0 +1,25 @@
@use '.../../../src/theme/ontimeColours' as *;
.focusBlock {
bottom: 0;
left: 0;
right: 0;
position: -webkit-sticky;
position: sticky;
display: flex;
justify-content: center;
width: 100%;
margin-top: -53px;
}
.focusButton {
margin: 10px;
background-color: $blue-500;
width: fit-content;
padding: 3px 15px 3px 15px;
border-radius: 10px;
display: flex;
align-items: center;
gap: 5px;
font-size: medium;
}
@@ -10,6 +10,20 @@
font-size: 1rem; font-size: 1rem;
} }
.event {
display: flex;
gap: 6px;
width: 100%;
}
.block {
width: 100%;
}
.fields {
font-weight: 700;
}
.time { .time {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
@@ -24,3 +38,15 @@
.title { .title {
flex: 1; flex: 1;
} }
.indicator {
display: flex;
justify-content: space-between;
}
.chevron {
display: flex;
align-items: center;
color: yellow;
font-size: 16px;
}
@@ -1,3 +1,4 @@
import { IoChevronUp } from '@react-icons/all-files/io5/IoChevronUp';
import { OntimeEvent } from 'ontime-types'; import { OntimeEvent } from 'ontime-types';
import { formatTime } from '../../../common/utils/time'; import { formatTime } from '../../../common/utils/time';
@@ -6,23 +7,34 @@ import style from './OpEvent.module.scss';
type OpEventProps = { type OpEventProps = {
data: OntimeEvent; data: OntimeEvent;
id: number;
}; };
export default function OpEvent({ data }: OpEventProps) { export default function OpEvent({ data, id }: OpEventProps) {
const start = formatTime(data.timeStart, { format: 'hh:mm' }); const start = formatTime(data.timeStart, { format: 'hh:mm' });
const end = formatTime(data.timeEnd, { format: 'hh:mm' }); const end = formatTime(data.timeEnd, { format: 'hh:mm' });
return ( return (
<> <>
<div className={style.alias}>{data.note}</div> <div className={style.alias}>{data.note}</div>
<div className={style.title}> <div className={style.block}>
{data.title} - {data.subtitle} <div className={style.event}>
</div> <div className={style.title}>
<div className={style.time}> {data.title} - {data.subtitle}
<div> </div>
{start} - {end} <div className={style.time}>
<div>
{start} - {end}
</div>
<div className={style.indicator}>
<div className={style.chevron}>
<IoChevronUp />
</div>
--:--:--
</div>
</div>
</div> </div>
--:--:-- {id % 3 == 0 && <div className={style.fields}>CAM 5 Slow pan to SL</div>}
</div> </div>
</> </>
); );
} }