-
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
feat: ✨ LevelModal 컴포넌트 이관 #98
Merged
Merged
Changes from 2 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
1a186b8
feat: :sparkles: LevelModal 컴포넌트 이관
7cd59f6
chore: 주석 제거
556e269
refactor: :recycle: data prop 의미 있는 이름으로 수정, levels 데이터는 필수인것으로 간주
611df31
Merge remote-tracking branch 'origin' into feature/level-modal
0be80b7
fix: :bug: fix type error
53088cd
feat: :sparkles: Modal 컴포넌트 추가 및 LevelModal 수정
a292574
refactor: :recycle: props 네이밍 수정, 불필요한 prop 제거
31ce12c
fix: :bug: fix storybook type error
2c5a2c1
chore: :beers: noMoreSee prop 관련 주석 추가
4a79cff
refactor: :recycle: level 데이터는 level modal에서 알 수 있도록 구조 수정
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 |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { ILevel } from '@/types'; | ||
import { ComponentStory, ComponentMeta } from '@storybook/react'; | ||
import { useState } from 'react'; | ||
|
||
import LevelModal from './LevelModal'; | ||
|
||
const LEVEL_DATA: ILevel[] = [ | ||
{ | ||
id: 1, | ||
tier: 1, | ||
imageUrl: 'https://cdn.pixabay.com/photo/2016/04/24/14/19/paper-1349664_1280.png', | ||
req: 0, | ||
}, | ||
{ | ||
id: 2, | ||
tier: 2, | ||
imageUrl: 'https://cdn.pixabay.com/photo/2016/04/24/14/19/paper-1349664_1280.png', | ||
req: 1, | ||
}, | ||
{ | ||
id: 3, | ||
tier: 3, | ||
imageUrl: 'https://cdn.pixabay.com/photo/2016/04/24/14/19/paper-1349664_1280.png', | ||
req: 5, | ||
}, | ||
{ | ||
id: 4, | ||
tier: 4, | ||
imageUrl: 'https://cdn.pixabay.com/photo/2016/04/24/14/19/paper-1349664_1280.png', | ||
req: 12, | ||
}, | ||
{ | ||
id: 5, | ||
tier: 5, | ||
imageUrl: 'https://cdn.pixabay.com/photo/2016/04/24/14/19/paper-1349664_1280.png', | ||
req: 20, | ||
}, | ||
]; | ||
|
||
export default { | ||
title: 'Components/mypage/LevelModal', | ||
component: LevelModal, | ||
} as ComponentMeta<typeof LevelModal>; | ||
|
||
const Template: ComponentStory<typeof LevelModal> = () => { | ||
const [isOpen, setIsOpen] = useState(true); | ||
|
||
return ( | ||
<LevelModal | ||
isLevelModalOpen={isOpen} | ||
openLevelModal={() => setIsOpen(true)} | ||
closeLevelModal={() => setIsOpen(false)} | ||
levelData={LEVEL_DATA} | ||
/> | ||
); | ||
}; | ||
|
||
export const Default = Template.bind({}); |
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,98 @@ | ||
import styled from '@emotion/styled'; | ||
|
||
import ModalLayout from '@/components/layouts/ModalLayout'; | ||
import Icon from '@/components/commons/Icon'; | ||
import { ILevel } from '@/types'; | ||
|
||
const LEVEL_MODAL_TITLE = 'Level 안내'; | ||
|
||
interface Props { | ||
isLevelModalOpen: boolean; | ||
openLevelModal: () => void; | ||
closeLevelModal: () => void; | ||
levelData: ILevel[]; | ||
} | ||
|
||
const LevelModal = ({ isLevelModalOpen, closeLevelModal, levelData }: Props) => { | ||
if (!levelData) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<ModalLayout open={isLevelModalOpen} onDimClick={closeLevelModal}> | ||
<StyleLevelModal open={isLevelModalOpen}> | ||
syoung125 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<Header> | ||
<CloseIcon name="Close" size={24} onClick={closeLevelModal} /> | ||
<Title>{LEVEL_MODAL_TITLE}</Title> | ||
</Header> | ||
<LevelList> | ||
{levelData.map(({ id, imageUrl, req, tier }) => ( | ||
<LevelListItem key={id}> | ||
<img src={imageUrl} alt={tier.toString()} width="64px" height="auto" /> | ||
<p> | ||
Level {tier} : 기록한 티켓 {req}개 이상 | ||
</p> | ||
</LevelListItem> | ||
))} | ||
</LevelList> | ||
</StyleLevelModal> | ||
</ModalLayout> | ||
); | ||
}; | ||
|
||
export default LevelModal; | ||
|
||
const StyleLevelModal = styled.div<{ open: boolean }>` | ||
position: absolute; | ||
top: 50%; | ||
left: 50%; | ||
transform: translate(-50%, -50%); | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
width: 300px; | ||
padding: 16px; | ||
border-radius: 12px; | ||
background-color: ${(p) => p.theme.color.white}; | ||
|
||
${(p) => !p.open && `display:none;`} | ||
`; | ||
|
||
const Header = styled.div` | ||
position: relative; | ||
width: 100%; | ||
margin-bottom: 25px; | ||
`; | ||
|
||
const Title = styled.h1` | ||
position: absolute; | ||
top: 50%; | ||
left: 50%; | ||
transform: translate(-50%, -50%); | ||
font-weight: 700; | ||
font-size: 16px; | ||
line-height: 19px; | ||
color: #323232; | ||
`; | ||
syoung125 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
const CloseIcon = styled(Icon)` | ||
cursor: pointer; | ||
`; | ||
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. 전체적으로 Icon에 |
||
|
||
const LevelList = styled.div` | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
align-items: center; | ||
width: 100%; | ||
gap: 40px; | ||
margin-bottom: 8px; | ||
`; | ||
|
||
const LevelListItem = styled.div` | ||
display: flex; | ||
align-items: center; | ||
gap: 13px; | ||
${({ theme }) => theme.fonts.Body4}; | ||
color: ${({ theme }) => theme.color.grey4}; | ||
`; |
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 @@ | ||
export { default } from './LevelModal'; |
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 ILevel { | ||
id: number; | ||
tier: number; | ||
imageUrl: string; | ||
req: number; | ||
} |
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.
levelData는 필수값인데 해당 로직은 필요없을 것 같습니다.
levelData이 실제로 optional 한 데이터라면 타입을 optional로 변경하거나, 외부에서 levelData라는 타입을 정확히 명시해
해당 데이터가 있어야 LevelModal 컴포넌트를 렌더링해주는게 좀 더 type safe한것 같습니다.
그리고 levelData라는 변수명도 다른 pr comment와 마찬가지로 array인지 알 수 있는 변수명이면 좋을것 같고 data라는 postfix없이도 의미는 명확하게 지을 수 있을 것 같아요