Skip to content
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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
<script type="text/javascript" src="//dapi.kakao.com/v2/maps/sdk.js?appkey=%VITE_KAKAO_MAP_API_KEY%"></script>
</body>
</html>
39 changes: 39 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"@types/xml-js": "^1.0.0",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-kakao-maps-sdk": "^1.1.27",
"react-router-dom": "^6.26.2",
"styled-components": "^6.1.13",
"vite-tsconfig-paths": "^5.0.1",
Expand Down
53 changes: 53 additions & 0 deletions src/components/MapModal/index.tsx
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,
);
};
64 changes: 64 additions & 0 deletions src/components/MapModal/styles.ts
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};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 부분 컨벤션에 맞게 바꾸어주세요!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

코멘트 주신 부분 반영했습니다.

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};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 부분도요!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The 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;
`;
8 changes: 4 additions & 4 deletions tsconfig.json
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"]
}
}
2 changes: 1 addition & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default defineConfig({
'/api': {
target: 'http://www.kopis.or.kr/openApi/restful',
changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, ''),
rewrite: path => path.replace(/^\/api/, ''),
},
},
},
Expand Down