-
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 : MapModal 컴포넌트 기능 구현 #112
base: main
Are you sure you want to change the base?
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { useEffect, useMemo } from 'react'; | ||
import * as S from './styles'; | ||
import ReactDOM from 'react-dom'; | ||
import { H16, P16 } from '@/components/Text'; | ||
import { Map, MapMarker } from 'react-kakao-maps-sdk'; | ||
|
||
interface MapModalProps { | ||
place: string; | ||
phone: string; | ||
address: string; | ||
url: string; | ||
visible: boolean; | ||
width?: number; | ||
height?: number; | ||
latitude: number; | ||
longitude: number; | ||
onClose: () => void; | ||
} | ||
|
||
export const MapModal = ({ place, phone, address, url, visible, latitude, longitude, onClose }: MapModalProps) => { | ||
const el = useMemo(() => document.createElement('div'), []); | ||
|
||
useEffect(() => { | ||
document.body.appendChild(el); | ||
return () => { | ||
document.body.removeChild(el); | ||
}; | ||
}, [el]); | ||
|
||
if (!visible) return null; | ||
|
||
return ReactDOM.createPortal( | ||
<S.MapModal> | ||
<S.ModalContainer> | ||
<S.ModalHeader> | ||
<H16>공연장 정보</H16> | ||
<S.ModalCloseBtn onClick={onClose}>X</S.ModalCloseBtn> | ||
</S.ModalHeader> | ||
|
||
<S.ModalPlaceInfo> | ||
<H16>{place}</H16> | ||
<P16>전화번호 : {phone}</P16> | ||
<P16>주소 : {address}</P16> | ||
<P16>홈페이지 : {url}</P16> | ||
<Map center={{ lat: latitude, lng: longitude }} style={{ width: '100%', height: '100%' }}> | ||
<MapMarker position={{ lat: latitude, lng: longitude }}></MapMarker> | ||
</Map> | ||
</S.ModalPlaceInfo> | ||
</S.ModalContainer> | ||
</S.MapModal>, | ||
el, | ||
); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import { styled } from 'styled-components'; | ||
import theme from '@/styles/theme'; | ||
|
||
export const MapModal = styled.div` | ||
position: fixed; | ||
top: 0; | ||
left: 0; | ||
width: 100vw; | ||
height: 100vh; | ||
background-color: rgba(255, 255, 255, 0.9); | ||
z-index: 1000; | ||
`; | ||
|
||
export const ModalContainer = styled.div` | ||
width: 40%; | ||
height: 50%; | ||
position: fixed; | ||
top: 50%; | ||
left: 50%; | ||
transform: translate(-50%, -50%); | ||
padding: 30px; | ||
background-color: ${props => props.theme.colors.white}; | ||
box-shadow: 0 3px 6px rgba(0, 0, 0, 0.5); | ||
border-radius: 10px; | ||
display: flex; | ||
flex-direction: column; | ||
min-width: 500px; | ||
min-height: 500px; | ||
`; | ||
|
||
export const ModalHeader = styled.div` | ||
display: flex; | ||
justify-content: space-between; | ||
align-items: center; | ||
position: relative; | ||
|
||
&::after { | ||
content: ''; | ||
border: 1px solid ${props => props.theme.colors.gray}; | ||
position: absolute; | ||
bottom: -10px; | ||
left: 0; | ||
width: 100%; | ||
height: 1px; | ||
} | ||
`; | ||
|
||
export const ModalCloseBtn = styled.button` | ||
border: none; | ||
background-color: transparent; | ||
font-size: 20px; | ||
&:hover { | ||
color: ${props => props.theme.colors.gray}; | ||
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. 이부분도 반영했습니다! |
||
} | ||
`; | ||
|
||
export const ModalPlaceInfo = styled.div` | ||
display: flex; | ||
flex-direction: column; | ||
padding: 20px 0; | ||
gap: 10px; | ||
flex-grow: 1; | ||
overflow-y: auto; | ||
`; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
{ | ||
"files": [], | ||
"references": [ | ||
{ "path": "./tsconfig.app.json" }, | ||
{ "path": "./tsconfig.node.json" } | ||
] | ||
"references": [{ "path": "./tsconfig.app.json" }, { "path": "./tsconfig.node.json" }], | ||
"compilerOptions": { | ||
"types": ["kakao.maps.d.ts"] | ||
} | ||
} |
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.
이 부분 컨벤션에 맞게 바꾸어주세요!
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.
코멘트 주신 부분 반영했습니다.