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

Issue169 마이페이지 북마크 된 음식점 지도 뷰 추가 #170

Merged
merged 25 commits into from
Jul 3, 2023
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
277aaca
chore: react kakao maps sdk 설치
ashleysyheo Jun 25, 2023
795248b
feat: < svg 아이콘 추가
ashleysyheo Jun 25, 2023
a261b1f
feat: BookmarkStore 타입 추가
ashleysyheo Jun 25, 2023
5ac3491
feat: 북마크 식당 목록 조회 api 추가
ashleysyheo Jun 25, 2023
c8903fa
feat: 북마크 식장 목록 조회 msw 추가 및 관련 목 데이터 추가
ashleysyheo Jun 25, 2023
5d4a6a8
feat: 지도 pin 아이콘들 추가
ashleysyheo Jun 26, 2023
0dcafeb
fix: Star 컴포넌트 사이즈 버그 수정
ashleysyheo Jun 26, 2023
5cf2a88
fix: msw bookmarkHandler 데이터가 안 넘어오는 문제 해결
ashleysyheo Jun 26, 2023
9024c1f
refactor: pin svg 아이콘 색상 변경
ashleysyheo Jun 26, 2023
7639e7f
chore: swiper 설치
ashleysyheo Jun 26, 2023
48886f9
feat: SlideCarousel 컴포넌트 생성
ashleysyheo Jun 26, 2023
23e7291
feat: useSlideCarousel 커스텀 훅 추가
ashleysyheo Jun 26, 2023
2980c9e
feat: EventMapMarker 컴포넌트 생성
ashleysyheo Jun 26, 2023
e6c211b
feat: useMap 커스텀 훅 추가
ashleysyheo Jun 26, 2023
275ea61
feat: 캠퍼스 별 좌표 추가
ashleysyheo Jun 26, 2023
1dd5be3
feat: BookmarkMapPage 생성
ashleysyheo Jun 26, 2023
c45f1c4
fix: key props 추가
ashleysyheo Jun 28, 2023
1cd6344
refactor: props 값이 true일 경우 축약 표현 사용
ashleysyheo Jun 28, 2023
4c39bd0
refactor: EventMapMarker props명 수정
ashleysyheo Jun 28, 2023
d992fdd
refactor: 지도에서 핀을 클릭했을 때 지도 중심이 핀으로 이동하는 기능 추가
ashleysyheo Jun 28, 2023
2ba24a8
refactor: pin 아이콘들 변경 및 클릭 되었을 때 사이즈 변하도록 변경
ashleysyheo Jun 29, 2023
1add44a
refactor: 지도 페이지 제목 '나의 맛집 지도'로 변경
ashleysyheo Jun 29, 2023
bcb1782
refactor: jsdoc 설명 추가
ashleysyheo Jul 1, 2023
9a04cb0
refactor: 폴더명 MypagePage에서 MyPage로 변경
ashleysyheo Jul 3, 2023
e8381fe
Merge branch 'develop' into issue169
ashleysyheo Jul 3, 2023
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
75 changes: 73 additions & 2 deletions package-lock.json

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

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@
"react": "^18.1.0",
"react-dom": "^18.1.0",
"react-icons": "^4.4.0",
"react-kakao-maps-sdk": "^1.1.9",
"react-query": "^3.39.1",
"react-router-dom": "^6.3.0",
"react-scripts": "^5.0.1",
"styled-components": "^5.3.5",
"swiper": "^9.4.1",
Copy link
Contributor

Choose a reason for hiding this comment

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

많은 슬라이더 라이브러리가 있는데 얘를 선택한 이유가 있을까요?

Copy link
Contributor

Choose a reason for hiding this comment

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

