-
-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
36 changed files
with
886 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
111 changes: 111 additions & 0 deletions
111
apps/client/src/features/viewers/timeline/Timeline.module.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
@use '../../../theme/viewerDefs' as *; | ||
|
||
$timeline-entry-height: 20px; | ||
$lane-height: 120px; | ||
$timeline-height: 1rem; | ||
|
||
.timeline { | ||
flex: 1; | ||
font-weight: 600; | ||
color: $ui-white; | ||
} | ||
|
||
.timelineEvents { | ||
position: relative; | ||
height: 100%; | ||
} | ||
|
||
.column { | ||
display: flex; | ||
flex-direction: column; | ||
position: absolute; | ||
border-left: 1px solid $ui-black; | ||
// avoiding content being larger than the view | ||
height: calc(100% - 3rem); | ||
|
||
// decorate timeline element | ||
&::before { | ||
content: ''; | ||
position: absolute; | ||
box-sizing: content-box; | ||
top: -$timeline-height; | ||
left: 0; | ||
right: 0; | ||
height: $timeline-height; | ||
background-color: $white-40; | ||
} | ||
} | ||
|
||
.smallArea { | ||
.content { | ||
gap: 0rem; | ||
writing-mode: vertical-rl; | ||
} | ||
|
||
.timeOverview { | ||
opacity: 0; | ||
} | ||
} | ||
|
||
.hide { | ||
// hide text elements | ||
& > div { | ||
display: none; | ||
} | ||
} | ||
|
||
.content { | ||
flex: 1; | ||
display: flex; | ||
flex-direction: column; | ||
gap: 2rem; | ||
padding-top: 0.25rem; | ||
padding-inline-start: 0.25rem; | ||
overflow: hidden; | ||
line-height: 1rem; | ||
|
||
background-color: var(--lighter, $viewer-card-bg-color); | ||
border-bottom: 2px solid $ui-black; | ||
box-shadow: 0 0.25rem 0 0 var(--color, $gray-300); | ||
|
||
&[data-status='done'] { | ||
opacity: $opacity-disabled; | ||
} | ||
|
||
&[data-status='live'] { | ||
box-shadow: 0 0.25rem 0 0 $active-red; | ||
} | ||
} | ||
|
||
.delay { | ||
margin-top: -2rem; | ||
margin-bottom: -1rem; | ||
} | ||
|
||
.timeOverview { | ||
padding-top: 0.25rem; | ||
padding-inline-start: 0.25em; | ||
text-transform: capitalize; | ||
white-space: normal; | ||
height: 6rem; | ||
|
||
&[data-status='done'] { | ||
opacity: $opacity-disabled; | ||
} | ||
|
||
&[data-status='live'] { | ||
.status { | ||
color: $active-red; | ||
} | ||
} | ||
|
||
&[data-status='future'] { | ||
.status { | ||
color: $green-500; | ||
} | ||
} | ||
} | ||
|
||
.cross { | ||
text-decoration: line-through; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
import { memo } from 'react'; | ||
import { useViewportSize } from '@mantine/hooks'; | ||
import { isOntimeEvent, MaybeNumber, OntimeEvent } from 'ontime-types'; | ||
import { dayInMs, getFirstEvent, getLastEvent, MILLIS_PER_HOUR } from 'ontime-utils'; | ||
|
||
import TimelineMarkers from './timeline-markers/TimelineMarkers'; | ||
import ProgressBar from './timeline-progress-bar/TimelineProgressBar'; | ||
import { getElementPosition, getEndHour, getStartHour } from './timeline.utils'; | ||
import { ProgressStatus, TimelineEntry } from './TimelineEntry'; | ||
|
||
import style from './Timeline.module.scss'; | ||
|
||
function useTimeline(rundown: OntimeEvent[]) { | ||
const { firstEvent } = getFirstEvent(rundown); | ||
const { lastEvent } = getLastEvent(rundown); | ||
const firstStart = firstEvent?.timeStart ?? 0; | ||
const lastEnd = lastEvent?.timeEnd ?? 0; | ||
const normalisedLastEnd = lastEnd < firstStart ? lastEnd + dayInMs : lastEnd; | ||
|
||
// we make sure the end accounts for delays | ||
const accumulatedDelay = lastEvent?.delay ?? 0; | ||
// timeline is padded to nearest hours (floor and ceil) | ||
const startHour = getStartHour(firstStart); | ||
const endHour = getEndHour(normalisedLastEnd + accumulatedDelay); | ||
|
||
return { | ||
rundown: rundown, | ||
startHour, | ||
endHour, | ||
}; | ||
} | ||
|
||
interface TimelineProps { | ||
selectedEventId: string | null; | ||
rundown: OntimeEvent[]; | ||
} | ||
|
||
export default memo(Timeline); | ||
|
||
function Timeline(props: TimelineProps) { | ||
const { selectedEventId, rundown: baseRundown } = props; | ||
const { width: screenWidth } = useViewportSize(); | ||
const timelineData = useTimeline(baseRundown); | ||
|
||
if (timelineData === null) { | ||
return null; | ||
} | ||
|
||
const { rundown, startHour, endHour } = timelineData; | ||
|
||
let hasTimelinePassedMidnight = false; | ||
let previousEventStartTime: MaybeNumber = null; | ||
// we use selectedEventId as a signifier on whether the timeline is live | ||
let eventStatus: ProgressStatus = selectedEventId ? 'done' : 'future'; | ||
|
||
return ( | ||
<div className={style.timeline}> | ||
<TimelineMarkers startHour={startHour} endHour={endHour} /> | ||
<ProgressBar startHour={startHour} endHour={endHour} /> | ||
<div className={style.timelineEvents}> | ||
{rundown.map((event) => { | ||
// for now we dont render delays and blocks | ||
if (!isOntimeEvent(event)) { | ||
return null; | ||
} | ||
|
||
// keep track of progress of rundown | ||
if (eventStatus === 'live') { | ||
eventStatus = 'future'; | ||
} | ||
if (event.id === selectedEventId) { | ||
eventStatus = 'live'; | ||
} | ||
|
||
if (!hasTimelinePassedMidnight) { | ||
// we need to offset the start to account for midnight | ||
hasTimelinePassedMidnight = previousEventStartTime !== null && event.timeStart < previousEventStartTime; | ||
} | ||
const normalisedStart = hasTimelinePassedMidnight ? event.timeStart + dayInMs : event.timeStart; | ||
previousEventStartTime = normalisedStart; | ||
|
||
const { left: elementLeftPosition, width: elementWidth } = getElementPosition( | ||
startHour * MILLIS_PER_HOUR, | ||
endHour * MILLIS_PER_HOUR, | ||
normalisedStart + (event.delay ?? 0), | ||
event.duration, | ||
screenWidth, | ||
); | ||
|
||
return ( | ||
<TimelineEntry | ||
key={event.id} | ||
colour={event.colour} | ||
delay={event.delay ?? 0} | ||
duration={event.duration} | ||
left={elementLeftPosition} | ||
status={eventStatus} | ||
start={normalisedStart} // solve issues related to crossing midnight | ||
title={event.title} | ||
width={elementWidth} | ||
/> | ||
); | ||
})} | ||
</div> | ||
</div> | ||
); | ||
} |
Oops, something went wrong.