Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 32 additions & 21 deletions src/components/layout/LyricsPanel.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useEffect, useMemo, useRef, useState } from "react";
import { Fragment, useEffect, useMemo, useRef, useState } from "react";
import { createPortal } from "react-dom";
import { useTranslation } from "react-i18next";
import { motion } from "framer-motion";
Expand Down Expand Up @@ -274,27 +274,38 @@ export function LyricsPanel() {
{hasWords ? (
<span>
{line.words!.map((word, wi) => (
<span
key={wi}
className={
wi === activeWordIndex
? "text-pink-500 dark:text-pink-400"
: wi < activeWordIndex
? ""
: "opacity-60"
}
style={{
display: "inline-block",
transform:
// See FullscreenLyrics for the rationale:
// `inline-block` strips the JSX whitespace
// that would normally separate inline
// siblings, and many Enhanced LRC sources
// omit spaces between word stamps. A literal
// `" "` text node restores the gap; if the
// source did carry trailing whitespace in
// `word.text`, `white-space: normal`
// collapses the pair to one.
<Fragment key={wi}>
<span
className={
wi === activeWordIndex
? "scale(1.04)"
: "scale(1)",
transition:
"color 150ms ease, opacity 150ms ease, transform 150ms ease",
}}
>
{word.text}
</span>
? "text-pink-500 dark:text-pink-400"
: wi < activeWordIndex
? ""
: "opacity-60"
}
style={{
display: "inline-block",
transform:
wi === activeWordIndex
? "scale(1.04)"
: "scale(1)",
transition:
"color 150ms ease, opacity 150ms ease, transform 150ms ease",
}}
>
{word.text}
</span>
{wi < line.words!.length - 1 && " "}
</Fragment>
))}
</span>
) : (
Expand Down
55 changes: 34 additions & 21 deletions src/components/player/FullscreenLyrics.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useEffect, useMemo, useRef } from "react";
import { Fragment, useEffect, useMemo, useRef } from "react";
import { useTranslation } from "react-i18next";
import { X, Music2, Maximize2 } from "lucide-react";
import { Artwork } from "../common/Artwork";
Expand Down Expand Up @@ -217,27 +217,40 @@ export function FullscreenLyrics({
: wi < activeWordIndex
? "past"
: "future";
// Render a literal space between adjacent
// word boxes. `display: inline-block` strips
// the JSX whitespace that would normally
// separate inline siblings, and many
// Enhanced LRC sources omit spaces between
// word stamps (`<wt>Meet<wt>me<wt>in…`),
// so without this the active line collapses
// to "Meetmeinthecrowd". If the source did
// include trailing space inside `word.text`,
// `white-space: normal` collapses the pair
// back to one.
return (
<span
key={wi}
style={{
opacity:
wState === "active"
? 1
: wState === "past"
? 0.8
: 0.45,
transform:
wState === "active"
? "scale(1.04)"
: "scale(1)",
display: "inline-block",
transition:
"opacity 150ms ease, transform 150ms ease",
}}
>
{word.text}
</span>
<Fragment key={wi}>
<span
style={{
opacity:
wState === "active"
? 1
: wState === "past"
? 0.8
: 0.45,
transform:
wState === "active"
? "scale(1.04)"
: "scale(1)",
display: "inline-block",
transition:
"opacity 150ms ease, transform 150ms ease",
}}
>
{word.text}
</span>
{wi < line.words!.length - 1 && " "}
</Fragment>
);
})}
</span>
Expand Down