처음에는 직접 구현해 보려다가 시간 안에 못할 것 같아서 라이브러리를 찾아보게 되었습니다! 그래서 react-slick이랑 swiper를 살펴봤는데, 사용 방법은 둘 다 거의 비슷하더라고요. 그런데 swiper는 slide 할 때는 click 이벤트를 막아 주는 반면, react-slick은 바로 못 해주고 그걸 하기 위한 과정이 조금 복잡했어요. 그리고 이건 제대로 테스트 한건 아니지만, Xcode에서 아이폰이랑, 아이패드에서 터치해서 슬라이드 할 때 swiper를 사용할 때 제대로 원하는 인터렉션을 할 수 있었고요. 찾아보니까 swiper가 mobile first에 초점을 맞춰서 그렇다고 하더라고요!

아무래도 맛집 서비스 자체는 모바일 타겟인 것 같아서 swiper를 선택했습니다!

"typescript": "^4.7.2"
},
"scripts": {
Expand Down
4 changes: 4 additions & 0 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,9 @@
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<script
type="text/javascript"
src="//dapi.kakao.com/v2/maps/sdk.js?appkey=c0befa1276a7e48d077a90cdc41d039b&libraries=services,clusterer"
></script>
</body>
</html>
29 changes: 29 additions & 0 deletions src/api/bookmark/fetchBookmarkList.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import type { BookmarkStore } from "types/common/bookmarkTypes";

import { ACCESS_TOKEN, ENDPOINTS } from "constants/api";

import axiosInstance from "api/axiosInstance";

const fetchBookmarkList = async () => {
const accessToken = window.sessionStorage.getItem(ACCESS_TOKEN);

if (!accessToken) {
window.sessionStorage.removeItem(ACCESS_TOKEN);
window.alert("다시 로그인 해주세요");
window.location.href = "/";
return;
}

const { data } = await axiosInstance.get<BookmarkStore[]>(
ENDPOINTS.BOOKMARKS,
{
headers: {
Authorization: `Bearer ${accessToken}`,
},
}
);

return data;
};

export default fetchBookmarkList;
4 changes: 4 additions & 0 deletions src/asset/campus-pin-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions src/asset/clicked-pin-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions src/asset/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@ export { ReactComponent as CloseIcon } from "./close-icon.svg";
export { ReactComponent as LogoLight } from "./logo-light.svg";
export { ReactComponent as PlusIcon } from "./plus-icon.svg";
export { ReactComponent as SearchIcon } from "./search-icon.svg";
export { ReactComponent as LeftIcon } from "./left-icon.svg";
export { ReactComponent as PinIcon } from "./pin-icon.svg";
export { ReactComponent as ClickedPinIcon } from "./clicked-pin-icon.svg";
export { ReactComponent as CampusPinIcon } from "./campus-pin-icon.svg";
3 changes: 3 additions & 0 deletions src/asset/left-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions src/asset/pin-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 32 additions & 0 deletions src/components/common/EventMapMarker/EventMapMarker.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import ClickedPinIcon from "../../../asset/clicked-pin-icon.svg";
import PinIcon from "../../../asset/pin-icon.svg";
import { MapMarker } from "react-kakao-maps-sdk";

import { theme } from "style/Theme";

interface EventMapMarkerProps {
position: { lat: number; lng: number };
isClicked: boolean;
onClick: () => void;
Copy link
Contributor

Choose a reason for hiding this comment

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

props들의 네이밍을 더 구체화 하는 것이 좋을 것 같아요! 물론 지금도 maker누르면 발생하는 여부인가보다 대충 어림짐작할 수 있어도 정확한 의미 전달은 힘들어서 네이밍에 수정이 필요해보입니다

Copy link
Member

Choose a reason for hiding this comment

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

더불어서 맥락을 위해서 추가적인 설명이 필요한 prop이나 변수에는 주석을 달아주세요! 저희가 항상 만나서 이야기하고 회의할 수 있는게 아니다보니 코드 안에서의 컨텍스트도 중요합니다!

Copy link
Contributor

Choose a reason for hiding this comment

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

그 부분에 대해서는 생각을 못 했네요! 코멘트로 설명 추가하고 props 명도 각각, markerPosition, isMarkerClicked, onMarkerClick로 변경해 봤습니다!

}

function EventMapMarker({ position, isClicked, onClick }: EventMapMarkerProps) {
const icon = isClicked ? ClickedPinIcon : PinIcon;
Copy link
Contributor

Choose a reason for hiding this comment

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

아이콘을 아예 갈아치우는 방법도 있지만 컬러만 바꾸도록 할 수도 있지 않을까요?

Copy link
Contributor

Choose a reason for hiding this comment

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

아이콘을 아예 갈아치우지 않고, 컬러만 바꾼다는 게 정확히 뭘 말하는 건가요?? 조금 더 자세히 설명 부탁합니다!

Copy link
Contributor

Choose a reason for hiding this comment

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

아 그냥 만약 기존 방식대로 색만 바뀌는 거라면 props로 컬러 받고 svg 컴포넌트에 적용한다는 이야기였어요!


return (
<MapMarker
position={position}
onClick={onClick}
image={{
src: icon,
size: {
width: 36,
height: 36,
},
}}
zIndex={isClicked ? theme.zIndex.overlay : 1}
/>
);
}

export default EventMapMarker;
44 changes: 44 additions & 0 deletions src/components/common/SlideCarousel/SlideCarousel.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { MutableRefObject } from "react";
import { Pagination, Navigation } from "swiper";
import "swiper/css";
import "swiper/css";
import "swiper/css/navigation";
import "swiper/css/pagination";
import { Swiper, SwiperRef, SwiperSlide } from "swiper/react";

interface SlideCarouselProps {
children: JSX.Element[];
spaceBetween?: number;
onSlideChange: (index: number) => void;
swiperRef: MutableRefObject<SwiperRef | null>;
}

function SlideCarousel({
children,
spaceBetween = 8,
onSlideChange,
swiperRef,
}: SlideCarouselProps) {
const handleSlideChange = () => {
const activeSlideIndex = swiperRef.current?.swiper.realIndex ?? 0;
onSlideChange(activeSlideIndex);
};

return (
<Swiper
ref={swiperRef}
className="mySwiper"
slidesPerView={1}
spaceBetween={spaceBetween}
loop={true}
ashleysyheo marked this conversation as resolved.
Show resolved Hide resolved
modules={[Pagination, Navigation]}
onSlideChangeTransitionEnd={handleSlideChange}
>
{children.map((child) => (
<SwiperSlide>{child}</SwiperSlide>
))}
</Swiper>
);
}

export default SlideCarousel;
16 changes: 8 additions & 8 deletions src/components/common/Star/Star.style.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@ import styled, { css } from "styled-components";
const getSizeStyling = (size: Required<StarProps>["size"]) => {
const style = {
lg: css`
width: "32px";
height: "32px";
width: 32px;
height: 32px;
`,
md: css`
width: "24px";
height: "24px";
width: 24px;
height: 24px;
`,
sm: css`
width: "20px";
height: "20px";
width: 20px;
height: 20px;
`,
xs: css`
width: "16px";
height: "16px";
width: 16px;
height: 16px;
`,
};

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import styled, { css } from "styled-components";

export const HeaderWrapper = styled.header`
display: flex;
justify-content: space-between;
padding: ${({ theme }) => theme.spacer.spacing3};
margin-bottom: ${({ theme }) => theme.spacer.spacing4};
background-color: white;
`;

export const headerStyle = css`
position: absolute;
left: 50%;
font-weight: bold;
transform: translateX(-50%);
`;

export const MapWrapper = styled.div`
height: calc(100vh - 208px);

& #react-kakao-maps-sdk-map-container {
width: 100%;
height: 100%;
}
`;

export const StoreListWrapper = styled.div`
position: absolute;
bottom: ${({ theme }) => theme.spacer.spacing3};
width: calc(100% - 16px);
z-index: ${({ theme }) => theme.zIndex.overlay};

& li {
width: calc(100% - 16px);
margin: ${({ theme }) => theme.spacer.spacing3};
padding: ${({ theme }) => theme.spacer.spacing3};
border-radius: ${({ theme }) => theme.borderRadius.small};
box-shadow: 0px 0px 5px rgba(0, 0, 0, 0.15);
}
`;
Loading