-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
2 changed files
with
72 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import React from 'react'; | ||
import { Meta, StoryFn } from '@storybook/react'; | ||
import { SubMenu, SubMenuProps } from './SubMenu'; | ||
import { BrowserRouter } from 'react-router-dom'; | ||
|
||
export default { | ||
title: 'Components/SubMenu', | ||
component: SubMenu, | ||
decorators: [ | ||
(Story) => ( | ||
<BrowserRouter> | ||
<Story /> | ||
</BrowserRouter> | ||
), | ||
], | ||
argTypes: { | ||
text: { control: 'text', description: '공지사항 텍스트' }, | ||
to: { control: 'text', description: '이동할 페이지 URL' }, | ||
}, | ||
} as Meta; | ||
|
||
const Template: StoryFn<SubMenuProps> = (args) => <SubMenu {...args} />; | ||
|
||
export const Default = Template.bind({}); | ||
Default.args = { | ||
text: '공지사항 보기', | ||
to: '/notice', | ||
}; | ||
|
||
export const CustomText = Template.bind({}); | ||
CustomText.args = { | ||
text: '설정 페이지로 이동', | ||
to: '/settings', | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { ReactNode } from 'react'; | ||
import { Arrow } from '../../../assets/svg'; | ||
import { useNavigate } from 'react-router-dom'; | ||
import styled from 'styled-components'; | ||
import theme from '../../../style/theme'; | ||
interface SubMenuProps { | ||
text: string; // 공지사항 텍스트 | ||
to: string; // 이동할 페이지 URL | ||
} | ||
|
||
const StyledSubMenu = styled.div` | ||
display: flex; | ||
align-items: center; | ||
cursor: pointer; | ||
font-size: 16px; | ||
color: ${theme.colors.black100}; | ||
justify-content: space-between; | ||
`; | ||
|
||
const Text = styled.span` | ||
white-space: nowrap; | ||
font-size: 16px; | ||
color: ${theme.colors.black100}; | ||
`; | ||
|
||
export function SubMenu({ text, to }: SubMenuProps) { | ||
const navigate = useNavigate(); | ||
const handleClick = () => { | ||
navigate(to); // to에 지정된 URL로 이동 | ||
}; | ||
|
||
return ( | ||
<StyledSubMenu onClick={handleClick}> | ||
<Text>{text}</Text> | ||
<Arrow width="15px" height="27px" /> | ||
</StyledSubMenu> | ||
); | ||
} |