Skip to content

Commit

Permalink
[#361] BottomNavigation 컴포넌트 (#392)
Browse files Browse the repository at this point in the history
* style: 누락된 theme 컬러 값 추가

* feat: BottomNavigationItem 컴포넌트 작성

* feat: BottomNavigation 컴포너트 작성

* feat: BottomNavigation 스토리북 작성

* fix: 스토리북 docs에 컴포넌트가 올바르게 표시되지 않던 문제 해결

* refactor: NavigationItem 컴포넌트 코드이동 및 삭제

* refactor: icon 크기 정의 방법을 수정

* refactor: getIconColorClasses()를 조건반환문 으로 변경

* chore: iconColor 상수를 컴포넌트 바깥으로 이동
  • Loading branch information
hanyugeon authored and gxxrxn committed Jun 17, 2024
1 parent f5bf5ef commit d7d8ca6
Show file tree
Hide file tree
Showing 3 changed files with 135 additions and 1 deletion.
72 changes: 72 additions & 0 deletions src/stories/Base/BottomNavigation.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import { Meta, StoryObj } from '@storybook/react';

import BottomNavigation from '@/ui/Base/BottomNavigation';

const meta: Meta<typeof BottomNavigation> = {
title: 'Base/BottomNavigation',
component: BottomNavigation,
tags: ['autodocs'],
parameters: {
docs: {
story: {
inline: false,
},
},
},
};

export default meta;

type Story = StoryObj<typeof BottomNavigation>;

export const Default: Story = {
parameters: {
nextjs: {
navigation: {
pathname: '/bookarchive',
},
},
},
render: () => {
return <BottomNavigation />;
},
};

export const Search: Story = {
parameters: {
nextjs: {
navigation: {
pathname: '/book/search',
},
},
},
render: () => {
return <BottomNavigation />;
},
};

export const Group: Story = {
parameters: {
nextjs: {
navigation: {
pathname: '/group',
},
},
},
render: () => {
return <BottomNavigation />;
},
};

export const Profile: Story = {
parameters: {
nextjs: {
navigation: {
pathname: '/profile/me',
},
},
},
render: () => {
return <BottomNavigation />;
},
};
61 changes: 61 additions & 0 deletions src/ui/Base/BottomNavigation.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
'use client';

import {
IconBookarchive,
IconDiscover,
IconGroup,
IconProfile,
} from '@public/icons';
import Link from 'next/link';
import { usePathname } from 'next/navigation';

const icons = [
{
icon: <IconBookarchive />,
label: '북카이브',
href: '/bookarchive',
},
{
icon: <IconDiscover />,
label: '도서 검색',
href: '/book/search',
},
{
icon: <IconGroup />,
label: '독서 모임',
href: '/group',
},
{
icon: <IconProfile />,
label: '내 프로필',
href: '/profile/me',
},
];

const iconColor = {
active: 'fill-main-900 text-main-900',
inactive: 'fill-placeholder text-placeholder',
} as const;

const BottomNavigation = () => {
const pathname = usePathname();

return (
<div className="border-top-[0.05rem] fixed bottom-0 flex h-[6.4rem] w-full max-w-[39.3rem] justify-between border-black-200 bg-white px-[2.6rem] pb-[1.2rem] pt-[0.8rem]">
{icons.map(({ icon, label, href }) => (
<Link key={label} type="button" href={href}>
<div
className={`flex h-[4.4rem] w-[4.6rem] flex-col items-center justify-center text-xs font-bold ${
href === pathname ? iconColor.active : iconColor.inactive
}`}
>
<div className="h-[2.6rem] w-[2.6rem] text-placeholder">{icon}</div>
{label}
</div>
</Link>
))}
</div>
);
};

export default BottomNavigation;
3 changes: 2 additions & 1 deletion tailwind.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ module.exports = {
kakao: '#FEE102',
kakaotext: '#191600',
black: {
200: '#F4F4F4',
100: '#F4F4F4',
200: '#E9E9E9',
300: '#ECECEC',
400: '#D9D9D9',
500: '#8D8D8D',
Expand Down

0 comments on commit d7d8ca6

Please sign in to comment.