Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

/archive fixes #189

Merged
merged 4 commits into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions data/archive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ export interface SeriesArchive {

export interface QuarterArchive {
name: string;
season: "w" | "s" | "u" | "f";
year: number;
series: SeriesArchive[];
}

Expand All @@ -19,7 +21,7 @@ for (const event of eventData) {
if (!event.type) continue;

const idComponents = event.id.split("-");
if (idComponents.length >= 2 && /^[fws]\d\d$/.test(idComponents[0])) {
if (idComponents.length >= 2 && /^[wsuf]\d\d$/.test(idComponents[0])) {
if (!quarters.has(idComponents[0])) {
quarters.set(idComponents[0], new Map());
}
Expand All @@ -36,22 +38,32 @@ for (const event of eventData) {
}
}

const SEASONS = { "w": 0, "s": 1, "u": 2, "f": 3 };

const archive: QuarterArchive[] = [...quarters.entries()].map(([quarterId, quarterMap]) => {
const seasonChar = quarterId.charAt(0);
let season;
switch (quarterId.charAt(0)) {
switch (seasonChar) {
case "f": season = "Fall"; break;
case "w": season = "Winter"; break;
case "s": season = "Spring"; break;
case "u": season = "Summer"; break;
default: throw `invalid season char '${quarterId.charAt(0)}' (this should never happen)`
}
const year = parseInt(quarterId.length === 3 ? `20${quarterId.slice(1)}` : quarterId.slice(1));
return {
name: `${season} ${quarterId.length === 3 ? `20${quarterId.slice(1)}` : quarterId}`,
name: `${season} ${year}`,
season: seasonChar,
year: year,
series: [...quarterMap.entries()].map(([seriesId, events]) => ({
name: seriesId,
description: eventTypes.find(x => x.name === seriesId)!.description,
events,
}))
}
})
}).sort((a, b) => {
if (b.year == a.year) return SEASONS[b.season] - SEASONS[a.season];
return b.year - a.year;
});

export default archive;
9 changes: 6 additions & 3 deletions styles/Archive.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,21 @@
}

.series {
padding: 0.5rem;
display: grid;
grid-template-columns: repeat(auto-fill, 20rem);
gap: 2rem;
padding: 1.5rem;
}

.event {
display: inline-flex; /* keep the inline nature of buttons */
display: flex;
align-items: flex-start; /* this is default */
background-color: var(--cyber-black);
margin: 1rem;
border: var(--cyber-gold) 2px solid;
border-radius: 2rem;
width: 20rem;
height: 17rem;
font-family: inherit; /* ??? override user-agent stylesheet for button */
text-align: left;

&:hover {
Expand Down