-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
식당 마커 클릭 시 식당정보 미리보기 구현
- Loading branch information
Showing
13 changed files
with
263 additions
and
89 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
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,53 @@ | ||
import { Socket } from 'socket.io-client'; | ||
|
||
import { ReactComponent as GpsIcon } from '@assets/images/gps.svg'; | ||
import { ReactComponent as PointCircleIcon } from '@assets/images/point-circle.svg'; | ||
|
||
import useCurrentLocation from '@hooks/useCurrentLocation'; | ||
|
||
import { useSocketStore } from '@store/socket'; | ||
import { useMeetLocationStore, useMapStore } from '@store/index'; | ||
|
||
import { MapControlBox } from './styles'; | ||
|
||
function MapController() { | ||
const { getCurrentLocation, updateUserLocation } = useCurrentLocation(); | ||
const { socket } = useSocketStore((state) => state); | ||
const { map } = useMapStore((state) => state); | ||
const { meetLocation } = useMeetLocationStore(); | ||
|
||
return ( | ||
<MapControlBox> | ||
<button | ||
type="button" | ||
onClick={async () => { | ||
if (!(socket instanceof Socket) || !map) { | ||
return; | ||
} | ||
|
||
const location = await getCurrentLocation(); | ||
socket.emit('changeMyLocation', { userLat: location.lat, userLng: location.lng }); | ||
updateUserLocation(location); | ||
|
||
map.setCenter(location); | ||
}} | ||
> | ||
<GpsIcon /> | ||
</button> | ||
<button | ||
type="button" | ||
onClick={() => { | ||
if (!map || !meetLocation) { | ||
return; | ||
} | ||
|
||
map.setCenter(meetLocation); | ||
}} | ||
> | ||
<PointCircleIcon /> | ||
</button> | ||
</MapControlBox> | ||
); | ||
} | ||
|
||
export default MapController; |
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,25 @@ | ||
import styled from 'styled-components'; | ||
import * as palette from '@styles/Variables'; | ||
|
||
export const MapControlBox = styled.div` | ||
position: absolute; | ||
left: 0; | ||
bottom: 0; | ||
margin: 0 0 18px 8px; | ||
z-index: ${palette.MAP_CONTROLLER_Z_INDEX}; | ||
gap: 10px; | ||
display: flex; | ||
flex-direction: column; | ||
button { | ||
width: 40px; | ||
height: 40px; | ||
background-color: white; | ||
border: none; | ||
border-radius: 5px; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
box-shadow: 0px 0px 4px rgb(0 0 0 / 50%); | ||
} | ||
`; |
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,62 @@ | ||
import { useEffect, useRef } from 'react'; | ||
import RestaurantRow from '@components/RestaurantRow'; | ||
import { AnimatePresence } from 'framer-motion'; | ||
import { useRestaurantDetailLayerStatusStore, useSelectedRestaurantDataStore } from '@store/index'; | ||
import { RESTAURANT_LIST_TYPES, RESTAURANT_DETAIL_TYPES } from '@constants/modal'; | ||
import { RestaurantPreviewBox, RestaurantPreviewLayout } from './styles'; | ||
|
||
function RestaurantPreview() { | ||
const modalRef = useRef<HTMLDivElement>(null); | ||
|
||
const { updateRestaurantDetailLayerStatus } = useRestaurantDetailLayerStatusStore( | ||
(state) => state | ||
); | ||
const { selectedRestaurantData, updateSelectedRestaurantData } = useSelectedRestaurantDataStore( | ||
(state) => state | ||
); | ||
|
||
useEffect(() => { | ||
const modalCloseWindowEvent = (e: Event) => { | ||
const { target } = e; | ||
|
||
if (modalRef.current && target instanceof HTMLElement && modalRef.current.contains(target)) { | ||
return; | ||
} | ||
|
||
updateSelectedRestaurantData(null); | ||
}; | ||
|
||
window.addEventListener('click', modalCloseWindowEvent); | ||
|
||
return () => { | ||
window.removeEventListener('click', modalCloseWindowEvent); | ||
}; | ||
}, []); | ||
|
||
return ( | ||
<RestaurantPreviewLayout ref={modalRef}> | ||
{selectedRestaurantData && ( | ||
<AnimatePresence> | ||
<RestaurantPreviewBox | ||
initial={{ opacity: 0, y: '100%' }} | ||
animate={{ opacity: 1, y: '0%' }} | ||
exit={{ opacity: 0, y: '100%' }} | ||
transition={{ | ||
duration: 0.5, | ||
}} | ||
onClick={() => { | ||
updateRestaurantDetailLayerStatus(RESTAURANT_DETAIL_TYPES.show); | ||
}} | ||
> | ||
<RestaurantRow | ||
restaurant={selectedRestaurantData} | ||
restaurantListType={RESTAURANT_LIST_TYPES.filtered} | ||
/> | ||
</RestaurantPreviewBox> | ||
</AnimatePresence> | ||
)} | ||
</RestaurantPreviewLayout> | ||
); | ||
} | ||
|
||
export default RestaurantPreview; |
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,14 @@ | ||
import styled from 'styled-components'; | ||
import * as palette from '@styles/Variables'; | ||
import { motion } from 'framer-motion'; | ||
|
||
export const RestaurantPreviewLayout = styled.div` | ||
z-index: ${palette.MAP_CONTROLLER_Z_INDEX}; | ||
`; | ||
|
||
export const RestaurantPreviewBox = styled(motion.div)` | ||
width: 100%; | ||
border-top-right-radius: 5px; | ||
border-top-left-radius: 5px; | ||
padding: 1% 3% 2% 3%; | ||
`; |
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
Oops, something went wrong.