-
Notifications
You must be signed in to change notification settings - Fork 2
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
Add Hubble poster handler #7
base: develop
Are you sure you want to change the base?
Conversation
Just a question out of curiosity, at what point would it make more sense to do the layout like this: ./handlers
├── poster
│ ├── index.ts
│ ├── components
│ │ └── ...
│ ├── gewis
│ │ ├── index.ts
│ │ └── components
│ │ └── ...
│ └── hubble
│ ├── index.ts
│ └── components
│ └── ...
├── time-trail-race
│ └── ...
└── ... So you really make |
Rebased on
|
Co-authored-by: Pim van Leeuwen <50077457+PimVanLeeuwen@users.noreply.github.com>
17e981a
to
8db65f2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small remarks, but I am not a prof on Aurora stuff so no approval
{overlay({ | ||
poster: selectedPoster, | ||
posterTitle: title, | ||
seconds: posterTimeout !== undefined ? selectedPoster?.timeout : undefined, | ||
posterIndex: posterIndex, | ||
nextPoster: nextPoster, | ||
pausePoster: pausePoster, | ||
borrelMode: borrelMode, | ||
})} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it not possible to make this a {children}
prop? Then you don't have to pass complete components as attributes, which looks a bit ugly to me in /poster-gewis/index.tsx
and in the Hubble equivalent.
import { useEffect, useState } from 'react'; | ||
|
||
interface Props { | ||
color: string; | ||
} | ||
|
||
export default function Clock({ color }: Props) { | ||
const [hours, setHours] = useState<number | undefined>(); | ||
const [minutes, setMinutes] = useState<number | undefined>(); | ||
|
||
const setTime = () => { | ||
const now = new Date(); | ||
setHours(now.getHours()); | ||
setMinutes(now.getMinutes()); | ||
}; | ||
|
||
useEffect(() => { | ||
const interval = setInterval(setTime, 1000); | ||
|
||
return () => { | ||
clearInterval(interval); | ||
}; | ||
}, []); | ||
|
||
return ( | ||
<div | ||
className="inline-flex flex-row flex-nowrap w-auto h-full items-center" | ||
style={{ fontFamily: '"Lato", monospace', fontSize: '8vh', color: color }} | ||
> | ||
<div>{hours?.toString().padStart(2, '0') ?? '--'}</div> | ||
<div className="w-full text-center" style={{ width: '=10%' }}> | ||
: | ||
</div> | ||
<div>{minutes?.toString().padStart(2, '0') ?? '--'}</div> | ||
</div> | ||
); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the Hubble clock so different from the GEWIS clock that it needs its own component? Is there no way to reuse the existing clock and parameterize it more to be able to create the Hubble clock?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The clock did change quite a bit for how simple the clock is. Furthermore I think for this one, and also most of the others, that is easier to just leave them as seperate components than to create switches and parameters for every little thing. Especially for maintability, then new Hubble people can just make pull request changing the HTML+CSS of the overlay, instead of having to do all sort of complicated things with making sure it switches correctly based on if it is for Hubble or for GEWIS etc etc. It is code duplication but in favor of readability and maintability
import Clock from './Clock'; | ||
import ProgressBarSlider from './ProgressBarSlider'; | ||
|
||
interface Props { | ||
seconds?: number; | ||
posterIndex?: number; | ||
color?: string; | ||
hideClock?: boolean; | ||
nextPoster?: () => void; | ||
pausePoster?: () => void; | ||
} | ||
|
||
export default function HubbleProgressBar({ seconds, posterIndex, color, hideClock, nextPoster, pausePoster }: Props) { | ||
return ( | ||
<div | ||
className="absolute w-full bottom-0 z-50 text-white flex flex-col text-5xl" | ||
style={{ backgroundColor: '', height: '14.3518519%' }} | ||
> | ||
<div className="absolute w-full" style={{ height: '3%', marginTop: -2, bottom: 0 }}> | ||
{seconds !== undefined && posterIndex && ( | ||
<ProgressBarSlider seconds={seconds} posterIndex={posterIndex} color={color || '#ffffff'} /> | ||
)} | ||
</div> | ||
<div className={`flex-grow flex justify-center items-center px-6`}> | ||
<div className="relative h-full py-3" style={{ width: '10%' }}> | ||
<div className="h-full flex flex-row gap-6 items-center"></div> | ||
</div> | ||
{/* eslint-disable-next-line jsx-a11y/click-events-have-key-events,jsx-a11y/no-static-element-interactions */} | ||
<div | ||
className="flex-grow h-full text-center text-shadow whitespace-nowrap overflow-hidden text-ellipsis" | ||
style={{ minHeight: '1rem' }} | ||
onClick={pausePoster} | ||
></div> | ||
{!hideClock && ( | ||
<div className="text-right h-full" style={{ width: '20%' }}> | ||
{/* eslint-disable-next-line jsx-a11y/click-events-have-key-events,jsx-a11y/no-static-element-interactions */} | ||
<div className="h-full" onClick={nextPoster}> | ||
<Clock color={color || '#ffffff'} /> | ||
</div> | ||
</div> | ||
)} | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
HubbleProgressBar.defaultProps = { | ||
color: '#ffffff', | ||
hideClock: false, | ||
nextPoster: undefined, | ||
pausePoster: undefined, | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as the clock: is the Hubble progress bar so different that it needs to be its own component?
import { useEffect, useState } from 'react'; | ||
|
||
interface Props { | ||
seconds: number; | ||
posterIndex: number; | ||
color: string; | ||
} | ||
|
||
export default function ProgressBarSlider({ seconds, posterIndex, color }: Props) { | ||
const [hiding, setHiding] = useState(false); | ||
|
||
useEffect(() => { | ||
setHiding(true); | ||
|
||
// ReturnType used instead of number as one of the dependencies uses @types/node as dependency | ||
let timeout: ReturnType<typeof setTimeout> | undefined = undefined; | ||
|
||
const startAnimation = () => { | ||
setHiding(false); | ||
clearTimeout(timeout); | ||
}; | ||
|
||
timeout = setTimeout(startAnimation, 500); | ||
return () => clearTimeout(timeout); | ||
}, [seconds, posterIndex]); | ||
|
||
return ( | ||
<div | ||
className={`h-full w-full rounded ${hiding ? 'transition-opacity opacity-0' : 'transition-transform opacity-100'}`} | ||
style={{ | ||
backgroundColor: color, | ||
transform: hiding ? 'translateX(-100%)' : 'translateX(0)', | ||
transitionDuration: hiding ? '500ms' : `${Math.max(0.75, seconds) * 1000 - 750}ms`, | ||
transitionTimingFunction: 'cubic-bezier(.2,0,.8,1)', | ||
}} | ||
/> | ||
); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as the clock.
@@ -1,4 +1,4 @@ | |||
import '../../poster/components/types/ScrollAnimation.scss'; | |||
import '../../poster-gewis/components/types/ScrollAnimation.scss'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ScrollAnimation
should be a generic poster component. I did a quick search, but it seems to only be used by the TimeTrailRaceScoreboard
, though there might be uses for posters as well.
Abstracts the main poster logic, and adds overlays defined for GEWIS and Hubble. Still needs the Handler to be added to the core. Later other features can be configured and added