www-new/components/EventDescriptionCard.tsx

83 lines
2.0 KiB
TypeScript
Raw Normal View History

import React from "react";
2021-06-01 00:45:52 -04:00
import { Button } from "./Button";
import { Image } from "./Image";
2021-05-16 03:22:06 -04:00
import { EventSetting } from "./EventSetting";
import styles from "./EventDescriptionCard.module.css";
2021-06-23 22:10:51 -04:00
import { Discord, Twitch, Instagram, Facebook } from "./SocialLinks";
2021-05-16 03:22:06 -04:00
2021-05-24 03:41:50 -04:00
interface Props {
2021-05-16 03:22:06 -04:00
name: string;
short: string;
2021-05-24 03:41:50 -04:00
online: boolean;
location: string;
2021-05-16 03:22:06 -04:00
date: Date;
poster?: string;
2021-05-16 03:22:06 -04:00
registerLink?: string;
}
/**
* @remarks
* - Child elements will display as the event's description
* - Assuming date prop is in EST
* - poster is the event's image name, including file ending (.jpg/.png/etc)
* - If event is online, location will be the platform, with capital first letter and no trailing spaces
* - ie. location="Discord"
* @todo
* get Link component
*/
2021-05-24 03:41:50 -04:00
export function EventDescriptionCard({
location,
poster,
name,
short,
2021-05-24 03:41:50 -04:00
date,
online,
registerLink,
}: Props) {
2021-06-23 22:10:51 -04:00
const Icon = getIcon(location);
2021-05-24 03:41:50 -04:00
2021-05-16 03:22:06 -04:00
return (
<article className={styles.card}>
{poster && <Image className={styles.poster} src={poster} alt={name} />}
2021-05-16 03:22:06 -04:00
<div className={styles.details}>
<h1 className={styles.name}>{name}</h1>
<h2 className={styles.setting}>
2021-05-24 03:41:50 -04:00
<EventSetting date={date} online={online} location={location} />
</h2>
<p className={styles.desc}>{short}</p>
2021-05-16 03:22:06 -04:00
<footer>
2021-05-24 03:41:50 -04:00
{registerLink && (
2021-05-16 03:22:06 -04:00
<div className={styles.button}>
2021-06-01 00:45:52 -04:00
<Button isLink={true} href={registerLink} size="small">
Register
</Button>
2021-05-16 03:22:06 -04:00
</div>
)}
2021-06-23 22:10:51 -04:00
{online && Icon && (
<div className={styles.logo}>
<Icon color="blue" size="small" />
</div>
2021-05-16 03:22:06 -04:00
)}
</footer>
</div>
</article>
);
}
2021-06-23 22:10:51 -04:00
function getIcon(platform: string) {
switch (platform) {
case "Twitch":
return Twitch;
case "Discord":
return Discord;
case "Instagram":
return Instagram;
case "Facebook":
return Facebook;
default:
return null;
}
}