2023-05-22 17:38:31 -07:00
|
|
|
import { useMemo } from 'react';
|
2023-06-04 16:19:13 -07:00
|
|
|
import styled from 'styled-components';
|
2023-05-22 17:38:31 -07:00
|
|
|
import { LyricLine } from '/@/renderer/features/lyrics/lyric-line';
|
2023-06-04 23:15:36 -07:00
|
|
|
import { LyricOverride } from '/@/renderer/api/types';
|
|
|
|
|
import { LyricSkip } from '/@/renderer/features/lyrics/lyric-skip';
|
2023-05-22 17:38:31 -07:00
|
|
|
|
|
|
|
|
interface UnsynchronizedLyricsProps {
|
|
|
|
|
lyrics: string;
|
2023-06-04 23:15:36 -07:00
|
|
|
onRemoveLyric: () => void;
|
|
|
|
|
override: LyricOverride | null;
|
2023-06-03 18:03:32 -07:00
|
|
|
source: string | null;
|
2023-05-22 17:38:31 -07:00
|
|
|
}
|
|
|
|
|
|
2023-06-04 16:19:13 -07:00
|
|
|
const UnsynchronizedLyricsContainer = styled.div`
|
|
|
|
|
padding: 5rem 0;
|
|
|
|
|
`;
|
|
|
|
|
|
2023-06-04 23:15:36 -07:00
|
|
|
export const UnsynchronizedLyrics = ({
|
|
|
|
|
onRemoveLyric,
|
|
|
|
|
lyrics,
|
|
|
|
|
override,
|
|
|
|
|
source,
|
|
|
|
|
}: UnsynchronizedLyricsProps) => {
|
2023-05-22 17:38:31 -07:00
|
|
|
const lines = useMemo(() => {
|
|
|
|
|
return lyrics.split('\n');
|
|
|
|
|
}, [lyrics]);
|
|
|
|
|
|
|
|
|
|
return (
|
2023-06-04 16:19:13 -07:00
|
|
|
<UnsynchronizedLyricsContainer className="unsynchronized-lyrics">
|
|
|
|
|
{source && (
|
|
|
|
|
<LyricLine
|
|
|
|
|
className="lyric-credit"
|
|
|
|
|
text={`Lyrics provided by ${source}`}
|
|
|
|
|
/>
|
|
|
|
|
)}
|
2023-06-04 23:15:36 -07:00
|
|
|
{override && (
|
|
|
|
|
<>
|
|
|
|
|
<LyricLine
|
|
|
|
|
className="lyric-credit"
|
2023-06-05 02:42:25 -07:00
|
|
|
text={`(Matched as ${override.name} by ${override.artist})`}
|
2023-06-04 23:15:36 -07:00
|
|
|
/>
|
|
|
|
|
<LyricSkip onClick={onRemoveLyric} />
|
|
|
|
|
</>
|
|
|
|
|
)}
|
2023-05-22 17:38:31 -07:00
|
|
|
{lines.map((text, idx) => (
|
|
|
|
|
<LyricLine
|
|
|
|
|
key={idx}
|
2023-06-04 16:19:13 -07:00
|
|
|
className="unsynchronized active"
|
2023-05-22 17:38:31 -07:00
|
|
|
id={`lyric-${idx}`}
|
2023-05-28 14:31:49 -07:00
|
|
|
text={text}
|
2023-05-22 17:38:31 -07:00
|
|
|
/>
|
|
|
|
|
))}
|
2023-06-04 16:19:13 -07:00
|
|
|
</UnsynchronizedLyricsContainer>
|
2023-05-22 17:38:31 -07:00
|
|
|
);
|
|
|
|
|
};
|