-
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.
Extract HistoryPage ui components into
@ui
- Loading branch information
1 parent
c831e66
commit aa5ee0c
Showing
7 changed files
with
208 additions
and
57 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
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
46 changes: 46 additions & 0 deletions
46
sogang-icpc-team.github.io-react/src/common/ui/award/award-table.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,46 @@ | ||
import { Table } from "@ui/table/table"; | ||
import { AwardBadge, TAwardBadgeVariant } from "@ui/award-badge/award-badge"; | ||
|
||
export const AwardTable = ({ | ||
columns, | ||
data, | ||
award, | ||
}: { | ||
columns: string[]; | ||
data: string[][]; | ||
award: TAwardBadgeVariant[]; | ||
}) => { | ||
return ( | ||
<Table.Wrapper> | ||
<Table> | ||
<Table.Header> | ||
<Table.Row> | ||
{columns.map((h, i) => ( | ||
<Table.Head key={i}>{h}</Table.Head> | ||
))} | ||
</Table.Row> | ||
</Table.Header> | ||
<Table.Body> | ||
{data.map((r, rowIndex) => ( | ||
<Table.Row key={rowIndex}> | ||
{r.map((c, colIndex) => { | ||
// FIXME: data 형식을 string[] -> json으로 일괄 변경해야 함 | ||
if (colIndex === 1) { | ||
return ( | ||
<Table.Cell key={colIndex}> | ||
{c} | ||
{award[rowIndex] ? ( | ||
<AwardBadge variant={award[rowIndex]} /> | ||
) : null} | ||
</Table.Cell> | ||
); | ||
} | ||
return <Table.Cell key={colIndex}>{c}</Table.Cell>; | ||
})} | ||
</Table.Row> | ||
))} | ||
</Table.Body> | ||
</Table> | ||
</Table.Wrapper> | ||
); | ||
}; |
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
File renamed without changes.
127 changes: 127 additions & 0 deletions
127
sogang-icpc-team.github.io-react/src/common/ui/dropdown/year-selector-dropdown.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,127 @@ | ||
import styled, { createGlobalStyle, css } from "styled-components"; | ||
|
||
import { EmptyButton } from "@ui/button/empty-button"; | ||
import { Dropdown } from "@ui/dropdown/dropdown"; | ||
|
||
const _Item = ({ | ||
className, | ||
label, | ||
}: { | ||
className?: string; | ||
label: React.ReactNode; | ||
selected: boolean; | ||
}) => { | ||
return <li className={className}>{label}</li>; | ||
}; | ||
const Item = styled(_Item)` | ||
width: fit-content; | ||
font-size: 1.6rem; | ||
letter-spacing: -1px; | ||
color: #ddd; | ||
cursor: pointer; | ||
transition: 0.3s color ease; | ||
${({ selected }) => { | ||
if (selected) { | ||
return css` | ||
color: #000; | ||
font-weight: bold; | ||
`; | ||
} | ||
}} | ||
`; | ||
|
||
const DropdownTriggerButton = styled(EmptyButton)` | ||
align-items: center; | ||
gap: 0.4rem; | ||
padding: 0.2rem 1rem; | ||
border-radius: 12px; | ||
background-color: #0000000f; | ||
color: #535353; | ||
font-size: 1.6rem; | ||
letter-spacing: -1px; | ||
cursor: pointer; | ||
font-weight: bold; | ||
transition: 0.3s color ease; | ||
`; | ||
|
||
const DROPDOWN_CLASSNAME = "history-tab__year__dropdown"; | ||
const DropdownStyles = createGlobalStyle` | ||
.${DROPDOWN_CLASSNAME} ul { | ||
display: grid; | ||
grid-template-columns: repeat(4, 1fr); | ||
li { | ||
justify-content: center; | ||
} | ||
} | ||
`; | ||
const TriangleDownIcon = styled.span` | ||
font-size: 12px; | ||
`; | ||
|
||
const _YearSelectorDropdown = ({ | ||
className, | ||
items, | ||
year, | ||
setYear, | ||
}: { | ||
className?: string; | ||
items: { label: React.ReactNode; value: number }[]; | ||
year: number; | ||
setYear: React.Dispatch<React.SetStateAction<number>>; | ||
}) => { | ||
return ( | ||
<div className={className}> | ||
<DropdownStyles /> | ||
<Dropdown | ||
overlayClassName={DROPDOWN_CLASSNAME} | ||
placement="bottomLeft" | ||
trigger={["click"]} | ||
menu={{ | ||
items: items.map((item) => ({ | ||
key: item.value, | ||
onClick: () => setYear(item.value), | ||
label: <Item selected={year === item.value} label={item.label} />, | ||
})), | ||
}} | ||
children={ | ||
<DropdownTriggerButton | ||
onClick={(e) => { | ||
e.preventDefault(); | ||
}} | ||
> | ||
<span>{year}</span> | ||
<TriangleDownIcon>▼</TriangleDownIcon> | ||
</DropdownTriggerButton> | ||
} | ||
/> | ||
</div> | ||
); | ||
}; | ||
export const YearSelectorDropdown = styled(_YearSelectorDropdown)` | ||
overflow-x: auto; | ||
overflow-y: hidden; | ||
white-space: nowrap; | ||
&::-webkit-scrollbar { | ||
height: 5px; | ||
} | ||
&::-webkit-scrollbar-track { | ||
background: #fff; | ||
} | ||
&::-webkit-scrollbar-thumb { | ||
background: #eee; | ||
&:hover { | ||
background: #eee; | ||
} | ||
} | ||
`; |