-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement contest history section on SpcPage
- Loading branch information
1 parent
aa5ee0c
commit 824175a
Showing
29 changed files
with
306 additions
and
110 deletions.
There are no files selected for viewing
Binary file added
BIN
+1.71 MB
sogang-icpc-team.github.io-react/public/downloads/spc/2019/champion.pdf
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+376 KB
sogang-icpc-team.github.io-react/public/downloads/spc/2019/solutions.pdf
Binary file not shown.
Binary file added
BIN
+286 KB
sogang-icpc-team.github.io-react/public/downloads/spc/2020/champion.pdf
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+459 KB
sogang-icpc-team.github.io-react/public/downloads/spc/2020/solutions.pdf
Binary file not shown.
Binary file added
BIN
+562 KB
sogang-icpc-team.github.io-react/public/downloads/spc/2021/champion.pdf
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+441 KB
sogang-icpc-team.github.io-react/public/downloads/spc/2021/solutions.pdf
Binary file not shown.
Binary file added
BIN
+759 KB
sogang-icpc-team.github.io-react/public/downloads/spc/2022/solutions.pdf
Binary file not shown.
Binary file added
BIN
+2.74 MB
sogang-icpc-team.github.io-react/public/downloads/spc/2023/solutions.pdf
Binary file not shown.
48 changes: 48 additions & 0 deletions
48
sogang-icpc-team.github.io-react/src/app/spc-page/contexts/selected-spc-history-context.tsx
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,48 @@ | ||
import React, { createContext, useContext, useEffect, useState } from "react"; | ||
import { | ||
TSpcData, | ||
useSpcDataContext, | ||
} from "../../../contexts/spc-data-context"; | ||
|
||
export type TSelectedSpcHistoryContext = { | ||
year: number; | ||
setYear: React.Dispatch<React.SetStateAction<number>>; | ||
data: TSpcData["all"][number]; | ||
}; | ||
const SelectedSpcHistoryContext = createContext<TSelectedSpcHistoryContext>( | ||
null as any, | ||
); | ||
|
||
export const useSelectedSpcHistoryContext = () => | ||
useContext(SelectedSpcHistoryContext); | ||
|
||
export const SelectedSpcHistoryContextProvider = ({ | ||
initialValue, | ||
children, | ||
}: { | ||
initialValue: Pick<TSelectedSpcHistoryContext, "year">; | ||
children: React.ReactNode; | ||
}) => { | ||
const { all: spcDataset } = useSpcDataContext(); | ||
|
||
const [year, setYear] = useState(initialValue.year); | ||
const [data, setData] = useState(spcDataset.find((d) => d.year === year)); | ||
|
||
useEffect(() => { | ||
setData(spcDataset.find((d) => d.year === year)); | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, [year]); | ||
|
||
if (!data) { | ||
throw new Error( | ||
`[ERROR] History data for the year(${year}) does not exist.`, | ||
); | ||
} | ||
|
||
return ( | ||
<SelectedSpcHistoryContext.Provider | ||
value={{ year, setYear, data }} | ||
children={children} | ||
/> | ||
); | ||
}; |
37 changes: 37 additions & 0 deletions
37
sogang-icpc-team.github.io-react/src/app/spc-page/spc-contest-history-display.tsx
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,37 @@ | ||
import styled from "styled-components"; | ||
|
||
import { Section } from "@ui/section/section"; | ||
import { TAwardBadgeVariant } from "@ui/award-badge/award-badge"; | ||
import { AwardTable } from "@ui/award/award-table"; | ||
import { LinksAndReviews } from "@ui/award/links-and-reviews"; | ||
import { MedalIconDescriptions } from "@ui/award/medal-icon-descriptions"; | ||
|
||
import { useSelectedSpcHistoryContext } from "./contexts/selected-spc-history-context"; | ||
|
||
const _SpcContestHistoryDisplay = ({ className }: { className?: string }) => { | ||
const selectedHistory = useSelectedSpcHistoryContext(); | ||
|
||
const showMedalIconDescriptions = selectedHistory.data.contests.length > 0; | ||
|
||
return ( | ||
<div className={className}> | ||
{selectedHistory.data.contests.map( | ||
({ title, columns, data, award, links }) => ( | ||
<Section key={title}> | ||
<Section.Title>{title}</Section.Title> | ||
<Section.Body> | ||
<AwardTable | ||
columns={columns} | ||
data={data} | ||
award={award as unknown as TAwardBadgeVariant[]} | ||
/> | ||
<LinksAndReviews links={links} review={[]} /> | ||
</Section.Body> | ||
</Section> | ||
), | ||
)} | ||
{showMedalIconDescriptions && <MedalIconDescriptions />} | ||
</div> | ||
); | ||
}; | ||
export const SpcContestHistoryDisplay = styled(_SpcContestHistoryDisplay)``; |
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
79 changes: 79 additions & 0 deletions
79
sogang-icpc-team.github.io-react/src/app/spc-page/spc-summary.tsx
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,79 @@ | ||
import styled from "styled-components"; | ||
|
||
import { OpenInANewTabButton } from "@ui/button/open-in-a-new-tab-button"; | ||
import { FlexRow } from "@ui/flex/flex"; | ||
|
||
import { useSelectedSpcHistoryContext } from "./contexts/selected-spc-history-context"; | ||
|
||
const Bold = styled.span` | ||
font-weight: bold; | ||
`; | ||
/** | ||
* TODO: Improve styles | ||
*/ | ||
export const SpcSummary = () => { | ||
const { | ||
data: { edition, date, time, location, authors, links }, | ||
} = useSelectedSpcHistoryContext(); | ||
return ( | ||
<p> | ||
<Bold>{edition} Sogang Programming Contest</Bold> | ||
<br /> | ||
{date} {time} | ||
<br /> | ||
{location} | ||
<br /> | ||
{authors.length > 0 && `출제 - ${authors.join(", ")}`} | ||
<FlexRow alignItems="center" columnGap="8px" style={{ marginTop: 12 }}> | ||
{links.problems.workbookBOJ ? ( | ||
<> | ||
<OpenInANewTabButton | ||
href={links.problems.workbookBOJ.Challenger} | ||
children="BOJ 문제 (Challenger)" | ||
/> | ||
<OpenInANewTabButton | ||
href={links.problems.workbookBOJ.Champion} | ||
children="BOJ 문제 (Champion)" | ||
/> | ||
</> | ||
) : null} | ||
{links.scoreboards ? ( | ||
<> | ||
<OpenInANewTabButton | ||
href={links.scoreboards.Master} | ||
children="스코어보드 (Master)" | ||
/> | ||
<OpenInANewTabButton | ||
href={links.scoreboards.Champion} | ||
children="스코어보드 (Champion)" | ||
/> | ||
</> | ||
) : null} | ||
{links.problems.BOJ ? ( | ||
<OpenInANewTabButton | ||
href={links.problems.BOJ} | ||
children="문제 (BOJ)" | ||
/> | ||
) : null} | ||
{links.problems.PDF ? ( | ||
<> | ||
<OpenInANewTabButton | ||
href={links.problems.PDF.Master} | ||
children="문제 (PDF)" | ||
/> | ||
<OpenInANewTabButton | ||
href={links.problems.PDF.Champion} | ||
children="문제 (PDF)" | ||
/> | ||
</> | ||
) : null} | ||
{links.solutions ? ( | ||
<OpenInANewTabButton | ||
href={links.solutions.PDF} | ||
children="해설 (PDF)" | ||
/> | ||
) : null} | ||
</FlexRow> | ||
</p> | ||
); | ||
}; |
10 changes: 6 additions & 4 deletions
10
sogang-icpc-team.github.io-react/src/contexts/assets/spc-data/2011.ts
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 |
---|---|---|
@@ -1,12 +1,14 @@ | ||
export default { | ||
year: 2011, | ||
edition: "제 7회", | ||
date: "", | ||
time: "", | ||
location: "", | ||
links: { | ||
problems: { | ||
BOJ: { | ||
Challenger: "https://www.acmicpc.net/workbook/view/24", | ||
Champion: "https://www.acmicpc.net/workbook/view/25", | ||
}, | ||
BOJ: null, | ||
}, | ||
}, | ||
authors: [], | ||
contests: [], | ||
}; |
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
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
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
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
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
Oops, something went wrong.