diff --git a/src/App.tsx b/src/App.tsx index 9a708787..b2ef3339 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,3 +1,4 @@ +import './styles/index.css' import { RouterProvider } from 'react-router-dom' import { router } from './routes' import './styles/index.css' diff --git a/src/components/common/header/Header.stories.tsx b/src/components/common/header/Header.stories.tsx new file mode 100644 index 00000000..df5f1a01 --- /dev/null +++ b/src/components/common/header/Header.stories.tsx @@ -0,0 +1,57 @@ +import type { Meta, StoryObj } from '@storybook/react' +import Header from './Header' +const meta = { + title: 'Component/Header', + component: Header, + parameters: { + layout: 'centered' + }, + tags: ['autodocs'], + argTypes: { + headerType: { + control: 'select', + options: ['BackPush', 'Logo', 'Close', 'CloseWithTitle'] + }, + pageTitle: { + control: 'text' + }, + rightElement: { + control: 'text' + } + } +} satisfies Meta + +export default meta +type Story = StoryObj + +export const BackPushHeader: Story = { + args: { + headerType: 'BackPush' + } +} + +export const LogoHeader: Story = { + args: { + headerType: 'Logo', + pageTitle: 'pageName', + rightElement: ( + <> + {'👏'} + {'👏'} + + ) + } +} + +export const CloseHeader: Story = { + args: { + headerType: 'Close' + } +} + +export const CloseWithTitleHeader: Story = { + args: { + headerType: 'CloseWithTitle', + pageTitle: 'pageName' + } +} diff --git a/src/components/common/header/Header.tsx b/src/components/common/header/Header.tsx new file mode 100644 index 00000000..9f032459 --- /dev/null +++ b/src/components/common/header/Header.tsx @@ -0,0 +1,62 @@ +import type { HeaderProps } from './HeaderType' +import Icon from '../icon/Icon' + +const Header = ({ + headerType, + pageTitle = 'pageTitle', + onClick +}: HeaderProps) => { + return ( +
+
+ {headerType === 'BackPush' ? ( + alert('뒤로가기')}> + + + ) : headerType === 'Logo' ? ( + <> +
+ {'👍'} + + {pageTitle} + +
+
+
alert('알림보기!')}> + +
+ alert('사이드 바 열기')}> + + +
+ + ) : headerType === 'Close' ? ( + + + + ) : headerType === 'CloseWithTitle' ? ( +
+ + + + {pageTitle} +
+ ) : ( + '' + )} +
+
+ ) +} + +export default Header diff --git a/src/components/common/header/HeaderType.ts b/src/components/common/header/HeaderType.ts new file mode 100644 index 00000000..1554dece --- /dev/null +++ b/src/components/common/header/HeaderType.ts @@ -0,0 +1,9 @@ +import { ReactNode } from 'react' + +type HeaderType = 'BackPush' | 'Logo' | 'Close' | 'CloseWithTitle' +export interface HeaderProps { + headerType: HeaderType + pageTitle?: string + rightElement?: ReactNode + onClick?: () => void +}