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

66 lines
1.4 KiB
TypeScript
Raw Normal View History

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';
import { FullLyricsMetadata } from '/@/renderer/api/types';
2023-05-22 17:38:31 -07:00
interface UnsynchronizedLyricsProps extends Omit<FullLyricsMetadata, 'lyrics'> {
2023-05-22 17:38:31 -07:00
lyrics: string;
}
2023-06-04 16:19:13 -07:00
const UnsynchronizedLyricsContainer = styled.div`
width: 100%;
height: 100%;
padding: 10vh 0 6vh;
overflow: scroll;
transform: translateY(-2rem);
mask-image: linear-gradient(
180deg,
transparent 5%,
rgba(0, 0, 0, 100%) 20%,
rgba(0, 0, 0, 100%) 85%,
transparent 95%
);
@media screen and (max-width: 768px) {
padding: 5vh 0;
}
2023-06-04 16:19:13 -07:00
`;
export const UnsynchronizedLyrics = ({
artist,
lyrics,
name,
remote,
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"
2023-06-09 04:09:46 -07:00
text={`Provided by ${source}`}
2023-06-04 16:19:13 -07:00
/>
)}
{remote && (
<LyricLine
className="lyric-credit"
2023-06-09 04:09:46 -07:00
text={`"${name} by ${artist}"`}
/>
)}
2023-05-22 17:38:31 -07:00
{lines.map((text, idx) => (
<LyricLine
key={idx}
2023-06-09 02:38:56 -07:00
className="lyric-line"
2023-05-22 17:38:31 -07:00
id={`lyric-${idx}`}
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
);
};