-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #381 from gravitational/ValtteriSavonen/add-new-ev…
…ent-banner-system Add new event banner system
- Loading branch information
Showing
17 changed files
with
364 additions
and
40 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
.banner { | ||
box-sizing: border-box; | ||
display: flex; | ||
flex-grow: 1; | ||
justify-content: center; | ||
align-items: center; | ||
position: relative; | ||
z-index: 1999; | ||
top: 0; | ||
background: #009984; | ||
color: #ffffff; | ||
height: 37px; | ||
gap: 24px; | ||
text-decoration: none; | ||
padding: 0; | ||
width: 100%; | ||
max-width: 100vw; | ||
@media (--sm-scr) { | ||
position: sticky; | ||
padding: 0 16px 0 16px; | ||
height: 48px; | ||
gap: 16px; | ||
} | ||
} | ||
|
||
.mainText { | ||
font-size: 14px; | ||
max-width: 600px; | ||
font-weight: 700; | ||
font-family: Lato, sans-serif; | ||
line-height: 21px; | ||
display: -webkit-box; | ||
-webkit-line-clamp: 2 /* Number of lines to show before truncating */; | ||
-webkit-box-orient: vertical; | ||
overflow: hidden; | ||
text-overflow: ellipsis; | ||
@media (--sm-scr) { | ||
font-size: 12px; | ||
} | ||
} | ||
|
||
.container { | ||
display: flex; | ||
flex-direction: row; | ||
align-items: flex-start; | ||
gap: 12px; | ||
white-space: nowrap; | ||
@media (--sm-scr) { | ||
flex-direction: column; | ||
gap: 4px; | ||
} | ||
} | ||
|
||
.styledBox { | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
gap: 4px; | ||
color: rgba(255, 255, 255, 0.8); | ||
} | ||
|
||
.styledText { | ||
font-size: 14px; | ||
min-width: fit-content; | ||
font-weight: 400; | ||
font-family: Lato, sans-serif; | ||
line-height: 21px; | ||
@media (--sm-scr) { | ||
font-size: 12px; | ||
line-height: 12px; | ||
} | ||
} | ||
|
||
.linkButton { | ||
display: flex; | ||
align-items: center; | ||
gap: 24px; | ||
font-size: 14px; | ||
line-height: 21px; | ||
font-weight: 700; | ||
padding: 0; | ||
min-width: 0; | ||
text-transform: none; | ||
vertical-align: inherit; | ||
color: #ffffff; | ||
text-decoration: none; | ||
@media (--sm-scr) { | ||
gap: 16px; | ||
font-size: 12px; | ||
} | ||
} | ||
|
||
.linkButton:hover { | ||
text-decoration: underline; | ||
} | ||
|
||
.icon { | ||
display: flex; | ||
} | ||
|
||
.icon svg { | ||
height: 16px; | ||
max-height: 16px; | ||
width: 16px; | ||
max-width: 16px; | ||
@media (--sm-scr) { | ||
height: 12px; | ||
max-height: 12px; | ||
width: 12px; | ||
max-width: 12px; | ||
} | ||
} |
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,95 @@ | ||
import { getParsedDate } from "utils/date"; | ||
import CalendarTrans from "./assets/calendar-trans.svg?react"; | ||
import ArrowRight from "./assets/arrow-right.svg?react"; | ||
import MapPin from "./assets/map-pin.svg?react"; | ||
import VirtualIcon from "./assets/video-meeting.svg?react"; | ||
import Link from "next/link"; | ||
import styles from "./EventBanner.module.css"; | ||
import { useEffect, useState } from "react"; | ||
|
||
export interface EventProps { | ||
end?: string | null; | ||
link?: string; | ||
location?: string | null; | ||
start?: string | null; | ||
title?: string | null; | ||
cta?: string; | ||
isVirtual?: boolean; | ||
bannerType?: "custom" | "event" | string; | ||
} | ||
|
||
export interface Events { | ||
events: EventProps[]; | ||
} | ||
|
||
export interface Event { | ||
event: EventProps; | ||
} | ||
|
||
export const getComingEvent = (event: EventProps) => { | ||
if (!event || !event?.title) return null; | ||
const currentDate = new Date().setHours(0, 0, 0, 0); | ||
const endDate = event.end ? new Date(event.end).setHours(0, 0, 0, 0) : null; | ||
|
||
if (endDate && currentDate > endDate) { | ||
//Event end date has gone | ||
return null; | ||
} | ||
return event; //No end date set or end date is in the future | ||
}; | ||
|
||
export const EventBanner: React.FC<{ | ||
initialEvent: EventProps; | ||
}> = ({ initialEvent }) => { | ||
const [event, setEvent] = useState<EventProps>(initialEvent); | ||
useEffect(() => { | ||
const fetchEvent = async () => { | ||
const tempEvent = await fetch("/api/getfeaturedevent/").then( | ||
(res) => res.status === 200 && res.json() | ||
); | ||
tempEvent && setEvent(tempEvent.data as EventProps); | ||
}; | ||
fetchEvent(); | ||
}, []); | ||
return event ? ( | ||
<Link className={styles.banner} href={event.link}> | ||
<div className={styles.mainText}>{event.title}</div> | ||
<div className={styles.container}> | ||
{event.start && ( | ||
<div className={styles.styledBox}> | ||
<div className={styles.icon}> | ||
<CalendarTrans /> | ||
</div> | ||
<div className={styles.styledText}> | ||
{getParsedDate(new Date(event.start), "MMM d")} | ||
{event.end != null && | ||
"-" + getParsedDate(new Date(event.end), "d")} | ||
</div> | ||
</div> | ||
)} | ||
|
||
{event.bannerType === "custom" && | ||
(event.location || event.isVirtual) && ( | ||
<div className={styles.styledBox}> | ||
<div className={styles.icon}> | ||
{event.location === "virtual" || event.isVirtual ? ( | ||
<VirtualIcon viewBox="0 0 16 16" /> | ||
) : ( | ||
<MapPin /> | ||
)} | ||
</div> | ||
<div className={styles.styledText}> | ||
{event.location || (event.isVirtual && "Virtual")} | ||
</div> | ||
</div> | ||
)} | ||
</div> | ||
<div style={{ display: "flex", alignItems: "center" }}> | ||
<div className={styles.linkButton}>{event.cta || "Register"}</div> | ||
<div className={styles.icon}> | ||
<ArrowRight /> | ||
</div> | ||
</div> | ||
</Link> | ||
) : null; | ||
}; |
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.
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 @@ | ||
export * from "./EventBanner"; |
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
Oops, something went wrong.
002b54c
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.
Successfully deployed to the following URLs:
docs – ./
docs-git-main-goteleport.vercel.app
docs-kohl-delta.vercel.app
docs-goteleport.vercel.app
docs.goteleport.com