// SPDX-License-Identifier: AGPL-3.0-only // Ported from Folia (https://github.com/chthollyphile/folia-major, v0.8.2), // src/components/visualizer/still/VisualizerStill.tsx: 静止, the style without motion. The line being sung with // the one before and the one after, plainly set; a line changes in place. // // Changed from Folia: used here for readers who ask their system for less motion, rather than offered as a // style of its own; the lines stand on the stage's still backdrop. import { resolveThemeFontWeight } from '../types'; import type { StyleContext, StyleRenderer } from './registry'; export const createStill = (context: StyleContext): StyleRenderer => { const { layer, theme, lines } = context; const box = document.createElement('div'); box.className = 'folia-still'; const rows = [-1, 0, 1].map((offset) => { const row = document.createElement('div'); row.className = offset === 0 ? 'folia-still__line folia-still__line--current' : 'folia-still__line'; row.style.color = theme.primaryColor; row.style.fontWeight = String(resolveThemeFontWeight(theme, offset === 0 ? 700 : 600)); box.append(row); return { row, offset }; }); layer.append(box); let shown = 0; return { setLine(_line, index) { // Between lines the last one stays up. if (index !== -1) shown = index; for (const { row, offset } of rows) row.textContent = lines[shown + offset]?.fullText ?? ''; }, frame() {}, destroy() { box.remove(); }, }; };