feishin/src/renderer/features/lyrics/unsynchronized-lyrics.tsx

28 lines
691 B
TypeScript
Raw Normal View History

2023-05-22 17:38:31 -07:00
import { useMemo } from 'react';
2023-06-03 18:03:32 -07:00
import { Text } from '/@/renderer/components';
2023-05-22 17:38:31 -07:00
import { LyricLine } from '/@/renderer/features/lyrics/lyric-line';
interface UnsynchronizedLyricsProps {
lyrics: string;
2023-06-03 18:03:32 -07:00
source: string | null;
2023-05-22 17:38:31 -07:00
}
2023-06-03 18:03:32 -07:00
export const UnsynchronizedLyrics = ({ lyrics, source }: UnsynchronizedLyricsProps) => {
2023-05-22 17:38:31 -07:00
const lines = useMemo(() => {
return lyrics.split('\n');
}, [lyrics]);
return (
2023-06-03 18:03:32 -07:00
<div className="unsynchronized-lyrics">
2023-06-03 23:21:00 -07:00
{source && <Text $noSelect>Lyrics provided by {source}</Text>}
2023-05-22 17:38:31 -07:00
{lines.map((text, idx) => (
<LyricLine
key={idx}
id={`lyric-${idx}`}
text={text}
2023-05-22 17:38:31 -07:00
/>
))}
</div>
);
};