-
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.
247 feat 편지 상세 보기 페이지 삭제 버튼 모달 컴포넌트 (#249)
* chore : 파일 경로 수정 * style : report 모달 열릴 때스타일 수정 * feat : 편지 상세 보기 페이지 삭제 버튼 모달 컴포넌트 완료
- Loading branch information
Showing
8 changed files
with
115 additions
and
62 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,40 @@ | ||
import { RiDeleteBin5Line } from 'react-icons/ri'; | ||
import { useState } from 'react'; | ||
import { DeleteModal } from './DeleteModal'; | ||
type DeleteButtonProps = { | ||
id: string; | ||
}; | ||
|
||
export const DeleteButton = ({ id }: DeleteButtonProps) => { | ||
const [isModalOpen, setIsModalOpen] = useState(false); | ||
|
||
const openModal = () => { | ||
setIsModalOpen(true); | ||
}; | ||
|
||
const closeModal = () => { | ||
setIsModalOpen(false); | ||
}; | ||
|
||
return ( | ||
<> | ||
<button className=" flex-center gap-1 p-2" onClick={openModal}> | ||
<RiDeleteBin5Line /> | ||
</button> | ||
|
||
{isModalOpen && ( | ||
<div | ||
className="fixed inset-0 mx-auto min-w-[375px] max-w-[475px] bg-black bg-opacity-50 flex-center z-50" | ||
onClick={closeModal} | ||
> | ||
<div | ||
onClick={(e) => e.stopPropagation()} | ||
className="bg-white rounded-lg p-6" | ||
> | ||
<DeleteModal id={id} closeModal={closeModal} /> | ||
</div> | ||
</div> | ||
)} | ||
</> | ||
); | ||
}; |
28 changes: 28 additions & 0 deletions
28
src/components/LetterDetailPage/Delete/DeleteModal.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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
import { DeleteModal } from './DeleteModal'; | ||
|
||
const meta: Meta<typeof DeleteModal> = { | ||
component: DeleteModal, | ||
title: 'molecule/DeleteModal', | ||
tags: ['autodocs'], | ||
argTypes: { | ||
id: { | ||
control: 'text', | ||
description: '삭제할 편지 ID.', | ||
defaultValue: '1234' | ||
}, | ||
closeModal: { | ||
action: 'closeModal', | ||
description: '모달 닫기 이벤트 핸들러' | ||
} | ||
} | ||
}; | ||
export default meta; | ||
|
||
type Story = StoryObj<typeof DeleteModal>; | ||
|
||
export const Default: Story = { | ||
args: { | ||
id: '1234' | ||
} | ||
}; |
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,29 @@ | ||
import { Margin } from '@/components/Common/Margin/Margin'; | ||
|
||
type DeleteModalProps = { | ||
id: string; | ||
closeModal: () => void; | ||
}; | ||
|
||
export const DeleteModal = ({ id, closeModal }: DeleteModalProps) => { | ||
return ( | ||
<div className="flex flex-col bg-white rounded-2xl items-center justify-center w-full h-full p-4"> | ||
<Margin top={10} /> | ||
<span className="font-bold mb-4 text-2xl"> | ||
{id}편지를 삭제하시겠습니까? | ||
</span> | ||
|
||
<div className="flex-center gap-2"> | ||
<button | ||
onClick={closeModal} | ||
className="mt-6 bg-slate-300 w-24 text-white px-4 py-2 rounded-lg" | ||
> | ||
닫기 | ||
</button> | ||
<button className="mt-6 bg-slate-500 w-24 text-white px-4 py-2 rounded-lg"> | ||
삭제하기 | ||
</button> | ||
</div> | ||
</div> | ||
); | ||
}; |
27 changes: 0 additions & 27 deletions
27
src/components/LetterDetailPage/DeleteButton/DeleteButton.stories.tsx
This file was deleted.
Oops, something went wrong.
17 changes: 0 additions & 17 deletions
17
src/components/LetterDetailPage/DeleteButton/DeleteButton.tsx
This file was deleted.
Oops, something went wrong.
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