Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions public/icons/crown.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions public/icons/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions public/icons/plus.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions src/components/Sidebar/DashboardItem.tsx
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>
);
}
46 changes: 46 additions & 0 deletions src/components/Sidebar/index.tsx
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';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

절대 경로도 저렇게 상위 폴더로 움직일 수 있네요... 꿀팁 하나 배워갑니다

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

width, height를 지정하지 않아도 되기 때문에 이 방식을 사용하시는 걸까요?? 성능상 장점도 있을까요??
이렇게 쓰는게 더 좋다면 aliasing 바꾸는 게 편하지 않을까요?? (큰 차이 있는 건 아니지만..)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • 제가 이렇게 사용하는 거는 코드가 좀 더 깔끔해 보여서 사용하는 거여서 큰 이유는 없습니다.
  • aliasing 바꾸는 거는 public에 접근할 일이 이미지 찾아가는 거 외에는 없는데 aliasing을 root로 바꾸면 src를 매번 입력해 줘야 하고 지금 작성한 코드들의 경로도 수정해 줘야 해서 굳이 변경 안 해도 될 거 같습니다.
    🫡👍

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>

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

글씨가 Dash Boards이고 좌우 여백이 나머지랑 다른 것 같아요!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dash Boards는 Dashboards가 한 단어인데 왜 나눠둔건지 모르겠어서 붙여뒀는데 Dash Boards로 수정 할까요?
여백은 바로 수정하겠습니다 🫡

Copy link
Contributor

@un0211 un0211 Jun 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

붙여두는게 맞는 것 같긴 하네요
기존 요구사항이랑 의도적으로 다르게 한 점이 있으면 이유와 함께 PR에 명시하는 게 좋을 것 같아요~~
아래 있는 구분선도 있는 게 구별이 잘 될 것 같아서 추가한 건가요??

Copy link
Contributor Author

@wjsdncl wjsdncl Jun 24, 2024

Choose a reason for hiding this comment

The 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>
);
}