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
1 change: 1 addition & 0 deletions apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"class-variance-authority": "^0.7.1",
"clsx": "^2.1.1",
"date-fns": "^4.1.0",
"framer-motion": "^12.33.0",
"gsap": "^3.14.2",
"immer": "^10.1.1",
"lottie-react": "^2.4.1",
Expand Down
60 changes: 46 additions & 14 deletions apps/web/src/Footer.tsx
Original file line number Diff line number Diff line change
@@ -1,38 +1,70 @@
'use client';

import { motion } from 'framer-motion';
import Link from 'next/link';
import { usePathname } from 'next/navigation';

import { Button } from '@/components/ui/button';
import useFooterAnimateStore, { FooterKey } from '@/stores/useFooterAnimateStore';
import { cn } from '@/utils/cn';

const navigation = [
{ name: '최신 곡', href: '/recent' },
interface Navigation {
name: string;
href: string;
key: FooterKey;
}

const navigation: Navigation[] = [
{ name: '최신 곡', href: '/recent', key: 'RECENT' },

{ name: '부를 곡', href: '/tosing' },
{ name: '검색', href: '/' },
{ name: '부를 곡', href: '/tosing', key: 'TOSING' },
{ name: '검색', href: '/', key: 'SEARCH' },

{ name: '인기곡', href: '/popular' },
{ name: '정보', href: '/info' },
{ name: '인기곡', href: '/popular', key: 'POPULAR' },
{ name: '정보', href: '/info', key: 'INFO' },
];

export default function Footer() {
const pathname = usePathname();
const { footerAnimateKey } = useFooterAnimateStore();
const navPath = pathname.split('/')[1];

return (
<footer className="bg-background fixed bottom-0 flex h-8 w-full max-w-md justify-between">
{navigation.map(item => {
const isActive = '/' + navPath === item.href;
const isAnimating = footerAnimateKey === item.key;

return (
<Button
asChild
key={item.name}
className={cn('flex-1 px-0 text-sm', isActive && 'bg-accent text-accent-foreground')}
variant="ghost"
>
<Link href={item.href}>{item.name}</Link>
</Button>
<div key={item.name} className="relative flex-1">
{isAnimating && (
<motion.div
className="bg-accent absolute top-0 left-1/2 z-0 h-4 w-4 -translate-x-1/2 rounded-full"
initial={{ y: -50, opacity: 0 }}
animate={{ y: 10, opacity: 1 }}
exit={{ opacity: 0 }}
transition={{ duration: 0.3, ease: 'easeOut' }}
/>
Comment on lines +40 to +47
Copy link

Copilot AI Feb 8, 2026

Choose a reason for hiding this comment

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

motion.divexit 애니메이션을 지정했지만, 현재처럼 {isAnimating && (...)}로 조건 렌더링만 하면 Framer Motion에서 exit가 실행되지 않습니다(AnimatePresence로 감싸지지 않음). 의도대로 사라질 때 페이드아웃이 필요하면 AnimatePresence를 추가해서 감싸고, 아니라면 exit 설정을 제거해 혼동을 줄여주세요.

Copilot uses AI. Check for mistakes.
)}
<Button
asChild
className={cn(
'h-full w-full px-0 text-sm',
isActive && 'bg-accent text-accent-foreground',
)}
variant="ghost"
>
<Link href={item.href}>
<motion.span
className="inline-block"
animate={isAnimating ? { scale: 1.4 } : { scale: 1 }}
transition={{ duration: 0.3, ease: 'easeInOut' }}
>
{item.name}
</motion.span>
</Link>
</Button>
</div>
);
})}
</footer>
Expand Down
5 changes: 5 additions & 0 deletions apps/web/src/components/ThumbUpModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { Slider } from '@/components/ui/slider';
import { useSongThumbMutation } from '@/queries/songThumbQuery';
import { useUserQuery } from '@/queries/userQuery';
import { usePatchSetPointMutation } from '@/queries/userQuery';
import useFooterAnimateStore from '@/stores/useFooterAnimateStore';

import FallingIcons from './FallingIcons';

Expand All @@ -29,10 +30,14 @@ export default function ThumbUpModal({ songId, handleClose }: ThumbUpModalProps)
const { mutate: patchSongThumb, isPending: isPendingSongThumb } = useSongThumbMutation();
const { mutate: patchSetPoint, isPending: isPendingSetPoint } = usePatchSetPointMutation();

const { setFooterAnimateKey } = useFooterAnimateStore();

const handleClickThumb = () => {
patchSongThumb({ songId, point: value[0] });
patchSetPoint({ point: point - value[0] });

setFooterAnimateKey('POPULAR');

handleClose();
};

Expand Down
14 changes: 14 additions & 0 deletions apps/web/src/hooks/useSearchSong.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
useToggleToSingMutation,
} from '@/queries/searchSongQuery';
import useAuthStore from '@/stores/useAuthStore';
import useFooterAnimateStore from '@/stores/useFooterAnimateStore';
import useGuestToSingStore from '@/stores/useGuestToSingStore';
import useSearchHistoryStore from '@/stores/useSearchHistoryStore';
import { Method } from '@/types/common';
Expand Down Expand Up @@ -46,6 +47,7 @@ export default function useSearchSong() {
isError,
} = useInfiniteSearchSongQuery(query, searchType, isAuthenticated);

const { setFooterAnimateKey } = useFooterAnimateStore();
const { addToHistory } = useSearchHistoryStore();
const { addGuestToSingSong, removeGuestToSingSong } = useGuestToSingStore();

Expand Down Expand Up @@ -75,6 +77,7 @@ export default function useSearchSong() {
if (!isAuthenticated) {
if (method === 'POST') {
addGuestToSingSong(song);
setFooterAnimateKey('TOSING');
} else {
removeGuestToSingSong(song.id);
}
Expand All @@ -85,6 +88,10 @@ export default function useSearchSong() {
toast.error('요청 중입니다. 잠시 후 다시 시도해주세요.');
return;
}

if (method === 'POST') {
setFooterAnimateKey('TOSING');
}
toggleToSing({ songId: song.id, method });
};

Expand All @@ -98,6 +105,10 @@ export default function useSearchSong() {
toast.error('요청 중입니다. 잠시 후 다시 시도해주세요.');
return;
}

if (method === 'POST') {
setFooterAnimateKey('INFO');
}
toggleLike({ songId, method });
};

Expand All @@ -116,6 +127,8 @@ export default function useSearchSong() {
toast.error('요청 중입니다. 잠시 후 다시 시도해주세요.');
return;
}

setFooterAnimateKey('INFO');
postSong({ songId, folderName, query, searchType });
};

Expand All @@ -125,6 +138,7 @@ export default function useSearchSong() {
return;
}

setFooterAnimateKey('INFO');
moveSong({ songIdArray: [songId], folderId });
};

