Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
23 changes: 23 additions & 0 deletions src/features/map/components/MapPinMessageBox.css
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,29 @@
align-items: center;
gap: 10px;
}
.gc-wave {
display: inline-flex;
width: 24px;
height: 24px;
flex-shrink: 0;
color: #9a9a9a; /* grayscale-400 */
}
.gc-wave--playing {
color: transparent;
background: linear-gradient(
180deg,
#c8f940 12.857%,
#fcff98 100%
); /* Neon/Linear — gc-play과 동일 */

-webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none'%3E%3Cpath d='M2.75 9.93782V14.0618M6.45 6.84482V17.1548M10.15 3.23682V20.7628M13.85 7.13182V16.8678M17.55 9.56582V14.4338M21.25 10.9688V13.0308' stroke='%23000' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E")
center / contain no-repeat;
Comment thread
kim3360 marked this conversation as resolved.
Resolved
mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none'%3E%3Cpath d='M2.75 9.93782V14.0618M6.45 6.84482V17.1548M10.15 3.23682V20.7628M13.85 7.13182V16.8678M17.55 9.56582V14.4338M21.25 10.9688V13.0308' stroke='%23000' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E")
center / contain no-repeat;
}
.gc-wave--playing svg {
opacity: 0;
}
.gc-play {
width: 30px;
height: 30px;
Expand Down
5 changes: 4 additions & 1 deletion src/features/map/components/MapPinMessageBox.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import UserPlaceholderIcon from '@/assets/icons/user-placeholder.svg?react';
import SoundWaveIcon from '@/assets/icons/soundwaves.svg?react';
import PlayIcon from '@/assets/icons/play.svg?react';
import { cn } from '@/lib/utils';
import './MapPinMessageBox.css';

export type MapPinMessageBoxProps = {
Expand Down Expand Up @@ -33,7 +34,9 @@ export function MapPinMessageBox({
</div>

<div className="gc-actions">
<SoundWaveIcon className="size-6 text-grayscale-400" aria-hidden />
<span className={cn('gc-wave', isPlaying && 'gc-wave--playing')} aria-hidden>
<SoundWaveIcon className="size-6" />
</span>
<button
type="button"
aria-label={isPlaying ? '미리듣기 일시정지' : '미리듣기 재생'}
Expand Down
4 changes: 3 additions & 1 deletion src/features/map/components/MapViewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export type MapViewerHandle = {
/** 지도를 현재 위치 마커로 이동시킨다. 위치를 아직 못 받았으면 아무 동작도 하지 않는다. */
recenterToCurrentLocation: () => void;
panTo: (coordinate: MapCoordinate, options?: { notifyCenterChanged?: boolean }) => void;
flyTo: (position: MapCoordinate, targetZoom: number, onArrive?: () => void) => void;
restoreViewport: (viewport: MapViewport) => void;
captureViewport: () => MapViewport | null;
};
Expand Down Expand Up @@ -107,10 +108,11 @@ export const MapViewer = forwardRef<MapViewerHandle, MapViewerProps>(function Ma
() => ({
recenterToCurrentLocation,
panTo,
flyTo,
restoreViewport,
captureViewport,
}),
[captureViewport, panTo, recenterToCurrentLocation, restoreViewport],
[captureViewport, flyTo, panTo, recenterToCurrentLocation, restoreViewport],
);

usePlaceMarkers({ mapInstanceRef, isLoaded, placeResults, selectedPlaceId, onSelectPlace });
Expand Down
2 changes: 1 addition & 1 deletion src/features/map/hooks/useMapPinOverlays.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
} from '../utils/mapPinMarker';

// 핀 클릭 시 포커스할 줌 레벨. 말풍선도 이 줌 범위에서만 노출한다.
const PIN_FOCUS_ZOOM = 21;
export const PIN_FOCUS_ZOOM = 21;
// flyTo 도중 소수점 줌과 정확히 21을 구분하기 위한 오차 허용치.
const ZOOM_EQUALITY_EPSILON = 0.01;

Expand Down
2 changes: 1 addition & 1 deletion src/features/pin/components/PinListSheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ function formatDistance(distance: number) {
}

function findFocusedPlaceTrackId(focusedFeedPin?: FocusedFeedPin) {
if (!focusedFeedPin) return null;
if (focusedFeedPin?.placeTrackId == null) return null;
return String(focusedFeedPin.placeTrackId);
}

Expand Down
35 changes: 21 additions & 14 deletions src/features/pin/hooks/useOpenPinPlaceOnMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,20 +131,27 @@ export function useOpenPinPlaceOnMap() {
place.placeAccessToken = access.placeAccessToken;
}

const resolvedPlaceTrackId =
showMyRegisteredTrackCta && placeTrackId != null ? Number(placeTrackId) : null;

if (resolvedPlaceTrackId != null) {
place.focusedFeedPin = {
pinId: resolvedPinId,
placeTrackId: resolvedPlaceTrackId,
nickname: pinDetail.writerNickname,
avatarUrl: pinDetail.writerProfileImage || undefined,
albumImageUrl: pinDetail.albumImageUrl,
introduction: pinDetail.introduction,
youtubeVideoId: pinDetail.youtubeVideoId,
clipStartMs: pinDetail.clipStartMs,
};
const resolvedPlaceTrackId = (() => {
if (placeTrackId == null) return undefined;
const parsed = Number(placeTrackId);
return Number.isInteger(parsed) && parsed > 0 ? parsed : undefined;
})();

// 피드 진입 시 지도 핀 말풍선(MapPinMessageBox)용 데이터
place.mapFocusPin = {
pinId: resolvedPinId,
placeTrackId: resolvedPlaceTrackId,
nickname: pinDetail.writerNickname,
avatarUrl: pinDetail.writerProfileImage || undefined,
albumImageUrl: pinDetail.albumImageUrl,
introduction: pinDetail.introduction,
youtubeVideoId: pinDetail.youtubeVideoId,
clipStartMs: pinDetail.clipStartMs,
};

// 내 등록 곡 상세 CTA는 placeTrackId가 있을 때만
if (showMyRegisteredTrackCta && resolvedPlaceTrackId != null) {
place.focusedFeedPin = place.mapFocusPin;
}

selectMapPlace(place);
Expand Down
2 changes: 1 addition & 1 deletion src/features/pin/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ export type PlaceResult = {

export type FocusedFeedPin = {
pinId: number;
placeTrackId: number;
placeTrackId?: number;
nickname: string;
avatarUrl?: string;
albumImageUrl: string;
Expand Down
25 changes: 17 additions & 8 deletions src/pages/MapPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { calculateDistanceMeters } from '@/features/map/utils/calculateDistanceM
import { MapViewer, type MapViewerHandle } from '@/features/map/components/MapViewer';
import { usePinMapView } from '@/features/map/queries/usePinMapView';
import { useAutoFocusNearestPin } from '@/features/map/hooks/useAutoFocusNearestPin';
import { PIN_FOCUS_ZOOM } from '@/features/map/hooks/useMapPinOverlays';
import { DEV_MOCK_MAP_PINS } from '@/features/map/constants/devMockMapPins';
import {
PinListSheet,
Expand Down Expand Up @@ -211,17 +212,18 @@ const MapPage: React.FC<MapPageProps> = ({
? (displayMapPins.find((pin) => pin.id === selectedMapPinId) ?? null)
: null;
// develop 방식: selectedMapPlace prop으로 장소 결과 관리
// 피드 진입(말풍선)일 때는 장소 검색 InfoWindow(흰 카드)를 띄우지 않는다.
const isFeedMapEntry = Boolean(selectedMapPlace?.mapFocusPin ?? selectedMapPlace?.focusedFeedPin);
const placeResults = useMemo<MapPlace[]>(
() => (selectedMapPlace ? [selectedMapPlace] : []),
[selectedMapPlace],
() => (selectedMapPlace && !isFeedMapEntry ? [selectedMapPlace] : []),
[isFeedMapEntry, selectedMapPlace],
);
const selectedPlaceId = selectedMapPlace?.id ?? null;
const selectedPlaceId = selectedMapPlace && !isFeedMapEntry ? selectedMapPlace.id : null;
Comment thread
kim3360 marked this conversation as resolved.
Resolved
const isPlaceSheetOpen = selectedMapPlace !== null && isUiActive;
const viewerSelectedMapPinId = focusedMapPinId ?? (selectedMapPlace ? null : displayedMapPinId);
// 검색 장소든 핀 클릭이든, 피드 진입(찜한 곡 등)이 아닐 때는 등록하기 버튼을 보여준다.
// 검색 장소든 핀 클릭이든, 피드 진입이 아닐 때만 등록하기 버튼을 보여준다.
const isRegisterButtonVisible =
isUiActive &&
((isPlaceSheetOpen && !selectedMapPlace?.focusedFeedPin) || selectedMapPin !== null);
isUiActive && ((isPlaceSheetOpen && !isFeedMapEntry) || selectedMapPin !== null);
// 아직 장소 정보가 안 왔거나(로딩 중), 500m 밖이거나, 본인 핀이면 등록할 수 없다.
const isRegisterButtonDisabled =
!resolvedActivePlace || resolvedActivePlace.isMine || !resolvedActivePlace.withinAccessRange;
Expand Down Expand Up @@ -326,12 +328,19 @@ const MapPage: React.FC<MapPageProps> = ({
}, [mapLoadStatus]);

// 선택된 장소가 있으면 해당 위도·경도로 지도를 이동한다.
// 현재 위치 최초 센터링보다 우선한다.
// 피드 말풍선(mapFocusPin/focusedFeedPin)이 있으면 줌 21까지 올려 말풍선이 보이게 한다.
useEffect(() => {
if (mapLoadStatus !== 'ready' || !selectedMapPlace) return;

const coordinate = selectedMapPlace.coordinates;
const shouldShowFeedBubble = Boolean(
selectedMapPlace.mapFocusPin ?? selectedMapPlace.focusedFeedPin,
);
const frameId = window.requestAnimationFrame(() => {
if (shouldShowFeedBubble) {
mapViewerRef.current?.flyTo(coordinate, PIN_FOCUS_ZOOM);
return;
}
mapViewerRef.current?.panTo(coordinate);
});

Expand Down Expand Up @@ -561,7 +570,7 @@ const MapPage: React.FC<MapPageProps> = ({
onResolvedPlaceChange={setResolvedActivePlace}
// 검색으로 들어온 장소만 "<"를 누르면 검색 화면으로 돌아간다(피드 진입은 기본 접기).
onFullPageBack={
selectedMapPlace.focusedFeedPin
isFeedMapEntry
? undefined
: () =>
navigate('/app/pin/search', {
Expand Down
Loading