-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #153 from prgrms-web-devcourse-final-project/feature/
#72 feat: MenuBottomSheet 컴포넌트 개발
- Loading branch information
Showing
8 changed files
with
112 additions
and
9 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
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,31 @@ | ||
import type { ComponentProps } from "react"; | ||
import { TextButton } from "components/atoms"; | ||
import { ModalBottomSheet } from "components/molecules"; | ||
import type { IMenu } from "types"; | ||
import { MenuBottomSheetWrapper } from "./styled"; | ||
|
||
interface IMenuBottomSheetProps | ||
extends ComponentProps<typeof ModalBottomSheet> { | ||
/** 메뉴 목록 */ | ||
menus: IMenu[]; | ||
} | ||
|
||
export const MenuBottomSheet = ({ | ||
open, | ||
onClose, | ||
menus, | ||
}: IMenuBottomSheetProps) => { | ||
return ( | ||
<MenuBottomSheetWrapper open={open} onClose={onClose}> | ||
{menus.map(({ content, onClick }, idx) => ( | ||
<TextButton | ||
key={`bottom_menu_${idx}`} | ||
text={content} | ||
onClick={onClick} | ||
backgroundColor="transparent" | ||
size="l" | ||
/> | ||
))} | ||
</MenuBottomSheetWrapper> | ||
); | ||
}; |
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,41 @@ | ||
import { useState } from "react"; | ||
import type { Meta, StoryObj } from "@storybook/react"; | ||
import { MenuBottomSheet } from "."; | ||
|
||
const meta: Meta<typeof MenuBottomSheet> = { | ||
title: "Organisms/MenuBottomSheet", | ||
component: MenuBottomSheet, | ||
tags: ["autodocs"], | ||
decorators: (story) => <div style={{ height: "300px" }}>{story()}</div>, | ||
render: (args) => { | ||
const Component = () => { | ||
const [open, setOpen] = useState(args.open); | ||
return ( | ||
<> | ||
<button onClick={() => setOpen(true)}>Open</button> | ||
<MenuBottomSheet | ||
open={open} | ||
onClose={() => setOpen(false)} | ||
menus={args.menus} | ||
/> | ||
</> | ||
); | ||
}; | ||
return <Component />; | ||
}, | ||
}; | ||
|
||
type Story = StoryObj<typeof meta>; | ||
|
||
export const Default: Story = { | ||
args: { | ||
open: true, | ||
menus: [ | ||
{ content: "조기 종료", onClick: () => console.log("조기 종료") }, | ||
{ content: "게시글 수정", onClick: () => console.log("게시글 수정") }, | ||
{ content: "삭제", onClick: () => console.log("삭제") }, | ||
], | ||
}, | ||
}; | ||
|
||
export default meta; |
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,28 @@ | ||
import type { ComponentProps } from "react"; | ||
import styled, { type StyledComponent } from "@emotion/styled"; | ||
import { ModalBottomSheet } from "components/molecules"; | ||
import { TextButtonWrapper } from "components/atoms/Button/TextButton/styled"; | ||
|
||
export const MenuBottomSheetWrapper: StyledComponent< | ||
ComponentProps<typeof ModalBottomSheet> | ||
> = styled(ModalBottomSheet)` | ||
display: flex; | ||
flex-direction: column; | ||
gap: 0.25rem; | ||
padding: 0.125rem 0 0; | ||
overflow: hidden; | ||
${TextButtonWrapper} { | ||
position: relative; | ||
&:hover { | ||
background-color: #f9f9f9; | ||
} | ||
&:not(:last-child)::after { | ||
content: ""; | ||
display: block; | ||
position: absolute; | ||
bottom: -0.125rem; | ||
width: 100%; | ||
border-bottom: 1px solid #d9d9d9; | ||
} | ||
} | ||
`; |
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
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,6 @@ | ||
export interface IMenu { | ||
/** 메뉴 이름 */ | ||
content: string; | ||
/** 메뉴 아이템 클릭시 일어나는 이벤트 */ | ||
onClick: () => void; | ||
} |