Expand Down
36 changes: 36 additions & 0 deletions apps/web/src/stores/useFooterAnimateStore.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { create } from 'zustand';

export type FooterKey = 'SEARCH' | 'RECENT' | 'TOSING' | 'POPULAR' | 'INFO' | null;

interface FooterStore {
footerAnimateKey: FooterKey;
timeoutId: ReturnType<typeof setTimeout> | null;
setFooterAnimateKey: (key: FooterKey) => void;
}

const initialState = {
footerAnimateKey: null,
timeoutId: null,
};

const useFooterAnimateStore = create<FooterStore>((set, get) => ({
...initialState,

setFooterAnimateKey: key => {
const { timeoutId } = get();

if (timeoutId) {
clearTimeout(timeoutId);
}

set({ footerAnimateKey: key });

const newTimeoutId = setTimeout(() => {
set({ footerAnimateKey: null, timeoutId: null });
}, 300);
Comment on lines +9 to +30
Copy link

Copilot AI Feb 8, 2026

Choose a reason for hiding this comment

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

triggerFooterAnimation이 호출될 때마다 setTimeout을 새로 걸고 이전 타이머를 정리하지 않아, 연속 호출 시 이전 타이머가 나중에 실행되며 최신 애니메이션 상태를 null로 덮어써서 애니메이션이 중간에 끊길 수 있습니다. 마지막 타이머 id를 저장해 clearTimeout 후 다시 설정하거나, 스토어에 timeoutId를 두고 갱신하는 방식으로 레이스를 방지해주세요.

Suggested change
}
const initialState = {
activeFooterItem: null,
};
const useFooterAnimateStore = create<FooterStore>(set => ({
...initialState,
triggerFooterAnimation: key => {
set({ activeFooterItem: key });
setTimeout(() => {
set({ activeFooterItem: null });
}, 300);
timeoutId: number | null;
}
const initialState = {
activeFooterItem: null as FooterKey,
timeoutId: null as number | null,
};
const useFooterAnimateStore = create<FooterStore>(set => ({
...initialState,
triggerFooterAnimation: key => {
set(prevState => {
if (prevState.timeoutId !== null) {
clearTimeout(prevState.timeoutId);
}
const timeoutId = window.setTimeout(() => {
set(currentState => ({
...currentState,
activeFooterItem: null,
timeoutId: null,
}));
}, 300);
return {
...prevState,
activeFooterItem: key,
timeoutId,
};
});

Copilot uses AI. Check for mistakes.

set({ timeoutId: newTimeoutId });
},
}));

export default useFooterAnimateStore;
29 changes: 16 additions & 13 deletions pnpm-lock.yaml

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