|
| 1 | +import type { FC, PropsWithChildren } from 'react'; |
| 2 | +import { Col, Container, Row } from 'react-bootstrap'; |
| 3 | + |
| 4 | +import { HackathonHeroAction } from './Hero'; |
| 5 | +import styles from './ActionHub.module.less'; |
| 6 | + |
| 7 | +export interface HackathonActionHubEntry { |
| 8 | + count: number; |
| 9 | + description: string; |
| 10 | + eyebrow: string; |
| 11 | + links: HackathonHeroAction[]; |
| 12 | + title: string; |
| 13 | +} |
| 14 | + |
| 15 | +export interface HackathonActionHubProps { |
| 16 | + entries: HackathonActionHubEntry[]; |
| 17 | + facts: string[]; |
| 18 | + primaryAction?: HackathonHeroAction; |
| 19 | + primaryDescription: string; |
| 20 | + primaryTitle: string; |
| 21 | + subtitle: string; |
| 22 | + title: string; |
| 23 | +} |
| 24 | + |
| 25 | +export const HackathonActionHubLink: FC<{ |
| 26 | + action: HackathonHeroAction; |
| 27 | + variant: 'ghost' | 'primary'; |
| 28 | +}> = ({ action, variant }) => ( |
| 29 | + <a |
| 30 | + className={variant === 'primary' ? styles.actionButton : styles.actionButtonGhost} |
| 31 | + href={action.href} |
| 32 | + {...(action.external && { target: '_blank', rel: 'noreferrer' })} |
| 33 | + > |
| 34 | + {action.label} |
| 35 | + </a> |
| 36 | +); |
| 37 | + |
| 38 | +const ActionEntryCard: FC<{ entry: HackathonActionHubEntry; step: string }> = ({ entry, step }) => ( |
| 39 | + <article className={styles.entryCard}> |
| 40 | + <span className={styles.entryStep}> |
| 41 | + {step} · {entry.eyebrow} |
| 42 | + </span> |
| 43 | + <h4 className="mt-2 mb-2">{entry.title}</h4> |
| 44 | + <p>{entry.description}</p> |
| 45 | + |
| 46 | + <div className={`${styles.entryMetaRow} d-flex flex-wrap gap-2 my-3`}> |
| 47 | + <span className={`${styles.entryMeta} d-inline-flex align-items-center`}>{entry.count}</span> |
| 48 | + <span className={`${styles.entryMeta} d-inline-flex align-items-center`}> |
| 49 | + {entry.eyebrow} |
| 50 | + </span> |
| 51 | + </div> |
| 52 | + |
| 53 | + <nav className={`${styles.entryLinks} d-flex flex-wrap gap-3`} aria-label={entry.title}> |
| 54 | + {entry.links.map(link => ( |
| 55 | + <a |
| 56 | + key={`${link.label}-${link.href}`} |
| 57 | + className={`${styles.entryLink} d-inline-flex align-items-center`} |
| 58 | + href={link.href} |
| 59 | + {...(link.external && { target: '_blank', rel: 'noreferrer' })} |
| 60 | + > |
| 61 | + {link.label} |
| 62 | + </a> |
| 63 | + ))} |
| 64 | + </nav> |
| 65 | + </article> |
| 66 | +); |
| 67 | + |
| 68 | +export const HackathonActionHub: FC<PropsWithChildren<HackathonActionHubProps>> = ({ |
| 69 | + children, |
| 70 | + entries, |
| 71 | + facts, |
| 72 | + primaryAction, |
| 73 | + primaryDescription, |
| 74 | + primaryTitle, |
| 75 | + subtitle, |
| 76 | + title, |
| 77 | +}) => ( |
| 78 | + <section id="entry-hub" className={styles.section}> |
| 79 | + <Container> |
| 80 | + <div className={styles.registerWrap}> |
| 81 | + <article className={styles.registerCard}> |
| 82 | + <div className={styles.registerCardInner}> |
| 83 | + <p className={`${styles.regEyebrow} mb-1`}>{title}</p> |
| 84 | + <h2 className={`${styles.regTitle} mt-2`}>{primaryTitle}</h2> |
| 85 | + <p className={`${styles.regDesc} mt-3 mb-4`}>{primaryDescription}</p> |
| 86 | + |
| 87 | + <nav className={`${styles.regActions} d-flex flex-wrap gap-3`} aria-label={title}> |
| 88 | + {primaryAction && <HackathonActionHubLink action={primaryAction} variant="primary" />} |
| 89 | + {children} |
| 90 | + </nav> |
| 91 | + |
| 92 | + <ul className={`list-unstyled ${styles.regFacts} d-flex flex-wrap gap-2 mt-4`}> |
| 93 | + {facts.map(fact => ( |
| 94 | + <li key={fact}>{fact}</li> |
| 95 | + ))} |
| 96 | + </ul> |
| 97 | + </div> |
| 98 | + </article> |
| 99 | + |
| 100 | + <div className={styles.entryHub}> |
| 101 | + <header className={`${styles.entryHubHead} mb-4`}> |
| 102 | + <p className={`${styles.entryEyebrow} mb-1`}>{subtitle}</p> |
| 103 | + <h3 className={`${styles.entryTitle} mt-2`}>{title}</h3> |
| 104 | + </header> |
| 105 | + |
| 106 | + <Row as="ol" className="list-unstyled g-3 mb-0"> |
| 107 | + {entries.map((entry, index) => ( |
| 108 | + <Col as="li" key={entry.title} md={6}> |
| 109 | + <ActionEntryCard entry={entry} step={String(index + 1).padStart(2, '0')} /> |
| 110 | + </Col> |
| 111 | + ))} |
| 112 | + </Row> |
| 113 | + </div> |
| 114 | + </div> |
| 115 | + </Container> |
| 116 | + </section> |
| 117 | +); |
0 commit comments