Files
writer-work-flow/apps/web/components/review/BeatMap.tsx

37 lines
1.1 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"use client";
import { toBeatCells, toSparkline } from "@/lib/pace/beatmap";
interface BeatMapProps {
beatMap: number[];
}
// 爽点节拍图UX §6.4beat_map(int 序列) → ▁▃▅ 柱状条。
// 渲染为定高柱CSS height%),同时给文本 sparkline 作无障碍标签a11y §10
// 静态高度,无动画 → 天然尊重 prefers-reduced-motion。
export function BeatMap({ beatMap }: BeatMapProps) {
const cells = toBeatCells(beatMap);
if (cells.length === 0) {
return <span className="text-xs text-ink-soft"></span>;
}
const spark = toSparkline(beatMap);
return (
<div className="max-w-full overflow-x-auto pb-1">
<div
className="flex h-12 min-w-full items-end gap-0.5"
role="img"
aria-label={`爽点节拍图 ${spark}`}
>
{cells.map((cell, i) => (
<div
key={i}
className="min-w-[4px] flex-1 rounded-t bg-cinnabar/70"
style={{ height: `${cell.heightPct}%` }}
title={`${i + 1}拍 强度${cell.value}`}
/>
))}
</div>
</div>
);
}