From 8a864c2cf72bc7bd480307453e0b44683f9f5843 Mon Sep 17 00:00:00 2001 From: sk1982 Date: Sat, 13 Apr 2024 04:53:51 -0400 Subject: [PATCH] chuni: show chart credits and note counts on music detail --- .../chuni/music/[musicId]/music-playlog.tsx | 107 +++++++++--------- 1 file changed, 56 insertions(+), 51 deletions(-) diff --git a/src/app/(with-header)/chuni/music/[musicId]/music-playlog.tsx b/src/app/(with-header)/chuni/music/[musicId]/music-playlog.tsx index aa98588..1cdae60 100644 --- a/src/app/(with-header)/chuni/music/[musicId]/music-playlog.tsx +++ b/src/app/(with-header)/chuni/music/[musicId]/music-playlog.tsx @@ -19,7 +19,8 @@ type ChuniMusicPlaylogProps = { export const ChuniMusicPlaylog = ({ music, playlog }: ChuniMusicPlaylogProps) => { type Music = (typeof music)[number]; type Playlog = (typeof playlog)['data'][number]; - const defaultExpanded: Record> = {} + + const [selected, setSelected] = useState(new Set()); const difficulties: (Music & { playlog: Playlog[] })[] = []; music.forEach(m => { @@ -27,65 +28,69 @@ export const ChuniMusicPlaylog = ({ music, playlog }: ChuniMusicPlaylogProps) => }); playlog.data.forEach(play => { - defaultExpanded[play.chartId!] = new Set(); difficulties[play.chartId!].playlog.push(play); }); - const [expanded, setExpanded] = useState(defaultExpanded); - const badgeClass = 'h-6 sm:h-8'; - return (
- {difficulties.map((data, i) => { - const rank = CHUNI_SCORE_RANKS[data.scoreRank!]; - const badges = [ - !!data.scoreRank && - {rank.endsWith('+') ? <> - {rank.slice(0, -1)} -
+
- : rank} -
, - data.isSuccess ? : null, - - ].filter(x => x); + return (
+ + {difficulties.map((data, i) => { + const rank = CHUNI_SCORE_RANKS[data.scoreRank!]; + const badges = [ + !!data.scoreRank && + {rank.endsWith('+') ? <> + {rank.slice(0, -1)} +
+
+ : rank} +
, + data.isSuccess ? : null, + (data.isFullCombo || data.isAllJustice) && + ].filter(x => x); - const toggleExpanded = () => expanded[i] && setExpanded(e => - ({ ...e, - [i]: e[i].size ? new Set() : new Set(['1']) - })); - return (
-
-
-
- + //
+ return ( { + const key = i.toString(); + setSelected(s => s.has(key) ? new Set([...s].filter(k => k !== key)) : new Set([...s, key])) + }}> +
+
+
+ +
+
{CHUNI_DIFFICULTIES[i]}
-
{CHUNI_DIFFICULTIES[i]}
+ {!data.playlog.length &&
No Play History
} + {data.rating ? : null} + {data.scoreMax ?
+ High Score: {data.scoreMax.toLocaleString()} +
: null} + {data.maxComboCount ?
+ Max Combo: {data.maxComboCount.toLocaleString()} +
: null}
- {!data.playlog.length &&
No Play History
} - {data.rating ? : null} - {data.scoreMax ?
- High Score: {data.scoreMax.toLocaleString()} + {badges.length ?
+ {badges}
: null} - {data.maxComboCount ?
- Max Combo: {data.maxComboCount.toLocaleString()} -
: null} -
- {badges.length ?
- {badges} -
: null} - {data.playlog.length ? setExpanded(e => ({ ...e, [i]: k as any }))}> - -
- {data.playlog.map(p => )} -
-
-
: null - } -
) - })} +
}> +
+ Chart designer: {data.chartDesigner} + {!!data.tapJudgeCount && Tap: {data.tapJudgeCount}} + {!!data.flickJudgeCount && Flick: {data.flickJudgeCount}} + {!!data.holdJudgeCount && Hold: {data.holdJudgeCount}} + {!!data.slideJudgeCount && Slide: {data.slideJudgeCount}} + {!!data.airJudgeCount && Air: {data.airJudgeCount}} +
+
+ {data.playlog.map(p => )} +
+ ); + })} +
); };