응원가 재생을 팀별 버튼 방식으로 전환

- 일정/메인 자동 로드 제거 — 상세 페이지 대결 카드의 팀 로고 아래
  "응원가 듣기" 버튼으로 각 팀 곡을 개별 재생 (재생 중 일시정지/이어듣기 토글)
- MusicBar 는 버튼이 실은 플레이리스트도 표시하도록 노출 조건 정리
- 두산 상설 응원가는 두산 버튼 트랙 뒤에 이어붙임

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
JinwooKimandClaude Fable 5 committed 2026-08-25 09:53:53 +09:00
1 parent 277378477a
commit 390e06113d
3 files changed
+88 -32

No files matched your search

+66 -3
View File
@@ -1,11 +1,64 @@
import { useEffect, useState } from "react";
import type { Match, TeamStanding } from "@/lib/types";
import { kickoffDisplay } from "@/lib/format";
import { type Lang, dict, teamShort, roundLabel as tRound } from "@/lib/i18n";
import { getTeamSongTracks, type Track } from "@/lib/playlist";
import { usePlayer } from "@/lib/usePlayer";
import BallIcon from "./BallIcon";
import { FormBadges } from "./ScheduleBoard";
import TeamFlag from "./TeamFlag";
import WaveStrip from "./WaveStrip";
// 팀별 '응원가 듣기' 버튼 — 오늘의 응원가(Suno 자동 생성)를 플레이어에 싣는다.
// 이 팀 곡이 재생 중이면 일시정지/이어듣기 토글. 곡이 없으면 렌더 안 함.
function CheerSongButton({
matchId,
teamCode,
lang,
}: {
matchId: string;
teamCode: string;
lang: Lang;
}) {
const { currentTrack, isPlaying, toggle, loadPlaylist, open } = usePlayer();
const [tracks, setTracks] = useState<Track[]>([]);
useEffect(() => {
let alive = true;
getTeamSongTracks(matchId, teamCode).then((ts) => alive && setTracks(ts));
return () => {
alive = false;
};
}, [matchId, teamCode]);
if (tracks.length === 0) return null;
const active = !!currentTrack && tracks.some((t) => t.src === currentTrack.src);
const label = active
? isPlaying
? lang === "en" ? "⏸ Pause" : "⏸ 일시정지"
: lang === "en" ? "▶ Resume" : "▶ 이어 듣기"
: lang === "en" ? "♪ Cheer song" : "♪ 응원가 듣기";
return (
<button
type="button"
onClick={() => {
if (active) toggle();
else {
loadPlaylist(tracks);
open();
}
}}
className={`rounded-full border px-3 py-1 text-[12px] font-bold transition active:scale-95 ${
active
? "border-[var(--green)] bg-[var(--green)]/15 text-[var(--green)]"
: "border-[var(--green)]/50 text-[var(--green)] hover:bg-[var(--green)]/10"
}`}
>
{label}
</button>
);
}
// 순위 캐시 → "3위 · 52승37패 (0.584)" 한 줄 (야구)
function standingLine(
st: { rank?: number | null; w?: number; l?: number; wra?: string | number } | null | undefined,
@@ -103,9 +156,14 @@ export default function MatchupHUD({ match, lang = "ko" }: { match: Match; lang?
</div>
</div>
{/* 국기/로고 + 라이트닝 VS (종료 시 최종 스코어) */}
{/* 국기/로고 + 라이트닝 VS (종료 시 최종 스코어) + 팀별 응원가 버튼(KBO) */}
<div className="mt-5 grid grid-cols-[1fr_auto_1fr] items-center gap-3">
<TeamFlag team={left} className={flagCls} />
<div className="flex flex-col items-center gap-2.5">
<TeamFlag team={left} className={flagCls} />
{match.league === "kbo" && (
<CheerSongButton matchId={match.matchId} teamCode={left.code} lang={lang} />
)}
</div>
<div className="relative grid place-items-center">
<div className="vs-glow absolute h-28 w-28" />
{finished && match.result ? (
@@ -123,7 +181,12 @@ export default function MatchupHUD({ match, lang = "ko" }: { match: Match; lang?
</span>
)}
</div>
<TeamFlag team={right} className={flagCls} />
<div className="flex flex-col items-center gap-2.5">
<TeamFlag team={right} className={flagCls} />
{match.league === "kbo" && (
<CheerSongButton matchId={match.matchId} teamCode={right.code} lang={lang} />
)}
</div>
</div>
{/* 야구 정보 패널: 선발 매치업 · 순위 · 시즌 상대전적 (캐시 있을 때만) */}