-
Notifications
You must be signed in to change notification settings - Fork 1
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
8 changed files
with
305 additions
and
2 deletions.
There are no files selected for viewing
86 changes: 86 additions & 0 deletions
86
apps/nextjs/components/DualUpcomingEvent/DualUpcomingEvent.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,86 @@ | ||
@import "../../styles/responsive.scss"; | ||
@import "../../styles/colors.scss"; | ||
|
||
.dualUpcoming { | ||
display: flex; | ||
flex-direction: column; | ||
|
||
@include breakpoint($md) { | ||
flex-direction: row; | ||
} | ||
} | ||
|
||
.heroblock { | ||
flex-grow: 1; | ||
// background: url("../../styles/img/hero-image.png") no-repeat; | ||
background-size: cover; | ||
background-position: center; | ||
color: $dark-text; | ||
|
||
.content { | ||
display: flex; | ||
flex-flow: column; | ||
padding: 50px 0; | ||
|
||
@include breakpoint($md) { | ||
flex-flow: row; | ||
max-width: 1200px; | ||
|
||
& > :first-child { | ||
display: inline-block; | ||
max-width: 33%; | ||
} | ||
|
||
& > :last-child:not(:only-child) { | ||
margin-left: 10px; | ||
max-width: 66%; | ||
padding: 0 7%; | ||
} | ||
} | ||
|
||
a { | ||
color: $color-white; | ||
|
||
&:visited { | ||
color: $color-white; | ||
} | ||
} | ||
|
||
.ctaBlock { | ||
text-align: left; | ||
padding: 25px; | ||
|
||
p { | ||
max-width: 400px; | ||
} | ||
|
||
.countdown { | ||
// font-size: 1.75rem; | ||
// line-height: 3; | ||
min-height: 32px; | ||
} | ||
|
||
a { | ||
margin-bottom: 16px; | ||
} | ||
} | ||
|
||
.logoBlock { | ||
// width: inherit; | ||
// max-width: 400px; | ||
display: flex; | ||
flex-direction: column; | ||
flex-grow: 1; | ||
align-items: center; | ||
justify-content: center; | ||
gap: 3rem; | ||
|
||
max-width: 80%; | ||
margin: auto; | ||
|
||
@include breakpoint($lg) { | ||
max-width: 600px; | ||
} | ||
} | ||
} | ||
} |
173 changes: 173 additions & 0 deletions
173
apps/nextjs/components/DualUpcomingEvent/DualUpcomingEvent.tsx
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,173 @@ | ||
import React, { useEffect, useState } from "react"; | ||
import styles from "./DualUpcomingEvent.module.scss"; | ||
import Image from "next/image"; | ||
import { faCalendar, faChevronRight, faPersonRunning, faTicket } from "@fortawesome/free-solid-svg-icons"; | ||
import Button from "../Button/Button"; | ||
import { AusSpeedrunsEvent } from "../../types/types"; | ||
|
||
type DualUpcomingEventProps = { | ||
eventA: HeroBlockProps; | ||
eventB: HeroBlockProps; | ||
}; | ||
|
||
function zeroPad(num: number): string { | ||
return num.toString().padStart(2, "0"); | ||
} | ||
|
||
function countdownRender(currentTime: number, eventDate: number) { | ||
// Calculate the difference in seconds between the target date and current date | ||
let diffInSeconds = (eventDate - currentTime) / 1000; | ||
|
||
// Calculate the days, hours, minutes and seconds from the difference in seconds | ||
let days = Math.floor(diffInSeconds / 86400); | ||
let hours = Math.floor(diffInSeconds / 3600) % 24; | ||
let minutes = Math.floor(diffInSeconds / 60) % 60; | ||
let seconds = Math.floor(diffInSeconds % 60); | ||
|
||
if (days > 0) { | ||
return ( | ||
<span> | ||
<span className="sr-only"> | ||
{days} days, {hours} hours, {minutes} minutes and {seconds} seconds remaining | ||
</span> | ||
<span aria-hidden> | ||
{zeroPad(days)}:{zeroPad(hours)}:{zeroPad(minutes)}:{zeroPad(seconds)} | ||
</span> | ||
</span> | ||
); | ||
} | ||
|
||
if (hours > 0) { | ||
return ( | ||
<span> | ||
<span className="sr-only"> | ||
{hours} hours, {minutes} minutes and {seconds} seconds remaining | ||
</span> | ||
<span aria-hidden> | ||
{zeroPad(hours)}:{zeroPad(minutes)}:{zeroPad(seconds)} | ||
</span> | ||
</span> | ||
); | ||
} | ||
|
||
return ( | ||
<span> | ||
<span className="sr-only"> | ||
{minutes} minutes and {seconds} seconds remaining | ||
</span> | ||
<span aria-hidden> | ||
{zeroPad(minutes)}:{zeroPad(seconds)} | ||
</span> | ||
</span> | ||
); | ||
} | ||
|
||
const DualUpcomingEvent = (props: DualUpcomingEventProps) => { | ||
return ( | ||
<div className={styles.dualUpcoming}> | ||
<HeroBlock {...props.eventA} reverse /> | ||
<HeroBlock {...props.eventB} /> | ||
</div> | ||
); | ||
}; | ||
|
||
type HeroBlockProps = { | ||
event: AusSpeedrunsEvent; | ||
tagLine?: string; | ||
darkText?: boolean; | ||
schedule?: boolean; | ||
submitRuns?: boolean; | ||
ticketLink?: string; | ||
dontShowEventPage?: boolean; | ||
reverse?: boolean; | ||
}; | ||
|
||
const HeroBlock = ({ | ||
event, | ||
tagLine, | ||
darkText, | ||
schedule, | ||
submitRuns, | ||
ticketLink, | ||
dontShowEventPage, | ||
reverse, | ||
}: HeroBlockProps) => { | ||
const [countdownElement, setCountdownElement] = useState(<></>); | ||
|
||
function updateCountdown() { | ||
if (!event.startDate) return; | ||
if (Date.now() < new Date(event.startDate).getTime()) { | ||
setCountdownElement(countdownRender(Date.now(), new Date(event.startDate).getTime())); | ||
} | ||
} | ||
|
||
useEffect(() => { | ||
updateCountdown(); | ||
const interval = setInterval(updateCountdown, 1000); | ||
return () => clearInterval(interval); | ||
}, []); | ||
|
||
return ( | ||
<section | ||
className={styles.heroblock} | ||
style={{ | ||
backgroundImage: `url("${require(`../../styles/img/${event.heroImage}`).default.src}")`, | ||
color: darkText ? "#000" : "#fff", | ||
}}> | ||
<div className={`${styles.content} content`} style={{ flexDirection: reverse ? "row-reverse" : undefined }}> | ||
<div className={styles.ctaBlock} style={{ textAlign: reverse ? "right" : undefined }}> | ||
<h1>{event.preferredName}</h1> | ||
<h2>{event.dates}</h2> | ||
<h3 className={[styles.countdown, styles.monospaced].join(" ")}>{countdownElement}</h3> | ||
<br /> | ||
<p>{tagLine}</p> | ||
{!dontShowEventPage && ( | ||
<Button | ||
actionText={event.preferredName} | ||
link={`/${event.shortName}`} | ||
iconRight={faChevronRight} | ||
colorScheme={"secondary"} | ||
/> | ||
)} | ||
|
||
{schedule && ( | ||
<Button | ||
actionText="Schedule" | ||
link={`/${event.shortName}/schedule`} | ||
iconRight={faCalendar} | ||
colorScheme={"secondary"} | ||
/> | ||
)} | ||
{(event.website || ticketLink) && ( | ||
<Button | ||
actionText="Purchase Tickets" | ||
link={event.website ?? ticketLink} | ||
iconRight={faTicket} | ||
colorScheme={"secondary"} | ||
/> | ||
)} | ||
{submitRuns && ( | ||
<Button | ||
actionText="Submit a run!" | ||
link="/submit-game" | ||
iconRight={faPersonRunning} | ||
colorScheme={"secondary"} | ||
/> | ||
)} | ||
</div> | ||
<div className={styles.logoBlock}> | ||
<Image | ||
src={require(`../../styles/img/${event.logo}`).default} | ||
alt="Event Logo" | ||
style={{ | ||
maxWidth: "100%", | ||
height: "auto", | ||
}} | ||
/> | ||
</div> | ||
</div> | ||
</section> | ||
); | ||
}; | ||
|
||
export default DualUpcomingEvent; |
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 |
---|---|---|
|
@@ -151,6 +151,10 @@ | |
height: 0; | ||
} | ||
|
||
.mainmenu { | ||
justify-content: center; | ||
} | ||
|
||
.mainmenu, | ||
.social, | ||
.auth { | ||
|
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.