-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
182 additions
and
75 deletions.
There are no files selected for viewing
128 changes: 103 additions & 25 deletions
128
frontend/src/components/dashboard/DashboardSidebar/index.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 |
---|---|---|
@@ -1,45 +1,123 @@ | ||
import Logo from '@assets/images/logo.svg'; | ||
import Accordion from '@components/_common/molecules/Accordion'; | ||
import { routes } from '@router/path'; | ||
import { Link } from 'react-router-dom'; | ||
import { Link, useLocation } from 'react-router-dom'; | ||
|
||
import type { RecruitmentStatusObject } from '@utils/compareTime'; | ||
|
||
import { Fragment } from 'react/jsx-runtime'; | ||
import { HiChevronDoubleLeft, HiOutlineHome } from 'react-icons/hi2'; | ||
import { HiOutlineMenu } from 'react-icons/hi'; | ||
import { GrDocumentTime, GrDocumentUser, GrDocumentVerified } from 'react-icons/gr'; | ||
|
||
import IconButton from '@components/_common/atoms/IconButton'; | ||
import LogoutButton from './LogoutButton'; | ||
|
||
import S from './style'; | ||
|
||
interface Option { | ||
text: string; | ||
isSelected: boolean; | ||
applyFormId: string; | ||
dashboardId: string; | ||
status: RecruitmentStatusObject; | ||
} | ||
|
||
interface SidebarStyle { | ||
isSidebarOpen: boolean; | ||
onClickSidebarToggle: () => void; | ||
} | ||
|
||
interface DashboardSidebarProps { | ||
sidebarStyle: SidebarStyle; | ||
options: Option[]; | ||
} | ||
|
||
export default function DashboardSidebar({ options }: DashboardSidebarProps) { | ||
export default function DashboardSidebar({ sidebarStyle, options }: DashboardSidebarProps) { | ||
const pendingPosts = options.filter(({ status }) => status.isPending); | ||
const onGoingPosts = options.filter(({ status }) => status.isOngoing); | ||
const closedPosts = options.filter(({ status }) => status.isClosed); | ||
|
||
const sidebarContentList = [ | ||
{ title: '모집 예정 공고 목록', posts: pendingPosts }, | ||
{ title: '진행 중 공고 목록', posts: onGoingPosts }, | ||
{ title: '마감 된 공고 목록', posts: closedPosts }, | ||
]; | ||
const location = useLocation(); | ||
|
||
return ( | ||
<S.Container> | ||
<Link to={routes.dashboard.list()}> | ||
<S.Logo | ||
src={Logo} | ||
alt="크루루 로고" | ||
/> | ||
</Link> | ||
|
||
<S.Contents> | ||
<Accordion title={<Link to={routes.dashboard.list()}>공고</Link>}> | ||
{options.map(({ text, isSelected, applyFormId, dashboardId }, index) => ( | ||
// eslint-disable-next-line react/no-array-index-key | ||
<Accordion.ListItem key={index}> | ||
<S.LinkContainer isSelected={isSelected}> | ||
<Link to={routes.dashboard.post({ dashboardId, applyFormId })}>{text}</Link> | ||
</S.LinkContainer> | ||
</Accordion.ListItem> | ||
))} | ||
</Accordion> | ||
</S.Contents> | ||
|
||
<LogoutButton /> | ||
<S.Container isSidebarOpen={sidebarStyle.isSidebarOpen}> | ||
<S.SidebarHeader> | ||
{sidebarStyle.isSidebarOpen && ( | ||
<Link to={routes.dashboard.list()}> | ||
<S.Logo | ||
src={Logo} | ||
alt="크루루 로고" | ||
/> | ||
</Link> | ||
)} | ||
|
||
<IconButton | ||
size="sm" | ||
outline={false} | ||
onClick={sidebarStyle.onClickSidebarToggle} | ||
> | ||
{sidebarStyle.isSidebarOpen ? <HiChevronDoubleLeft /> : <HiOutlineMenu />} | ||
</IconButton> | ||
</S.SidebarHeader> | ||
|
||
<nav> | ||
<S.Contents> | ||
<S.SidebarItem> | ||
<Link to={routes.dashboard.list()}> | ||
<S.SidebarItemLink isSelected={location.pathname === routes.dashboard.list()}> | ||
<HiOutlineHome | ||
size={24} | ||
strokeWidth={2.4} | ||
/> | ||
{sidebarStyle.isSidebarOpen && <S.SidebarItemText>모집 공고</S.SidebarItemText>} | ||
</S.SidebarItemLink> | ||
</Link> | ||
</S.SidebarItem> | ||
|
||
<S.Divider /> | ||
|
||
{sidebarContentList.map(({ title, posts }) => { | ||
if (posts.length === 0) return; | ||
return ( | ||
<Fragment key={title}> | ||
<S.ContentSubTitle>{sidebarStyle.isSidebarOpen ? title : <S.Circle />}</S.ContentSubTitle> | ||
{posts.map(({ text, isSelected, applyFormId, dashboardId, status }) => ( | ||
<S.SidebarItem key={applyFormId}> | ||
<Link to={routes.dashboard.post({ dashboardId, applyFormId })}> | ||
<S.SidebarItemLink isSelected={isSelected}> | ||
{status.isPending ? ( | ||
<GrDocumentTime | ||
size={24} | ||
strokeWidth={2} | ||
/> | ||
) : status.isOngoing ? ( | ||
<GrDocumentUser | ||
size={24} | ||
strokeWidth={2} | ||
/> | ||
) : status.isClosed ? ( | ||
<GrDocumentVerified | ||
size={24} | ||
strokeWidth={2} | ||
/> | ||
) : null} | ||
{sidebarStyle.isSidebarOpen && <S.SidebarItemText>{text}</S.SidebarItemText>} | ||
</S.SidebarItemLink> | ||
</Link> | ||
</S.SidebarItem> | ||
))} | ||
</Fragment> | ||
); | ||
})} | ||
</S.Contents> | ||
</nav> | ||
|
||
{sidebarStyle.isSidebarOpen && <LogoutButton />} | ||
</S.Container> | ||
); | ||
} |
77 changes: 58 additions & 19 deletions
77
frontend/src/components/dashboard/DashboardSidebar/style.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,57 +1,96 @@ | ||
import styled from '@emotion/styled'; | ||
|
||
const Container = styled.div` | ||
const Container = styled.div<{ isSidebarOpen: boolean }>` | ||
position: relative; | ||
width: 28rem; | ||
width: ${({ isSidebarOpen }) => (isSidebarOpen ? '276px' : '56px')}; | ||
height: 100%; | ||
border-right: 1px solid ${({ theme }) => theme.baseColors.grayscale[400]}; | ||
padding: 3.6rem 1.6rem; | ||
background-color: ${({ theme }) => theme.baseColors.grayscale[50]}; | ||
border-radius: 1.6rem 0 0 1.6rem; | ||
display: flex; | ||
flex-direction: column; | ||
gap: 3.2rem; | ||
gap: 4rem; | ||
`; | ||
|
||
const SidebarHeader = styled.div` | ||
display: flex; | ||
justify-content: space-between; | ||
align-items: center; | ||
height: 2.4rem; | ||
`; | ||
|
||
const Logo = styled.img` | ||
height: 2.4rem; | ||
`; | ||
|
||
const Contents = styled.nav` | ||
const Contents = styled.ul` | ||
display: flex; | ||
flex-direction: column; | ||
gap: 1.4rem; | ||
gap: 2rem; | ||
`; | ||
|
||
const LinkContainer = styled.div<{ isSelected: boolean }>` | ||
${({ theme }) => theme.typography.common.block} | ||
color: ${({ theme, isSelected }) => (isSelected ? theme.colors.brand.primary : theme.colors.text.default)}; | ||
margin-bottom: 0; | ||
const SidebarItem = styled.li` | ||
list-style: none; | ||
`; | ||
|
||
const SidebarItemLink = styled.div<{ isSelected: boolean }>` | ||
display: flex; | ||
align-items: flex-start; | ||
align-items: center; | ||
gap: 1rem; | ||
color: ${({ theme }) => theme.baseColors.grayscale[900]}; | ||
opacity: ${({ isSelected }) => (isSelected ? 0.99 : 0.4)}; | ||
transition: opacity 0.2s ease; | ||
& > button > a { | ||
text-align: start; | ||
&:hover { | ||
opacity: 0.99; | ||
} | ||
`; | ||
|
||
const SidebarItemText = styled.p` | ||
width: 21rem; | ||
white-space: nowrap; | ||
overflow: hidden; | ||
text-overflow: ellipsis; | ||
${({ theme }) => theme.typography.common.largeAccent} | ||
`; | ||
|
||
const Divider = styled.div` | ||
border-bottom: 0.15rem solid ${({ theme }) => theme.baseColors.grayscale[400]}; | ||
`; | ||
|
||
const ContentSubTitle = styled.p` | ||
height: 2rem; | ||
color: ${({ theme }) => theme.baseColors.grayscale[500]}; | ||
${({ theme }) => theme.typography.common.default} | ||
`; | ||
|
||
const Circle = styled.div` | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
width: 100%; | ||
&::before { | ||
content: '•'; | ||
display: block; | ||
width: 1rem; | ||
aspect-ratio: 1/1; | ||
margin: 0 0.8rem; | ||
scale: 1.3; | ||
} | ||
`; | ||
|
||
const S = { | ||
Container, | ||
SidebarHeader, | ||
Logo, | ||
Contents, | ||
LinkContainer, | ||
SidebarItem, | ||
SidebarItemLink, | ||
SidebarItemText, | ||
Divider, | ||
ContentSubTitle, | ||
Circle, | ||
}; | ||
|
||
export default S; |
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