Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

style views #390

Merged
merged 4 commits into from
May 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ $progress-bar-br: 6px;

.progress-bar__indicator {
height: $progress-bar-size;
border-radius: $progress-bar-br;
background-color: var(--timer-progress-override, $accent-color);
transition: 1s linear;
transition-property: width;
Expand Down
14 changes: 9 additions & 5 deletions apps/client/src/common/components/schedule/Schedule.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ interface ScheduleProps {
}

export default function Schedule({ className }: ScheduleProps) {
const { paginatedEvents, selectedEventId, isBackstage } = useSchedule();
const { paginatedEvents, selectedEventId, isBackstage, scheduleType } = useSchedule();

if (paginatedEvents?.length < 1) {
return <Empty text='No events to show' />;
Expand All @@ -21,10 +21,14 @@ export default function Schedule({ className }: ScheduleProps) {
return (
<ul className={`schedule ${className}`}>
{paginatedEvents.map((event) => {
if (event.id === selectedEventId) {
selectedState = 'now';
} else if (selectedState === 'now') {
selectedState = 'future';
if (scheduleType === 'past' || scheduleType === 'future') {
selectedState = scheduleType;
} else {
if (event.id === selectedEventId) {
selectedState = 'now';
} else if (selectedState === 'now') {
selectedState = 'future';
}
}
return (
<ScheduleItem
Expand Down
16 changes: 15 additions & 1 deletion apps/client/src/common/components/schedule/ScheduleContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ interface ScheduleContextState {
events: OntimeEvent[];
paginatedEvents: OntimeEvent[];
selectedEventId: string | null;
scheduleType: 'past' | 'now' | 'future';
numPages: number;
visiblePage: number;
isBackstage: boolean;
Expand All @@ -27,7 +28,7 @@ export const ScheduleProvider = ({
events,
selectedEventId,
isBackstage = false,
eventsPerPage = 8,
eventsPerPage = 7,
time = 10,
}: PropsWithChildren<ScheduleProviderProps>) => {
const [visiblePage, setVisiblePage] = useState(0);
Expand All @@ -36,6 +37,18 @@ export const ScheduleProvider = ({
const eventStart = eventsPerPage * visiblePage;
const eventEnd = eventsPerPage * (visiblePage + 1);
const paginatedEvents = events.slice(eventStart, eventEnd);
const selectedEventIndex = events.findIndex((event) => event.id === selectedEventId);

const resolveScheduleType = () => {
if (selectedEventIndex >= eventStart && selectedEventIndex < eventEnd) {
return 'now';
}
if (selectedEventIndex > eventEnd) {
return 'past';
}
return 'future';
};
const scheduleType = resolveScheduleType();

// every SCROLL_TIME go to the next array
useInterval(() => {
Expand All @@ -51,6 +64,7 @@ export const ScheduleProvider = ({
events,
paginatedEvents,
selectedEventId,
scheduleType,
numPages,
visiblePage,
isBackstage,
Expand Down
7 changes: 6 additions & 1 deletion apps/client/src/features/viewers/backstage/Backstage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,12 @@ export default function Backstage(props: BackstageProps) {
</div>
</div>

<ProgressBar className='progress-container' now={time.current} complete={time.duration} hidden={!showProgress} />
<ProgressBar
className='progress-container'
now={time.current ?? undefined}
complete={time.duration ?? undefined}
hidden={!showProgress}
/>

<div className='now-container'>
<AnimatePresence>
Expand Down
6 changes: 3 additions & 3 deletions apps/client/src/features/viewers/timer/Timer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@ const formatOptions = {
// motion
const titleVariants = {
hidden: {
y: 500,
x: -2500,
},
visible: {
y: 0,
x: 0,
transition: {
duration: 1,
},
},
exit: {
y: 500,
x: -2500,
},
};

Expand Down