-
Notifications
You must be signed in to change notification settings - Fork 0
[✨ Feat/#51] ConfirmModal 공통 컴포넌트 구현 #52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
41d4eb8
🎨 Style: Button border 굵기 수정
Lseojeong 0e515b2
✨ Feat: ConfirmModal 공통 컴포넌트 구현
Lseojeong bc629de
📝 Docs: ConfirmModal 스토리북 예제 추가
Lseojeong e9d3bb1
♻️ Refactor: ConfirmModal 타입 공개 범위 정리
Lseojeong e296183
✨ Feat: 모달 애니메이션 구현
Lseojeong 69e7e90
🚚 Rename: Slot 유틸 함수 파일 폴더 이동
Lseojeong bfa2af8
♻️ Refactor: ButtonProps 제거
Lseojeong 4959374
♻️ Refactor: ConfirmModal 로딩 상태 단순화
Lseojeong 9736403
📝 Docs: ConfirmModal TSDocs 수정
Lseojeong 6065d57
🎨 Style: ConfirmModal gap 조정
Lseojeong 9a9788d
♻️ Refactor: description 타입 string으로 조정
Lseojeong 9262564
♻️ Refactor: Surface 애니메이션 키프레임 이름 정리
Lseojeong 0c5dd49
📝 Docs: ConfirmModal 로딩 스토리 개선
Lseojeong File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,37 @@ | ||
| @keyframes surface-overlay-fade-in { | ||
| from { | ||
| opacity: 0; | ||
| } | ||
|
|
||
| to { | ||
| opacity: 1; | ||
| } | ||
| } | ||
|
|
||
| @keyframes surface-modal-slide-up { | ||
| from { | ||
| opacity: 0; | ||
| transform: translate3d(0, 40px, 0); | ||
| } | ||
|
|
||
| to { | ||
| opacity: 1; | ||
| transform: translate3d(0, 0, 0); | ||
| } | ||
| } | ||
|
|
||
| .surface-modal-overlay-animation { | ||
| animation: surface-overlay-fade-in 350ms ease-out both; | ||
| } | ||
|
|
||
| .surface-modal-animation { | ||
| will-change: transform, opacity; | ||
| animation: surface-modal-slide-up 350ms ease-out both; | ||
| } | ||
|
|
||
| @media (prefers-reduced-motion: reduce) { | ||
| .surface-modal-overlay-animation, | ||
| .surface-modal-animation { | ||
| animation: none; | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,202 @@ | ||
| import { useEffect, useRef, useState } from 'react'; | ||
| import type { ComponentProps } from 'react'; | ||
|
|
||
| import { Button } from '@/shared/ui/button'; | ||
|
|
||
| import { ConfirmModal } from './index'; | ||
|
|
||
| import type { Meta, StoryObj } from '@storybook/nextjs'; | ||
|
|
||
| type ConfirmModalStoryProps = ComponentProps<typeof ConfirmModal>; | ||
|
|
||
| function ButtonOpenConfirmModalExample(args: ConfirmModalStoryProps) { | ||
| const [isOpen, setIsOpen] = useState(false); | ||
|
|
||
| const handleConfirm = () => { | ||
| args.onConfirm(); | ||
| setIsOpen(false); | ||
| }; | ||
|
|
||
| const handleCancel = () => { | ||
| args.onCancel?.(); | ||
| }; | ||
|
|
||
| return ( | ||
| <div className="flex min-h-80 items-center justify-center"> | ||
| <Button onClick={() => setIsOpen(true)}>ConfirmModal 열기</Button> | ||
| <ConfirmModal | ||
| {...args} | ||
| onCancel={handleCancel} | ||
| onConfirm={handleConfirm} | ||
| onOpenChange={setIsOpen} | ||
| open={isOpen} | ||
| /> | ||
| </div> | ||
| ); | ||
| } | ||
|
|
||
| function ControlledConfirmModalExample() { | ||
| const [isOpen, setIsOpen] = useState(false); | ||
| const [message, setMessage] = useState('대기 중'); | ||
|
|
||
| const handleConfirm = () => { | ||
| setMessage('확인 이벤트가 실행되었습니다.'); | ||
| setIsOpen(false); | ||
| }; | ||
|
|
||
| const handleCancel = () => { | ||
| setMessage('취소 이벤트가 실행되었습니다.'); | ||
| }; | ||
|
|
||
| return ( | ||
| <div className="flex min-h-80 flex-col items-center justify-center gap-4"> | ||
| <Button onClick={() => setIsOpen(true)}>ConfirmModal 열기</Button> | ||
| <p className="m-0 body-14 text-gray-100">{message}</p> | ||
| <ConfirmModal | ||
| cancelLabel="아니오" | ||
| confirmLabel="저장하기" | ||
| description="버전 V.0.1로 저장됩니다." | ||
| onCancel={handleCancel} | ||
| onConfirm={handleConfirm} | ||
| onOpenChange={setIsOpen} | ||
| open={isOpen} | ||
| title="해당 자기소개서를 저장하시겠습니까?" | ||
| /> | ||
| </div> | ||
| ); | ||
| } | ||
|
|
||
| function LoadingConfirmModalExample() { | ||
| const [isOpen, setIsOpen] = useState(false); | ||
| const [isLoading, setIsLoading] = useState(false); | ||
| const timerRef = useRef<ReturnType<typeof setTimeout> | null>(null); | ||
|
|
||
| useEffect(() => { | ||
| return () => { | ||
| if (timerRef.current) { | ||
| clearTimeout(timerRef.current); | ||
| } | ||
| }; | ||
| }, []); | ||
|
|
||
| const handleConfirm = () => { | ||
| setIsLoading(true); | ||
|
|
||
| timerRef.current = setTimeout(() => { | ||
| setIsLoading(false); | ||
| setIsOpen(false); | ||
| timerRef.current = null; | ||
| }, 1200); | ||
| }; | ||
|
|
||
| return ( | ||
| <div className="flex min-h-80 items-center justify-center"> | ||
| <Button onClick={() => setIsOpen(true)}>Loading ConfirmModal 열기</Button> | ||
| <ConfirmModal | ||
| cancelLabel="아니오" | ||
| confirmLabel="저장하기" | ||
| description="저장 중에는 모달을 닫을 수 없습니다." | ||
| isLoading={isLoading} | ||
| onConfirm={handleConfirm} | ||
| onOpenChange={setIsOpen} | ||
| open={isOpen} | ||
| title="해당 자기소개서를 저장하시겠습니까?" | ||
| /> | ||
| </div> | ||
| ); | ||
| } | ||
|
|
||
| const meta = { | ||
| title: 'Shared/ConfirmModal', | ||
| component: ConfirmModal, | ||
| tags: ['autodocs'], | ||
| args: { | ||
| cancelLabel: '아니오', | ||
| confirmLabel: '저장하기', | ||
| defaultOpen: false, | ||
| description: '버전 V.0.1로 저장됩니다.', | ||
| isLoading: false, | ||
| onConfirm: () => undefined, | ||
| title: '해당 자기소개서를 저장하시겠습니까?', | ||
| }, | ||
| argTypes: { | ||
| cancelLabel: { | ||
| control: 'text', | ||
| }, | ||
| closeOnEscape: { | ||
| control: 'boolean', | ||
| }, | ||
| closeOnOutsideClick: { | ||
| control: 'boolean', | ||
| }, | ||
| confirmLabel: { | ||
| control: 'text', | ||
| }, | ||
| defaultOpen: { | ||
| control: 'boolean', | ||
| }, | ||
| description: { | ||
| control: 'text', | ||
| }, | ||
| focusTrap: { | ||
| control: 'boolean', | ||
| }, | ||
| isLoading: { | ||
| control: 'boolean', | ||
| }, | ||
| onCancel: { | ||
| action: 'cancel', | ||
| }, | ||
| onClosePrevented: { | ||
| action: 'closePrevented', | ||
| }, | ||
| onConfirm: { | ||
| action: 'confirm', | ||
| }, | ||
| onOpenChange: { | ||
| action: 'openChange', | ||
| }, | ||
| open: { | ||
| control: false, | ||
| }, | ||
| restoreFocus: { | ||
| control: 'boolean', | ||
| }, | ||
| scrollLock: { | ||
| control: 'boolean', | ||
| }, | ||
| title: { | ||
| control: 'text', | ||
| }, | ||
| }, | ||
| parameters: { | ||
| backgrounds: { | ||
| default: 'black', | ||
| }, | ||
| }, | ||
| } satisfies Meta<typeof ConfirmModal>; | ||
|
|
||
| export default meta; | ||
|
|
||
| type Story = StoryObj<typeof meta>; | ||
|
|
||
| export const Default: Story = { | ||
| render: (args) => <ButtonOpenConfirmModalExample {...args} />, | ||
| }; | ||
|
|
||
| export const Loading: Story = { | ||
| render: () => <LoadingConfirmModalExample />, | ||
| }; | ||
|
|
||
| export const Controlled: Story = { | ||
| render: () => <ControlledConfirmModalExample />, | ||
| }; | ||
|
|
||
| export const LongDescription: Story = { | ||
| args: { | ||
| description: | ||
| '현재 작성 중인 내용은 새 버전으로 저장되며, 저장이 완료된 뒤에는 버전 목록에서 다시 확인할 수 있습니다.', | ||
| title: '현재 내용을 새 버전으로 저장하시겠습니까?', | ||
| }, | ||
| render: (args) => <ButtonOpenConfirmModalExample {...args} />, | ||
| }; | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.