Skip to content

Commit

Permalink
Merge pull request #189 from uclaacm/fix/archive
Browse files Browse the repository at this point in the history
/archive fixes
  • Loading branch information
Aplet123 authored Aug 26, 2024
2 parents af80fee + ff53bc7 commit 1233c80
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
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

0 comments on commit 1233c80

Please sign in to comment.