-
Notifications
You must be signed in to change notification settings - Fork 3
✨ Feat(#2): Sidebar 제작 #65
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
Changes from all commits
70ec9da
3b59e95
cee380d
73d037f
39625b8
2fc7487
fcab75e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| import Image from 'next/image'; | ||
| import Link from 'next/link'; | ||
|
|
||
| import crown from '@/../public/icons/crown.svg'; | ||
| import { Dashboard } from '@/types/Dashboard.interface'; | ||
|
|
||
| interface DashboardItemProps { | ||
| dashboard: Dashboard; | ||
| nowDashboard?: number; | ||
| } | ||
|
|
||
| export default function DashboardItem({ dashboard, nowDashboard }: DashboardItemProps) { | ||
| const isActive = nowDashboard === dashboard.id; | ||
| const itemClasses = `flex items-center gap-4 rounded-md px-3 py-3 ${isActive ? 'bg-violet_f1 text-black_33' : 'text-gray_78'} hover:bg-violet_f1`; | ||
|
|
||
| return ( | ||
| <li> | ||
| <Link href={`/dashboard/${dashboard.id}`} className={itemClasses}> | ||
| <div className='rounded-full p-1' style={{ backgroundColor: dashboard.color }} /> | ||
| <p className='text-lg font-medium'>{dashboard.title}</p> | ||
| {dashboard.createdByMe && <Image src={crown} alt='my' />} | ||
| </Link> | ||
| </li> | ||
| ); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| import Image from 'next/image'; | ||
| import Link from 'next/link'; | ||
| import { useRouter } from 'next/router'; | ||
| import { useSelector } from 'react-redux'; | ||
|
|
||
| import DashboardItem from './DashboardItem'; | ||
|
|
||
| import logo from '@/../public/icons/logo.svg'; | ||
| import plus from '@/../public/icons/plus.svg'; | ||
| import { useFetchDashboards } from '@/hooks/useFetchDashboards'; | ||
| import { RootState } from '@/store/store'; | ||
|
|
||
| export default function Sidebar() { | ||
| const router = useRouter(); | ||
| const { id } = router.query; | ||
|
|
||
| const { isLoading } = useFetchDashboards(); | ||
| const dashboards = useSelector((state: RootState) => state.dashboards.dashboards); | ||
|
|
||
| if (isLoading) return <div>Loading...</div>; | ||
|
|
||
| return ( | ||
| <aside className='flex h-screen w-72 flex-col gap-14 border-r border-gray_d9 px-3 py-5'> | ||
| <Link href='/' className='px-3'> | ||
| <Image src={logo} alt='logo' priority /> | ||
| </Link> | ||
|
|
||
| <div className='flex flex-col gap-2'> | ||
| <div className='flex items-center justify-between'> | ||
| <p className='px-3 text-xs font-bold text-gray_78'>Dashboards</p> | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 글씨가 Dash Boards이고 좌우 여백이 나머지랑 다른 것 같아요!
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Dash Boards는 Dashboards가 한 단어인데 왜 나눠둔건지 모르겠어서 붙여뒀는데 Dash Boards로 수정 할까요?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 붙여두는게 맞는 것 같긴 하네요
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 오 확실히 기존 요구사항이랑 다르게 제작한 거 작성해 주는 게 더 나았겠네요. 추가해 두겠습니다 |
||
| {/* 모달 연결 해야함 */} | ||
| <a href='#' className='p-3'> | ||
| <Image src={plus} alt='add' /> | ||
| </a> | ||
| </div> | ||
| <div className='mx-2 mb-2 border-b border-gray_d9' /> | ||
| <ul className='flex flex-col gap-2'> | ||
| {dashboards.map((dashboard) => ( | ||
| <DashboardItem key={dashboard.id} dashboard={dashboard} nowDashboard={Number(id)} /> | ||
| ))} | ||
| </ul> | ||
| </div> | ||
| </aside> | ||
| ); | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
절대 경로도 저렇게 상위 폴더로 움직일 수 있네요... 꿀팁 하나 배워갑니다
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
width, height를 지정하지 않아도 되기 때문에 이 방식을 사용하시는 걸까요?? 성능상 장점도 있을까요??
이렇게 쓰는게 더 좋다면 aliasing 바꾸는 게 편하지 않을까요?? (큰 차이 있는 건 아니지만..)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🫡👍