This repository has been archived by the owner on Jan 3, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Competition info grid alignment (#367)
* Separate information grid into own component and minor formatting * Partially de-duplicate; correct column widths on all screen sizes * De-duplicate person list code and remove comma from link * Handle no-competitor-limit case in info * Move info grid to own file and minor formatting * fix eslint --------- Co-authored-by: FinnIckler <finnickler@gmail.com>
- Loading branch information
1 parent
4663fc0
commit 7ce1487
Showing
2 changed files
with
137 additions
and
89 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
import { marked } from 'marked' | ||
import moment from 'moment' | ||
import React, { Fragment } from 'react' | ||
import { Grid, Header } from 'semantic-ui-react' | ||
import styles from './index.module.scss' | ||
|
||
export default function InfoGrid({ competitionInfo }) { | ||
return ( | ||
<Grid columns={2}> | ||
<InfoGridRow> | ||
<InfoGridHeader>Date</InfoGridHeader> | ||
<InfoGridHeader> | ||
{competitionInfo.start_date === competitionInfo.end_date | ||
? `${moment(competitionInfo.start_date).format('ll')}` | ||
: `${moment(competitionInfo.start_date).format('ll')} to ${moment( | ||
competitionInfo.end_date | ||
).format('ll')}`} | ||
</InfoGridHeader> | ||
</InfoGridRow> | ||
|
||
<InfoGridRow> | ||
<InfoGridHeader>City</InfoGridHeader> | ||
<InfoGridHeader> | ||
{competitionInfo.city}, {competitionInfo.country_iso2} | ||
</InfoGridHeader> | ||
</InfoGridRow> | ||
|
||
<InfoGridRow> | ||
<InfoGridHeader>Venue</InfoGridHeader> | ||
<InfoGridHeader> | ||
<p | ||
dangerouslySetInnerHTML={{ | ||
__html: marked(competitionInfo.venue), | ||
}} | ||
/> | ||
</InfoGridHeader> | ||
</InfoGridRow> | ||
|
||
<InfoGridRow> | ||
<InfoGridHeader color="grey">Address</InfoGridHeader> | ||
<InfoGridHeader color="grey"> | ||
{competitionInfo.venue_address} | ||
</InfoGridHeader> | ||
</InfoGridRow> | ||
|
||
{competitionInfo.venue_details && ( | ||
<InfoGridRow> | ||
<InfoGridHeader color="grey">Details</InfoGridHeader> | ||
<InfoGridHeader color="grey"> | ||
{competitionInfo.venue_details} | ||
</InfoGridHeader> | ||
</InfoGridRow> | ||
)} | ||
|
||
<InfoGridRow> | ||
<InfoGridHeader>Competitor Limit</InfoGridHeader> | ||
<InfoGridHeader> | ||
{competitionInfo.competitor_limit ?? 'None'} | ||
</InfoGridHeader> | ||
</InfoGridRow> | ||
|
||
<InfoGridRow> | ||
<InfoGridHeader>Contact</InfoGridHeader> | ||
<InfoGridHeader> | ||
{competitionInfo.contact ? ( | ||
<span | ||
dangerouslySetInnerHTML={{ | ||
__html: marked(competitionInfo.contact), | ||
}} | ||
/> | ||
) : ( | ||
<a | ||
href={`https://www.worldcubeassociation.org/contact/website?competitionId=${competitionInfo.id}`} | ||
> | ||
Organization Team | ||
</a> | ||
)} | ||
</InfoGridHeader> | ||
</InfoGridRow> | ||
|
||
<InfoGridRow> | ||
<InfoGridHeader>Organizers</InfoGridHeader> | ||
<InfoGridHeader> | ||
<PersonList people={competitionInfo.organizers} /> | ||
</InfoGridHeader> | ||
</InfoGridRow> | ||
|
||
<InfoGridRow> | ||
<InfoGridHeader>Delegates</InfoGridHeader> | ||
<InfoGridHeader> | ||
<PersonList people={competitionInfo.delegates} /> | ||
</InfoGridHeader> | ||
</InfoGridRow> | ||
</Grid> | ||
) | ||
} | ||
|
||
function InfoGridRow({ children }) { | ||
return ( | ||
<Grid.Row> | ||
<Grid.Column computer={3} tablet={5} mobile={5}> | ||
{children[0]} | ||
</Grid.Column> | ||
<Grid.Column computer={12} tablet={10} mobile={10}> | ||
{children[1]} | ||
</Grid.Column> | ||
</Grid.Row> | ||
) | ||
} | ||
|
||
function InfoGridHeader({ color, children }) { | ||
return ( | ||
<Header className={styles.informationHeader} color={color}> | ||
{children} | ||
</Header> | ||
) | ||
} | ||
|
||
function PersonList({ people }) { | ||
return people.map((person, index) => ( | ||
<Fragment key={person.id}> | ||
{index > 0 && ', '} | ||
<a href={`${process.env.WCA_URL}/persons/${person.wca_id}`}> | ||
{person.name} | ||
</a> | ||
</Fragment> | ||
)) | ||
} |
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