From 1432fec809eb20ac33f07e0ca6237c91340a16db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9E=84=EA=B1=B4=EC=9A=B0?= Date: Tue, 19 Mar 2024 13:23:59 +0900 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20fix:=20=EC=95=84=ED=8B=B0?= =?UTF-8?q?=EC=8A=A4=ED=8A=B8=20=EC=A7=80=EB=8F=84=20=EB=B0=8F=20=ED=96=89?= =?UTF-8?q?=EC=82=AC=20=EB=A1=9C=EC=A7=81=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../[artistId]/_components/MobileTab.tsx | 4 +- .../artist/[artistId]/_components/PcTab.tsx | 70 ------------------- .../[artistId]/_hooks/useArtistSheet.tsx | 12 ++-- app/(route)/artist/[artistId]/page.tsx | 65 +++++++++++++---- app/_hooks/useCustomMap.tsx | 8 ++- 5 files changed, 66 insertions(+), 93 deletions(-) delete mode 100644 app/(route)/artist/[artistId]/_components/PcTab.tsx diff --git a/app/(route)/artist/[artistId]/_components/MobileTab.tsx b/app/(route)/artist/[artistId]/_components/MobileTab.tsx index 81ee8b15..28975a31 100644 --- a/app/(route)/artist/[artistId]/_components/MobileTab.tsx +++ b/app/(route)/artist/[artistId]/_components/MobileTab.tsx @@ -28,7 +28,7 @@ const MobileTab = ({ mapVar, mapCallback, image, name, status, setStatus, sort, return (
@@ -49,7 +49,7 @@ const MobileTab = ({ mapVar, mapCallback, image, name, status, setStatus, sort, 인기순
-
+
{isEmpty ? (

행사가 없습니다.

) : ( diff --git a/app/(route)/artist/[artistId]/_components/PcTab.tsx b/app/(route)/artist/[artistId]/_components/PcTab.tsx deleted file mode 100644 index 67425a53..00000000 --- a/app/(route)/artist/[artistId]/_components/PcTab.tsx +++ /dev/null @@ -1,70 +0,0 @@ -import SortButton from "@/(route)/search/_components/SortButton"; -import Image from "next/image"; -import { Dispatch, SetStateAction } from "react"; -import TimeFilter from "@/components/TimeFilter"; -import { MapCallbackType, MapVarType } from "@/hooks/useCustomMap"; -import { EventCardType } from "@/types/index"; -import SortIcon from "@/public/icon/sort.svg"; -import EventCard from "./EventCard"; - -interface Props { - mapVar: MapVarType; - mapCallback: MapCallbackType; - image: string; - name: string; - status: number; - setStatus: Dispatch>; - sort: "최신순" | "인기순"; - setSort: Dispatch>; - eventData: EventCardType[]; -} - -const PcTab = ({ mapVar, mapCallback, image, name, status, setStatus, sort, setSort, eventData }: Props) => { - const isEmpty = eventData.length === 0; - - return ( - <> - {mapVar.toggleTab && ( -
-
-
- 아티스트 이미지 -
-

- {name} 행사 보기 -

-
- -
- - setSort("최신순")} selected={sort === "최신순"}> - 최신순 - - setSort("인기순")} selected={sort === "인기순"}> - 인기순 - -
-
- {isEmpty ? ( -

행사가 없습니다.

- ) : ( -
- {eventData.map((event) => ( - mapCallback.handleCardClick(event)} - scrollRef={mapVar.selectedCard?.id === event.id ? mapCallback.scrollRefCallback : null} - /> - ))} -
- )} -
-
- )} - - ); -}; - -export default PcTab; diff --git a/app/(route)/artist/[artistId]/_hooks/useArtistSheet.tsx b/app/(route)/artist/[artistId]/_hooks/useArtistSheet.tsx index 67442906..13893a34 100644 --- a/app/(route)/artist/[artistId]/_hooks/useArtistSheet.tsx +++ b/app/(route)/artist/[artistId]/_hooks/useArtistSheet.tsx @@ -7,8 +7,8 @@ interface BottomSheetMetrics { } const SNAP = { - top: 280, - bottom: 670, + top: 260, + bottom: 650, }; const useArtistSheet = () => { @@ -39,14 +39,14 @@ const useArtistSheet = () => { const currentY = node.getBoundingClientRect().y; if (currentY > SNAP.bottom) { - node.style.setProperty("transform", `translateY(240px)`); - metrics.current.position = 240; + node.style.setProperty("transform", `translateY(220px)`); + metrics.current.position = 220; } else if (currentY < SNAP.bottom && currentY > SNAP.top) { node.style.setProperty("transform", "translateY(0px)"); metrics.current.position = 0; } else if (currentY < SNAP.top) { - node.style.setProperty("transform", `translateY(-360px)`); - metrics.current.position = -360; + node.style.setProperty("transform", `translateY(-320px)`); + metrics.current.position = -320; } metrics.current.isContentAreaTouched = false; diff --git a/app/(route)/artist/[artistId]/page.tsx b/app/(route)/artist/[artistId]/page.tsx index ffab9a46..c7865e7f 100644 --- a/app/(route)/artist/[artistId]/page.tsx +++ b/app/(route)/artist/[artistId]/page.tsx @@ -1,24 +1,28 @@ "use client"; +import SortButton from "@/(route)/search/_components/SortButton"; import { useQuery } from "@tanstack/react-query"; import Image from "next/image"; import { useParams } from "next/navigation"; import { useEffect, useState } from "react"; import KakaoMap from "@/components/KakaoMap"; import MetaTag from "@/components/MetaTag"; +import TimeFilter from "@/components/TimeFilter"; import DottedLayout from "@/components/layout/DottedLayout"; import { instance } from "@/api/api"; import useCustomMap from "@/hooks/useCustomMap"; import { getArtist, getGroup } from "@/utils/getArtist"; import { Res_Get_Type } from "@/types/getResType"; import { SORT, STATUS, SortItem } from "@/constants/eventStatus"; +import SortIcon from "@/public/icon/sort.svg"; +import EventCard from "./_components/EventCard"; import MobileTab from "./_components/MobileTab"; -import PcTab from "./_components/PcTab"; +import useArtistSheet from "./_hooks/useArtistSheet"; const SIZE = 9999; const ArtistIdPage = () => { - const { artistId } = useParams() as { artistId: string }; // artists -> 멤버, 솔로 // groupId -> 그룹명 + const { artistId } = useParams() as { artistId: string }; const group = getGroup(instance, artistId); const artist = getArtist(instance, artistId); @@ -49,10 +53,12 @@ const ArtistIdPage = () => { }, [sort, status]); const { mapVar, mapCallback } = useCustomMap(); + const { sheet, content } = useArtistSheet(); if (!isSuccess) return; const eventData = artistData.eventList; + const isEmpty = eventData.length === 0; return ( <> @@ -70,18 +76,49 @@ const ArtistIdPage = () => { > 화살표 - - + {mapVar.toggleTab && ( +
+
+
+
+ 아티스트 이미지 +
+

+ {name} 행사 보기 +

+
+ +
+ + setSort("최신순")} selected={sort === "최신순"}> + 최신순 + + setSort("인기순")} selected={sort === "인기순"}> + 인기순 + +
+
+ {isEmpty ? ( +

행사가 없습니다.

+ ) : ( +
+ {eventData.map((event) => ( + mapCallback.handleCardClick(event)} + scrollRef={mapVar.selectedCard?.id === event.id ? mapCallback.scrollRefCallback : null} + /> + ))} +
+ )} +
+
+ )}
diff --git a/app/_hooks/useCustomMap.tsx b/app/_hooks/useCustomMap.tsx index febe3445..16f88f54 100644 --- a/app/_hooks/useCustomMap.tsx +++ b/app/_hooks/useCustomMap.tsx @@ -1,5 +1,6 @@ import { Dispatch, SetStateAction, useEffect, useRef, useState } from "react"; import { EventCardType } from "@/types/index"; +import useGetWindowWidth from "./useGetWindowWidth"; const useCustomMap = () => { const [toggleTab, setToggleTab] = useState(true); @@ -23,8 +24,13 @@ const useCustomMap = () => { scrollRef.current = el; }; + const { isPc } = useGetWindowWidth(); useEffect(() => { - scrollRef.current?.scrollIntoView({ behavior: "smooth", block: "nearest" }); + if (isPc) { + scrollRef.current?.scrollIntoView({ behavior: "smooth", block: "nearest" }); + return; + } + scrollRef.current?.scrollIntoView({ behavior: "smooth", block: "start" }); }, [selectedCard?.id, toggleTab]); const mapVar = {