Skip to content

Commit fa8eef2

Browse files
authored
Merge pull request #130 from dnd-side-project/fix/#129/1sp-qa-mobile
2 parents 4b015ca + d0f99b6 commit fa8eef2

File tree

21 files changed

+297
-139
lines changed

21 files changed

+297
-139
lines changed

src/App.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,21 @@ import { useAuthStore } from '@/features/auth/store/authStore'
2424
import { GlobalErrorModal } from '@/shared/ui'
2525
import NavBar, { NAV_HEIGHT } from '@/widgets/layout/NavBar'
2626

27-
const LAYOUT_BOTTOM_GAP = 34
28-
2927
const App = () => {
3028
const deviceType = useDevice()
3129
const location = useLocation()
30+
const isMobile = deviceType === 'mobile'
3231

3332
const { isLogin } = useAuthStore()
3433
const { mutate } = useAnonymousLogin()
3534

3635
const [isNavVisible, setIsNavVisible] = useState(true)
3736

38-
const LAYOUT_WIDTH = deviceType === 'mobile' ? 'clamp(320px, 100dvw, 430px)' : '430px'
37+
const LAYOUT_WIDTH = isMobile ? 'clamp(320px, 100dvw, 430px)' : '430px'
38+
39+
const isMobileView =
40+
isMobile && (location.pathname.startsWith('/mycd') || location.pathname.startsWith('/discover'))
41+
const LAYOUT_BOTTOM_GAP = isMobileView ? 16 : 34
3942

4043
// 비회원일 경우 API 호출을 위한 익명 토큰 발급
4144
// TODO: 토큰 만료됐을 경우 응답 체크해서 해당 값일 경우 토큰 재발급

src/entities/playlist/types/playlist.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,7 @@ export interface PlaylistInfo extends PlaylistDetail {
6666
totalTime?: string
6767
creator: Creator
6868

69-
// TODO : 타입 맞춰달라고 수정 요청 해야 함
70-
onlyCdResponse?: {
69+
cdResponse?: {
7170
cdItems: CdCustomData[]
7271
}
7372
cdItems?: CdCustomData[]

src/features/chat/model/sendMessage.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export interface ChatMessage {
88
messageId: string
99
username: string | null
1010
content: string
11-
sentAt?: string
11+
sentAt: string
1212
profileImage: string | null
1313
systemMessage?: boolean
1414
roomId: string

src/features/share/ui/ShareButton.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const ShareButton = ({ playlistId, stickers, type = 'DISCOVER' }: ShareButtonPro
2727
const shareRefs = useRef<(HTMLDivElement | null)[]>([])
2828

2929
const slides = [
30-
{ id: 'cd', content: <Cd variant="share" bgColor="none" stickers={stickers} /> },
30+
{ id: 'cd', content: <Cd variant="customize" bgColor="none" stickers={stickers} /> },
3131
{
3232
id: 'member',
3333
content: <img src={MemberCharacter} alt="Member Character" width={220} height={220} />,
@@ -59,7 +59,6 @@ const ShareButton = ({ playlistId, stickers, type = 'DISCOVER' }: ShareButtonPro
5959
<>
6060
<ButtonWrapper $isMy={type === 'MY'} onClick={handleShare}>
6161
<SvgButton icon={Share} width={type === 'MY' ? 16 : 24} height={type === 'MY' ? 16 : 24} />
62-
{type === 'MY' && <p>공유</p>}
6362
</ButtonWrapper>
6463

6564
<BottomSheet

src/features/swipe/ui/SwipeCarousel.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ const SwipeCarousel = ({
6666
</div>
6767
) : (
6868
<EmblaViewport ref={emblaRef}>
69-
<VerticaContainer>{children}</VerticaContainer>
69+
<VerticalContainer>{children}</VerticalContainer>
7070
</EmblaViewport>
7171
)}
7272
</>
@@ -80,7 +80,7 @@ const EmblaViewport = styled.div`
8080
overflow: hidden;
8181
`
8282

83-
const VerticaContainer = styled.div`
83+
const VerticalContainer = styled.div`
8484
display: flex;
8585
flex-direction: column;
8686
height: 100%;

src/pages/discover/index.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ const DiscoverPage = () => {
164164
currentPlaylist={currentPlaylist}
165165
currentTrackIndex={currentTrackIndex}
166166
currentTime={currentTime}
167-
isPlaying={isPlaying}
167+
isPlaying={isPlaying && !showCoachmark}
168168
onPlayPause={() => (isPlaying ? pause() : play())}
169169
onNext={nextTrack}
170170
onPrev={prevTrack}
@@ -179,14 +179,16 @@ const DiscoverPage = () => {
179179
))}
180180
</SwipeCarousel>
181181

182-
{videoId && (
182+
{!showCoachmark && videoId && (
183183
<YoutubePlayer
184184
videoId={videoId}
185185
onReady={(event) => {
186186
playerRef.current = event.target
187187
playerRef.current?.seekTo(currentTime, true)
188-
if (isPlaying) playerRef.current?.playVideo()
189-
else playerRef.current?.pauseVideo()
188+
if (!isPlaying) {
189+
playerRef.current?.pauseVideo()
190+
}
191+
190192
setIsMuted(playerRef.current?.isMuted() ?? null)
191193
}}
192194
onStateChange={handlePlayerStateChange}
@@ -200,6 +202,7 @@ export default DiscoverPage
200202

201203
const Slide = styled.div`
202204
flex: 0 0 100%;
205+
position: relative;
203206
`
204207
const Page = styled.div`
205208
position: relative;

src/pages/home/index.tsx

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
useRecommendedGenres,
1010
} from '@/features/recommend'
1111
import { FirstSection } from '@/pages/home/ui'
12-
import { ScrollCarousel } from '@/shared/ui'
12+
import { CategoryButton, ScrollCarousel } from '@/shared/ui'
1313
import { Playlist, PlaylistWithSong } from '@/widgets/playlist'
1414

1515
const HomePage = () => {
@@ -67,13 +67,13 @@ const HomePage = () => {
6767
<h1>오늘은 이런 기분</h1>
6868
<ScrollCarousel gap={12}>
6969
{GenreData?.map((item) => (
70-
<Slide
70+
<CategoryButton
7171
key={item.code}
72-
$bgImage={CARD_IMAGES_LARGE[item.code as keyof typeof CARD_IMAGES_LARGE]}
72+
size="large"
73+
text={item.displayName}
74+
bgImage={CARD_IMAGES_LARGE[item.code as keyof typeof CARD_IMAGES_LARGE]}
7375
onClick={() => handleKeywordSearch(item.code)}
74-
>
75-
{item.displayName}
76-
</Slide>
76+
/>
7777
))}
7878
</ScrollCarousel>
7979
</FourthSection>
@@ -83,22 +83,6 @@ const HomePage = () => {
8383

8484
export default HomePage
8585

86-
const Slide = styled.button<{ $bgImage?: string }>`
87-
border-radius: 10px;
88-
width: 160px;
89-
height: 200px;
90-
color: ${({ theme }) => theme.COLOR['gray-100']};
91-
${({ theme }) => theme.FONT['body1-normal']};
92-
background-color: ${({ theme }) => theme.COLOR['gray-600']};
93-
background-image: url(${({ $bgImage }) => $bgImage});
94-
background-size: cover;
95-
background-position: center;
96-
padding: 12px;
97-
display: flex;
98-
flex-direction: column;
99-
align-items: flex-start;
100-
`
101-
10286
const PageLayout = styled.div`
10387
display: flex;
10488
flex-direction: column;

src/pages/mycd/index.tsx

Lines changed: 72 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ import { useLocation, useNavigate, useParams } from 'react-router-dom'
44
import styled from 'styled-components'
55

66
import { usePlaylist } from '@/app/providers/PlayerProvider'
7+
import { NoLike } from '@/assets/icons'
78
import { MemberCharacter } from '@/assets/images'
9+
import { usePlaylistDetail } from '@/entities/playlist'
810
import { useMyCdActions, useMyCdList, useMyLikedCdList } from '@/entities/playlist/model/useMyCd'
911
import { useAuthStore } from '@/features/auth/store/authStore'
1012
import { useChatSocket } from '@/features/chat/model/sendMessage'
@@ -13,7 +15,7 @@ import type { MyCdTab } from '@/pages/mycd/ui/HeaderTab'
1315
import { getVideoId } from '@/shared/lib'
1416
import { useDevice } from '@/shared/lib/useDevice'
1517
import { flexColCenter, flexRowCenter } from '@/shared/styles/mixins'
16-
import { Button, LiveInfo } from '@/shared/ui'
18+
import { Button, LiveInfo, Loading } from '@/shared/ui'
1719
import { ActionBar, ControlBar, ProgressBar, VolumeButton, YoutubePlayer } from '@/widgets/playlist'
1820

1921
const MyCdPage = () => {
@@ -45,10 +47,11 @@ const MyCdPage = () => {
4547
const likedCdPlaylist = useMyLikedCdList('RECENT')
4648

4749
const playlistQuery = selectedTab === 'MY' ? myCdPlaylist : likedCdPlaylist
48-
4950
const playlistData = useMemo(() => playlistQuery.data ?? [], [playlistQuery.data])
50-
51+
const isLoading = playlistQuery.isLoading
5152
const isError = playlistQuery.isError
53+
const isMyEmpty = !myCdPlaylist.isLoading && (myCdPlaylist.data?.length ?? 0) === 0
54+
const isLikedEmpty = !likedCdPlaylist.isLoading && (likedCdPlaylist.data?.length ?? 0) === 0
5255

5356
const [centerItem, setCenterItem] = useState<{
5457
playlistId: number | null
@@ -112,9 +115,15 @@ const MyCdPage = () => {
112115
)
113116

114117
/* 플레이리스트 세팅 */
115-
const { tracklist: playlistDetail } = useMyCdActions(Number(centerItem.playlistId), {
116-
enabled: !!centerItem.playlistId,
118+
const myCdDetail = useMyCdActions(Number(centerItem.playlistId), {
119+
enabled: selectedTab === 'MY' && !!centerItem.playlistId,
120+
})
121+
122+
const likedCdDetail = usePlaylistDetail(centerItem.playlistId, {
123+
enabled: selectedTab === 'LIKE' && !!centerItem.playlistId,
117124
})
125+
126+
const playlistDetail = selectedTab === 'MY' ? myCdDetail.tracklist : likedCdDetail.data
118127
useEffect(() => {
119128
if (playlistDetail && userInfo) {
120129
if (currentPlaylist?.playlistId === playlistDetail.playlistId) return
@@ -162,21 +171,41 @@ const MyCdPage = () => {
162171
? getVideoId(currentPlaylist.songs[currentTrackIndex]?.youtubeUrl)
163172
: null
164173

174+
if (isLoading) {
175+
return <Loading isLoading />
176+
}
177+
165178
if (isError) {
166179
navigate('/error')
167180
return null
168181
}
169182

170-
const isEmpty = playlistData && playlistData.length === 0
183+
if (selectedTab === 'MY' && isMyEmpty) {
184+
return (
185+
<EmptyPage>
186+
<HeaderTab selectedTab={selectedTab} onSelect={handleTabSelect} />
187+
<CenterContent>
188+
<img src={MemberCharacter} alt="Guest Character" width={160} height={160} />
189+
<NavigateBtn onClick={() => navigate('/mypage/customize')}>
190+
새로운 CD에 취향 담기
191+
</NavigateBtn>
192+
</CenterContent>
193+
</EmptyPage>
194+
)
195+
}
171196

172-
if (isEmpty) {
197+
if (selectedTab === 'LIKE' && isLikedEmpty) {
173198
return (
174-
<ViewContainer>
175-
<img src={MemberCharacter} alt="Guest Character" width={160} height={160} />
176-
<NavigateBtn onClick={() => navigate('/mypage/customize')}>
177-
새로운 CD에 취향 담기
178-
</NavigateBtn>
179-
</ViewContainer>
199+
<EmptyPage>
200+
<HeaderTab selectedTab={selectedTab} onSelect={handleTabSelect} />
201+
<CenterContent>
202+
<NoLike width={160} height={160} />
203+
<SubText>
204+
아직 좋아요한 CD가 없어요. <br /> 새로운 음악을 찾아볼까요?
205+
</SubText>
206+
<NavigateBtn onClick={() => navigate('/discover')}>둘러보기로 가기</NavigateBtn>
207+
</CenterContent>
208+
</EmptyPage>
180209
)
181210
}
182211

@@ -204,18 +233,18 @@ const MyCdPage = () => {
204233
</Button>
205234
)}
206235
</Container>
207-
208236
<PlaylistCarousel data={playlistData ?? []} onCenterChange={handleCenterChange} />
209-
210237
<ActionBar
211238
playlistId={centerItem.playlistId ?? 0}
212239
creatorId={currentPlaylist.creator.creatorId}
213240
stickers={playlistDetail?.cdResponse?.cdItems || []}
214241
type="MY"
215242
selectedTab={selectedTab}
216243
/>
217-
218-
<Title>{centerItem.playlistName}</Title>
244+
<Title $isMobile={isMobile}> {centerItem.playlistName}</Title>
245+
{selectedTab === 'LIKE' && playlistDetail?.creatorNickname && (
246+
<Creator>{playlistDetail.creatorNickname}</Creator>
247+
)}
219248

220249
<BottomWrapper>
221250
<ProgressBar
@@ -259,24 +288,18 @@ const Container = styled.div`
259288
height: 30px;
260289
`
261290

262-
const Title = styled.p`
291+
const Title = styled.p<{ $isMobile?: boolean }>`
263292
${({ theme }) => theme.FONT.headline1};
264-
padding-top: 40px;
293+
padding-top: ${({ $isMobile }) => ($isMobile ? '24px' : '40px')};
265294
`
266295

267296
const BottomWrapper = styled.div`
268-
padding-top: 24px;
297+
padding-top: 20px;
269298
display: flex;
270299
flex-direction: column;
271300
gap: 20px;
272301
`
273302

274-
const ViewContainer = styled.div`
275-
${flexColCenter}
276-
height: 100%;
277-
gap: 16px;
278-
`
279-
280303
const NavigateBtn = styled.button`
281304
${flexRowCenter}
282305
background-color: ${({ theme }) => theme.COLOR['primary-normal']};
@@ -285,4 +308,27 @@ const NavigateBtn = styled.button`
285308
padding: 6px 20px;
286309
height: 32px;
287310
${({ theme }) => theme.FONT['body2-normal']};
311+
margin-top: 16px;
312+
`
313+
const Creator = styled.p`
314+
${({ theme }) => theme.FONT['body2-normal']};
315+
color: ${({ theme }) => theme.COLOR['gray-300']};
316+
`
317+
318+
const SubText = styled.p`
319+
${({ theme }) => theme.FONT['body1-normal']}
320+
color: ${({ theme }) => theme.COLOR['gray-50']};
321+
`
322+
323+
const EmptyPage = styled.div`
324+
display: flex;
325+
flex-direction: column;
326+
height: 100%;
327+
background-color: ${({ theme }) => theme.COLOR['gray-900']};
328+
`
329+
330+
const CenterContent = styled.div`
331+
flex: 1;
332+
${flexColCenter};
333+
text-align: center;
288334
`

0 commit comments

Comments
 (0)