-
Notifications
You must be signed in to change notification settings - Fork 1
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
1 parent
1816314
commit 0d5cd15
Showing
4 changed files
with
45 additions
and
47 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
34 changes: 14 additions & 20 deletions
34
src/components/Common/NavigationBar/NavigationItem.stories.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,39 +1,33 @@ | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
import { NavigationItem } from './NavigationItem'; | ||
import { FaReact } from 'react-icons/fa'; | ||
import { MemoryRouter } from 'react-router-dom'; | ||
|
||
const meta: Meta<typeof NavigationItem> = { | ||
component: NavigationItem, | ||
title: 'atoms/NavigationItem', | ||
tags: ['autodocs'], | ||
decorators: [ | ||
(Story) => ( | ||
<MemoryRouter> | ||
<Story /> | ||
</MemoryRouter> | ||
) | ||
], | ||
argTypes: { | ||
icon: { | ||
description: '아이콘입니다.' | ||
}, | ||
label: { | ||
description: '탭을 설명하는 타이틀 입니다.' | ||
}, | ||
isActive: { | ||
description: '선택 상태' | ||
} | ||
icon: { description: '아이콘입니다.' }, | ||
label: { description: '탭을 설명하는 타이틀 입니다.' }, | ||
path: { description: '페이지 경로 입니다.' } | ||
} | ||
}; | ||
export default meta; | ||
|
||
type Story = StoryObj<typeof NavigationItem>; | ||
|
||
export const deactive: Story = { | ||
export const Deactive: Story = { | ||
args: { | ||
icon: <FaReact />, | ||
label: 'title', | ||
isActive: false | ||
} | ||
}; | ||
|
||
export const active: Story = { | ||
args: { | ||
icon: <FaReact />, | ||
label: 'title', | ||
isActive: true | ||
label: '설명', | ||
path: '/' | ||
} | ||
}; |
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,29 +1,24 @@ | ||
import React from 'react'; | ||
import { NavLink } from 'react-router-dom'; | ||
|
||
type NavigationItemProps = { | ||
icon: React.ReactNode; | ||
label: string; | ||
isActive: boolean; | ||
onClick: () => void; | ||
path: string; | ||
}; | ||
|
||
export const NavigationItem = ({ | ||
icon, | ||
label, | ||
isActive, | ||
onClick | ||
}: NavigationItemProps) => { | ||
export const NavigationItem = ({ icon, label, path }: NavigationItemProps) => { | ||
return ( | ||
<button | ||
className={`flex flex-col items-center justify-center p-2 ${ | ||
isActive ? 'text-blue-500' : 'text-gray-400' | ||
}`} | ||
onClick={onClick} | ||
<NavLink | ||
to={path} | ||
className={({ isActive }) => | ||
`flex flex-col items-center justify-center p-2 ${ | ||
isActive ? 'text-blue-500' : 'text-gray-400' | ||
}` | ||
} | ||
> | ||
<div className={`${isActive ? 'fill-blue-500' : 'fill-gray-400'}`}> | ||
{icon} | ||
</div> | ||
<div>{icon}</div> | ||
<span className="text-sm">{label}</span> | ||
</button> | ||
</NavLink> | ||
); | ||
}; |