-
Notifications
You must be signed in to change notification settings - Fork 0
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
[Feature/BAR-36] 모달 컴포넌트 개발 #21
Merged
+247
−56
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
c52dd7c
refactor: 토스트 스타일 token을 사용하는 형태로 변경
miro-ring 5ebb849
feat: strict true 설정 및 이로 인해 발생하는 에러 수정
miro-ring fdb7950
feat: modalStore 수정
miro-ring cb5d559
feat: 모달 style 개발
miro-ring c7a4811
feat: 모달 개발 및 적용
miro-ring 0d2c1e6
feat: 글 삭제 모달 작성
miro-ring db7b4a9
feat: 모달 스토리북 작성
miro-ring 9c410d1
feat: store 형태 변경
miro-ring 7ecafe4
feat: ts 파일들에 대해서 no-undef 룰 제거
miro-ring cad1752
feat: 컨벤션 변경에 따른 파일명 변경
miro-ring 124363a
refactor: store 관련 파일들 리팩터링
miro-ring eb6b42b
feat: 포탈 컴포넌트 작성
miro-ring ac50fb7
feat: 확장성 있는 형태로 ModalContainer 변경
miro-ring fefeccc
feat: 아티클 제거 컴포넌트 작성
miro-ring 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 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 |
---|---|---|
|
@@ -56,6 +56,12 @@ | |
} | ||
] | ||
} | ||
}, | ||
{ | ||
"files": ["*.ts", "*.tsx"], | ||
"rules": { | ||
"no-undef": "off" | ||
} | ||
} | ||
] | ||
} |
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 { Meta, StoryObj } from '@storybook/react'; | ||
|
||
import { useModalStore } from '@/src/stores/modalStore'; | ||
|
||
import Modal from '.'; | ||
|
||
const meta: Meta<typeof Modal> = { | ||
title: 'Components/Modal', | ||
component: Modal, | ||
decorators: [ | ||
(Story) => ( | ||
<div style={{ height: '500px' }}> | ||
<Story /> | ||
</div> | ||
), | ||
], | ||
}; | ||
|
||
export default meta; | ||
|
||
type Story = StoryObj<typeof Modal>; | ||
|
||
export const DeleteArticle: Story = { | ||
render: function Render() { | ||
const { openModal } = useModalStore(); | ||
|
||
openModal('deleteArticle'); | ||
|
||
return <Modal />; | ||
}, | ||
}; |
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,15 @@ | ||
import type { PropsWithChildren } from 'react'; | ||
|
||
import Portal from '../Portal'; | ||
import * as styles from './style.css'; | ||
|
||
const ModalContainer = ({ children }: PropsWithChildren<unknown>) => { | ||
return ( | ||
<Portal id="modal-root"> | ||
<div className={styles.dimmed} /> | ||
<div className={styles.modalStyle}>{children}</div> | ||
</Portal> | ||
); | ||
}; | ||
|
||
export default ModalContainer; |
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,45 @@ | ||
import { assignInlineVars } from '@vanilla-extract/dynamic'; | ||
|
||
import { useModalStore } from '@/src/stores/modalStore'; | ||
import { COLORS } from '@/src/styles/tokens'; | ||
|
||
import ModalContainer from '../ModalContainer'; | ||
import * as styles from '../style.css'; | ||
|
||
const DeleteArticle = () => { | ||
const { closeModal } = useModalStore(); | ||
|
||
return ( | ||
<ModalContainer> | ||
<strong className={styles.title}>해당 글을 삭제할까요?</strong> | ||
<p className={styles.body}> | ||
{'삭제한 글은 복구할 수 없어요!\n삭제하시겠어요'} | ||
</p> | ||
<div> | ||
<button | ||
type="button" | ||
className={styles.button} | ||
style={assignInlineVars({ | ||
[styles.buttonColor]: COLORS['Grey/600'], | ||
[styles.buttonBackgroundColor]: COLORS['Grey/150'], | ||
})} | ||
onClick={closeModal} | ||
> | ||
취소 | ||
</button> | ||
<button | ||
type="button" | ||
className={styles.button} | ||
style={assignInlineVars({ | ||
[styles.buttonColor]: COLORS['Grey/White'], | ||
[styles.buttonBackgroundColor]: COLORS['Blue/Default'], | ||
})} | ||
> | ||
만들기 | ||
</button> | ||
</div> | ||
</ModalContainer> | ||
); | ||
}; | ||
|
||
export default DeleteArticle; |
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,13 @@ | ||
import { useModalStore } from '@/src/stores/modalStore'; | ||
|
||
import DeleteArticle from './components/DeleteArticle'; | ||
|
||
const Modal = () => { | ||
const { type } = useModalStore(); | ||
|
||
if (type === 'deleteArticle') return <DeleteArticle />; | ||
|
||
return null; | ||
}; | ||
|
||
export default Modal; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import { createVar, style } from '@vanilla-extract/css'; | ||
|
||
import { sprinkles } from '@/src/styles/sprinkles.css'; | ||
import { COLORS } from '@/src/styles/tokens'; | ||
import { middleLayer, positionCenter, topLayer } from '@/src/styles/utils.css'; | ||
|
||
export const modalStyle = style([ | ||
positionCenter, | ||
topLayer, | ||
{ | ||
padding: '32px', | ||
width: '400px', | ||
borderRadius: '16px', | ||
backgroundColor: COLORS['Grey/White'], | ||
}, | ||
]); | ||
|
||
export const dimmed = style([ | ||
middleLayer, | ||
{ | ||
backgroundColor: COLORS['Dim/50'], | ||
position: 'fixed', | ||
left: '0', | ||
top: '0', | ||
right: '0', | ||
bottom: '0', | ||
}, | ||
]); | ||
|
||
export const title = style([ | ||
sprinkles({ | ||
typography: '20/Title/Semibold', | ||
}), | ||
{ | ||
display: 'block', | ||
marginBottom: '18px', | ||
}, | ||
]); | ||
|
||
export const body = style([ | ||
sprinkles({ | ||
typography: '15/Body/Regular', | ||
}), | ||
{ | ||
display: 'block', | ||
}, | ||
]); | ||
|
||
export const buttonColor = createVar(); | ||
export const buttonBackgroundColor = createVar(); | ||
|
||
export const button = style([ | ||
sprinkles({ | ||
typography: '15/Title/Medium', | ||
}), | ||
{ | ||
width: '164px', | ||
color: buttonColor, | ||
backgroundColor: buttonBackgroundColor, | ||
padding: '16px 40px', | ||
borderRadius: '8px', | ||
marginTop: '24px', | ||
selectors: { | ||
'& + &': { | ||
marginLeft: '8px', | ||
}, | ||
}, | ||
}, | ||
]); |
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 { PropsWithChildren } from 'react'; | ||
import { useEffect } from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
|
||
interface PortalProps { | ||
id: 'modal-root'; | ||
tag?: keyof HTMLElementTagNameMap; | ||
} | ||
|
||
const Portal = ({ | ||
children, | ||
id, | ||
tag = 'div', | ||
}: PropsWithChildren<PortalProps>) => { | ||
const root = document.createElement(tag); | ||
root.id = id; | ||
|
||
useEffect(() => { | ||
if (root) { | ||
document.body.appendChild(root); | ||
} | ||
|
||
return () => { | ||
document.body.removeChild(root); | ||
}; | ||
}, [root]); | ||
|
||
return ReactDOM.createPortal(children, root); | ||
}; | ||
|
||
export default Portal; |
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
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,23 @@ | ||
import { createStore } from 'zustand'; | ||
import { shallow } from 'zustand/shallow'; | ||
import { useStoreWithEqualityFn as useStore } from 'zustand/traditional'; | ||
|
||
type ModalType = 'deleteArticle'; | ||
|
||
interface State { | ||
type: ModalType | null; | ||
} | ||
|
||
interface Action { | ||
openModal: (type: ModalType) => void; | ||
closeModal: () => void; | ||
} | ||
|
||
export const modalStore = createStore<State & Action>((set) => ({ | ||
type: null, | ||
openModal: (type) => set({ type }), | ||
closeModal: () => set({ type: null }), | ||
})); | ||
|
||
export const useModalStore = () => | ||
useStore(modalStore, (state) => state, shallow); |
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 |
---|---|---|
@@ -1,10 +1,10 @@ | ||
{ | ||
"compilerOptions": { | ||
"strict": true, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍🏻👍🏻👍🏻 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 😭 |
||
"target": "es5", | ||
"lib": ["dom", "dom.iterable", "esnext"], | ||
"allowJs": true, | ||
"skipLibCheck": true, | ||
"strict": false, | ||
"noEmit": true, | ||
"esModuleInterop": true, | ||
"module": "esnext", | ||
|
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Modal.tsx
가 하나의 파일에서 너무 많은 일을 하고 있는것 같습니다 !There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
디자인적 요소 (버튼 등)를 포함하지 않은 모달이 존재하면 더 좋을것 같아요