diff --git a/src/components/global/SubMenu/SubMenu.stories.tsx b/src/components/global/SubMenu/SubMenu.stories.tsx new file mode 100644 index 00000000..72a3c4f3 --- /dev/null +++ b/src/components/global/SubMenu/SubMenu.stories.tsx @@ -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) => ( + + + + ), + ], + argTypes: { + text: { control: 'text', description: '공지사항 텍스트' }, + to: { control: 'text', description: '이동할 페이지 URL' }, + }, +} as Meta; + +const Template: StoryFn = (args) => ; + +export const Default = Template.bind({}); +Default.args = { + text: '공지사항 보기', + to: '/notice', +}; + +export const CustomText = Template.bind({}); +CustomText.args = { + text: '설정 페이지로 이동', + to: '/settings', +}; diff --git a/src/components/global/SubMenu/SubMenu.tsx b/src/components/global/SubMenu/SubMenu.tsx new file mode 100644 index 00000000..e6a260ba --- /dev/null +++ b/src/components/global/SubMenu/SubMenu.tsx @@ -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 ( + + {text} + + + ); +}