-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor: 커피챗 오픈/수정 페이지 변경사항 적용 (#1702)
* feat: 경력 선택 항목 UI 변경 - chip -> dropwdown * feat: MO에서 사용 가능한 BottomSheetSelect 컴포넌트 추가 * feat: 경력 선택 항목 UI 변경 - chip -> PC: dropdown, MO: bottomsheet 으로 변경 * feat: 커피챗 진행 방식 UI 변경 - MO에서 dropdown -> bottomsheet 으로 변경 * fix: 자기소개 항목) 필수 -> 선택항목으로 변경 * refactor: MO: 관련 분야, 커피챗 주제 및 소개 섹션 chip md->sm으로 사이즈 변경 * chore: 커피챗 주제 및 소개 항목) placeholder 변경 * chore: 경력 선택 항목 dropdown 사이즈 변경
- Loading branch information
Showing
7 changed files
with
268 additions
and
50 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
149 changes: 149 additions & 0 deletions
149
src/components/coffeechat/upload/CoffeechatForm/BottomSheetSelect/index.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,149 @@ | ||
import styled from '@emotion/styled'; | ||
import { colors } from '@sopt-makers/colors'; | ||
import { fonts } from '@sopt-makers/fonts'; | ||
import { IconCheck, IconChevronDown } from '@sopt-makers/icons'; | ||
import { Button } from '@sopt-makers/ui'; | ||
import { useEffect, useState } from 'react'; | ||
|
||
import { zIndex } from '@/styles/zIndex'; | ||
|
||
interface Option { | ||
label: string; | ||
value: string; | ||
} | ||
|
||
interface BottomSheetSelectProps { | ||
options: Option[]; | ||
value: string | string[] | null | undefined; | ||
placeholder: string; | ||
onChange: (value: string) => void; | ||
} | ||
const BottomSheetSelect = ({ options, value, placeholder, onChange }: BottomSheetSelectProps) => { | ||
const [open, setOpen] = useState(false); | ||
const [selectedValue, setSelectedValue] = useState(value); | ||
const [temporaryValue, setTemporaryValue] = useState(value); | ||
|
||
const handleOpen = () => setOpen(true); | ||
const handleClose = () => setOpen(false); | ||
|
||
const handleOptionSelect = (value: string) => { | ||
setTemporaryValue(value); | ||
}; | ||
|
||
const handleConfirm = () => { | ||
setSelectedValue(temporaryValue); | ||
if (temporaryValue !== '') onChange(temporaryValue as string); | ||
|
||
handleClose(); | ||
}; | ||
|
||
useEffect(() => { | ||
if (open) { | ||
document.body.style.overflow = 'hidden'; | ||
} else { | ||
document.body.style.overflow = ''; | ||
} | ||
|
||
return () => { | ||
document.body.style.overflow = ''; | ||
}; | ||
}, [open]); | ||
|
||
return ( | ||
<Container> | ||
<InputField onClick={handleOpen}> | ||
{selectedValue !== null ? <p>{selectedValue}</p> : <p style={{ color: '#808087' }}>{placeholder}</p>} | ||
<IconChevronDown | ||
style={{ | ||
width: 20, | ||
height: 20, | ||
transform: open ? 'rotate(-180deg)' : '', | ||
transition: 'all 0.5s', | ||
}} | ||
/> | ||
</InputField> | ||
|
||
{open && ( | ||
<> | ||
<Overlay onClick={handleClose} /> | ||
<BottomSheet> | ||
<OptionList> | ||
{options.map((option) => ( | ||
<OptionItem key={option.value} onClick={() => handleOptionSelect(option.value)}> | ||
{option.label} | ||
{temporaryValue === option.value && <CheckedIcon />} | ||
</OptionItem> | ||
))} | ||
</OptionList> | ||
<Button size='lg' style={{ width: '100%' }} onClick={handleConfirm}> | ||
확인 | ||
</Button> | ||
</BottomSheet> | ||
</> | ||
)} | ||
</Container> | ||
); | ||
}; | ||
export default BottomSheetSelect; | ||
|
||
const Container = styled.div` | ||
position: relative; | ||
width: 100%; | ||
`; | ||
|
||
const InputField = styled.div` | ||
display: flex; | ||
align-items: center; | ||
justify-content: space-between; | ||
border-radius: 10px; | ||
background-color: ${colors.gray800}; | ||
cursor: pointer; | ||
padding: 11px 16px; | ||
${fonts.BODY_16_M}; | ||
`; | ||
|
||
const Overlay = styled.div` | ||
position: fixed; | ||
top: 0; | ||
left: 0; | ||
z-index: ${zIndex.헤더}; | ||
background-color: rgb(15 15 18 / 80%); | ||
width: 100%; | ||
height: 100%; | ||
`; | ||
|
||
const BottomSheet = styled.section` | ||
position: fixed; | ||
bottom: 0; | ||
z-index: ${zIndex.헤더}; | ||
margin-bottom: 12px; | ||
border-radius: 16px; | ||
background-color: ${colors.gray800}; | ||
padding: 16px; | ||
width: calc(100% - 40px); | ||
`; | ||
|
||
const OptionList = styled.ul` | ||
margin: 0 0 16px; | ||
padding: 0; | ||
max-height: 300px; | ||
overflow-y: auto; | ||
list-style: none; | ||
`; | ||
|
||
const OptionItem = styled.li` | ||
display: flex; | ||
align-items: center; | ||
justify-content: space-between; | ||
border-radius: 4px; | ||
cursor: pointer; | ||
padding: 10px; | ||
height: 44px; | ||
${fonts.BODY_14_M} | ||
`; | ||
|
||
const CheckedIcon = styled(IconCheck)` | ||
width: 24px; | ||
height: 24px; | ||
color: ${colors.success}; | ||
`; |
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
15 changes: 8 additions & 7 deletions
15
src/components/coffeechat/upload/CoffeechatForm/constants.ts
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