import { createEffect, createMemo, For, Show, createSignal } from 'solid-js'; import { type VirtualizerHandle } from 'virtua/solid'; import { type LineLyrics } from '@/plugins/synced-lyrics/types'; import { config } from '../renderer'; import { _ytAPI } from '..'; import { canonicalize, romanize, simplifyUnicode } from '../utils'; interface SyncedLineProps { scroller: VirtualizerHandle; index: number; line: LineLyrics; status: 'upcoming' | 'current' | 'previous'; } export const SyncedLine = (props: SyncedLineProps) => { const text = createMemo(() => { if (!props.line.text.trim()) { return config()?.defaultTextString ?? ''; } return props.line.text; }); const [romanization, setRomanization] = createSignal(''); createEffect(() => { if (!config()?.romanization) return; const input = canonicalize(text()); romanize(input).then((result) => { setRomanization(canonicalize(result)); }); }); return ( } when={text()} >
{ _ytAPI?.seekTo((props.line.timeInMs + 10) / 1000); }} >
{ // TODO: Investigate the animation, even though the duration is properly set, all lines have the same animation duration div.style.setProperty( '--lyrics-duration', `${props.line.duration / 1000}s`, 'important', ); }} style={{ 'display': 'flex', 'flex-direction': 'column' }} > {(word, index) => { return ( ); }} {(word, index) => { return ( ); }}
); };