Upgrade to karaoke display window, including slightly more interesting graphical options.
This commit is contained in:
1 parent
6f0ca67979
commit
8333da1351
3 files changed
+428
-55
No files matched your search
+120
@@ -213,3 +213,123 @@ Changed `color: isActive ? bright : dim` → `color: (isActive || done) ? bright
|
||||
**Problem:** Active word is `fontSize * 1.15`; `base` uses `verticalAlign: 'top'`, so the larger word's top aligns with others but extends further down.
|
||||
|
||||
**Fix:** Override to `verticalAlign: 'middle'` in the pop-mode branch so all words (normal and enlarged) center on the same axis.
|
||||
|
||||
---
|
||||
|
||||
### Album card font not affected by font option
|
||||
|
||||
Both the small windowed overlay and the fullscreen album panel used hardcoded `fontFamily` / `fontWeight` values, so the user's font selection had no effect.
|
||||
|
||||
**Fix:** Added `fontFamily` to both text containers (windowed overlay `<div>` and fullscreen panel `<div>`). The subtitle in both also respects `fontWeight: fontBold ? 700 : 400`. Artist name stays at 700 (it's always a heading).
|
||||
|
||||
Also changed the windowed overlay from `flexDirection: 'column'` (art above, text below) to `flexDirection: 'row', alignItems: 'center'` so text sits beside and vertically centered on the art.
|
||||
|
||||
---
|
||||
|
||||
### TypeScript error 7026 / 2875 / 2322 (pre-existing, not build-blocking)
|
||||
|
||||
These TS language server errors ("no interface JSX.IntrinsicElements exists", "react/jsx-runtime not found") appear on whichever line was last edited. They are a pre-existing tsconfig / language server cache issue — not introduced by any of the above changes. Vite uses esbuild for transpilation and does not type-check, so `vite build` is unaffected. Restart the TS server (VS Code: Ctrl+Shift+P → "TypeScript: Restart TS Server") or let the container run `npm install` to resolve.
|
||||
|
||||
### Styling options — stroke, shadow, scale, pop size
|
||||
|
||||
Added to `StyleState`: `strokeWidth`, `strokeColor`, `shadowBlur`, `shadowX`, `shadowY`, `shadowColor`, `scaleX`, `scaleY`, `popScale`.
|
||||
|
||||
**StylePicker** gained two new rows:
|
||||
- **Effects row**: stroke color swatch + width slider (0–4), shadow color swatch + blur/X/Y sliders.
|
||||
- **Scale row**: W (horizontal) and H (vertical) scale sliders (0.5–2×). A **Pop** slider (15–25%) appears conditionally when `karaokeMode === 'pop'`.
|
||||
|
||||
**Lyrics container** (outer div): `textShadow` and `WebkitTextStroke` applied from state; `as any` cast used because the file uses named React imports (no `React` namespace for `React.CSSProperties`).
|
||||
|
||||
**Inner lyrics div**: `transform` updated to `translateY(…) scaleX(…) scaleY(…)`.
|
||||
|
||||
**`KaraokeWord`**: accepts `popScale?: number` (default 15); pop branch uses `fontSize * (1 + popScale / 100)` for the active word size.
|
||||
|
||||
**All three `KaraokeWord` call sites** (karaoke / glow / blur renderers) updated to pass `popScale={popScale}`.
|
||||
|
||||
### Stroke fix — proper outer border, not hollow outline; show/hide toggles; shadow opacity; Reset
|
||||
|
||||
**Problem:** `-webkit-text-stroke` strokes symmetrically inward and outward, hollowing the glyph fill. In gradient (fill) mode, `-webkit-text-fill-color: transparent` made it worse — just an outline with no visible fill.
|
||||
|
||||
**Fix:** Replaced `-webkit-text-stroke` entirely with a disc-shaped `text-shadow` simulation. `makeStrokeShadow(width, color)` generates zero-blur shadows at every integer offset within a radius, producing a filled outer ring. Works correctly with `WebkitTextFillColor: transparent` (gradient mode) and normal color fills (pop mode).
|
||||
|
||||
**Added `hexToRgba(hex, opacity)`** to apply shadow opacity to the drop shadow.
|
||||
|
||||
**New `StyleState` fields:** `strokeEnabled: boolean`, `shadowEnabled: boolean`, `shadowOpacity: number` (0–1).
|
||||
|
||||
**`DEFAULT_STYLE` constant** extracted so defaults are a single source of truth used by both `useState` and the new `resetStyle` handler.
|
||||
|
||||
**StylePicker UI changes:**
|
||||
- Stroke and Shadow labels are now toggle **buttons** (click to enable/disable); controls collapse when disabled.
|
||||
- Shadow controls gained an **Opacity** slider (0–1) next to the color swatch.
|
||||
- **Reset** button added in the font row (right side) — clears localStorage and restores `DEFAULT_STYLE`.
|
||||
|
||||
**`StylePicker` prop:** `onReset: () => void` added. `resetStyle` callback in main component removes the localStorage key and calls `setStyle(DEFAULT_STYLE)`.
|
||||
|
||||
### Stroke rendering order — abandoned text-shadow approach; switched to WebkitTextStroke + paint-order
|
||||
|
||||
**Attempt 1 (disc text-shadow):** Generated a disc of zero-blur `text-shadow` entries. Inner shadows covered the gradient interior, making text look hollow/broken.
|
||||
|
||||
**Attempt 2 (ring text-shadow):** Limited shadows to the outermost pixel band. Still jagged/bubbly in practice — each shadow entry is a full pixel-offset copy of the glyph shape; many overlapping copies create rough anti-aliasing artefacts visible as a bubbly halo.
|
||||
|
||||
**Final fix:** Removed `makeStrokeShadow` entirely. Now use:
|
||||
- `WebkitTextStroke: '${strokeWidth}px ${strokeColor}'` on the container (cascades to all child text)
|
||||
- `paintOrder: 'stroke fill'` on the container (cascades): renders stroke first, then fill on top — only the outer half of the stroke extends beyond the glyph edge; the inner half is covered by the opaque fill
|
||||
|
||||
For pop mode (solid fill): only the outer stroke ring is visible. Clean outer border. ✓
|
||||
For fill/gradient mode (`WebkitTextFillColor: transparent`): fill is transparent, so inner half of stroke is slightly visible at the glyph edge. For thin strokes this is a minor tint at the very edge; outer border is clean and anti-aliased. Acceptable trade-off vs. jagged shadow approach. ✓
|
||||
|
||||
Drop shadow remains via `textShadow` on the container, unchanged.
|
||||
|
||||
### Stroke/shadow layered DOM approach in KaraokeWord
|
||||
|
||||
**Problem:** `WebkitTextStroke` + `paint-order: stroke fill` still broke gradient text. CSS paints `background` (where the gradient lives via `background-clip:text`) before `text-shadow`/`WebkitTextStroke`, so any stroke technique on the same element appears on top of the gradient, not behind it. No single-element CSS solution can place the stroke behind a `background-clip:text` gradient.
|
||||
|
||||
**Fix:** Layered DOM structure inside `KaraokeWord`. When stroke or shadow is active:
|
||||
```
|
||||
<span style="position:relative"> ← wrapper (layout)
|
||||
<span aria-hidden style="position:absolute"> ← behind-layer: stroke + shadow
|
||||
<span ref={elRef}> ← fill-layer: gradient/pop text
|
||||
```
|
||||
- **Behind-layer**: renders `WebkitTextStroke` + `paintOrder: stroke fill` + `textShadow`. With opaque fill color, only the outer half of the stroke extends beyond the glyph → clean outer ring.
|
||||
- **Fill-layer**: resets `WebkitTextStroke: '0 transparent'` and `textShadow: 'none'` to cancel container inheritance, then renders gradient or solid-color text on top.
|
||||
|
||||
Result: shadow (back) → stroke → base text (front), all properly layered.
|
||||
|
||||
**`WordEffects` interface** added; `wordEffects` object constructed from destructured style state; passed to all 3 `KaraokeWord` call sites as `effects={wordEffects}`.
|
||||
|
||||
**hexToRgba** moved above `KaraokeWord` so `behindLayer` can call it.
|
||||
|
||||
Container keeps `WebkitTextStroke` + `paintOrder` + `textShadow` for non-karaoke modes (scroll/fade) where text has opaque fills and the single-element approach works correctly.
|
||||
|
||||
### Layer z-index fix + sluggishness fix
|
||||
|
||||
**z-index bug:** `position: absolute` elements paint on top of in-flow elements by default regardless of DOM order. The behind-layer (`position: absolute`) was rendering above the fill span. Fixed by adding `zIndex: 0` to the behind-layer and `position: relative; zIndex: 1` to the fill/pop front span via `frontLayerBase`. CSS z-index only applies to positioned elements, so the fill span needed `position: relative` to participate in z-index stacking.
|
||||
|
||||
**Sluggishness:** The RAF loop triggers React state updates (~60 fps), causing re-renders of the lyrics line. Each re-render was constructing a new `wordEffects` object, propagating as a changed prop to every `KaraokeWord` in the line. Fixed by wrapping `wordEffects` in `useMemo` with the style fields as dependencies — the object reference is now stable during playback and only changes when the user adjusts a style control. `useMemo` added to the React import.
|
||||
|
||||
### Album art overlay text exempt from stroke/shadow
|
||||
|
||||
The windowed overlay (`div` wrapping artist + title `<p>` tags) and the fullscreen album panel (`div` with artist/title) both inherit `WebkitTextStroke` and `textShadow` from the outer lyrics container. Fixed by adding `WebkitTextStroke: 'initial'` and `textShadow: 'none'` to the `style` prop of each wrapper div (`as any` cast to avoid TS CSSProperties namespace error).
|
||||
|
||||
### Pop mode syllable transition — font-size → transform: scale()
|
||||
|
||||
**Problem:** Pop mode used `fontSize: activeFontSize` (switching between base and scaled size) on the wrapper, with `transition: 'font-size 0.08s ease'`. Font-size changes trigger layout reflow on every transition frame, causing jank. 80ms was also too short, making the snap feel jarring.
|
||||
|
||||
**Fix:**
|
||||
- Replaced `fontSize` toggling with `transform: scale(1 + popScale/100)` on the wrapper span — GPU-composited, zero layout reflow.
|
||||
- `fontSize` is now always `fontSize` (base size); the wrapper transform handles the visual growth.
|
||||
- Transition: `transform 0.15s ease-out, color 0.15s ease-out` — 150ms feels smooth without lag; `ease-out` snaps into the active state and eases out of it naturally.
|
||||
- `willChange: 'transform'` added on pop-mode wrappers to hint the browser to promote them to a compositor layer.
|
||||
- Behind-layer `fontSize` also stays at base size (scales with the wrapper via inherited transform).
|
||||
|
||||
### Stroke rounded joins — prevent "fang" artefacts
|
||||
|
||||
`-webkit-text-stroke` defaults to miter joins at sharp glyph corners, producing spike/fang artefacts. Fixed by adding `strokeLinejoin: 'round'` and `strokeLinecap: 'round'` (SVG stroke properties, honoured by Chromium/WebKit on HTML text with `-webkit-text-stroke`) to both the `KaraokeWord` behind-layer span and the outer lyrics container (for non-karaoke/scroll/fade modes).
|
||||
|
||||
### Pop mode — Snap slider (transition duration)
|
||||
|
||||
Added `popSnap: number` (ms) to `StyleState` and `DEFAULT_STYLE` (default: 150ms). A **Snap** slider (50–500ms, step 25ms) appears next to the Pop slider when `karaokeMode === 'pop'`. The value is passed as `snapMs` prop to `KaraokeWord` (default 150) and used in the `wrapStyle` transition: `` `transform ${snapMs}ms ease-out, color ${snapMs}ms ease-out` ``. Range rationale: 50ms feels near-instant/snappy; 500ms is a slow, deliberate fade.
|
||||
|
||||
### BG color scope fix — fullscreen root no longer inherits bgColor
|
||||
|
||||
The fullscreen root `<div>` had `style={isFullscreen ? { backgroundColor: effectiveBg } : undefined}`. This painted the entire fullscreen container (including toolbar, controls, album panel) with the user's BG color. The BG color is already applied correctly on the inner lyrics area div (`backgroundColor: effectiveBg` at line ~1804). Removed the root-level style entirely (`style={undefined}`).
|
||||
@@ -19,8 +19,8 @@
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
|
||||
<meta name="apple-mobile-web-app-title" content="StemEngine" />
|
||||
<link rel="apple-touch-icon" href="/icon.svg" />
|
||||
<script type="module" crossorigin src="/assets/index-49yhwRUo.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/index-DBHjVSaY.css">
|
||||
<script type="module" crossorigin src="/assets/index-BtPYzF_7.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/index-02k6pNvN.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { useState, useEffect, useLayoutEffect, useRef, useCallback } from 'react'
|
||||
import { useState, useEffect, useLayoutEffect, useRef, useCallback, useMemo } from 'react'
|
||||
import { Play, Pause, SkipBack, Volume2, VolumeX, Palette, Pencil, X, AlignLeft, AlignCenter, AlignRight, Type, Crosshair, Maximize2, Minimize2 } from 'lucide-react'
|
||||
import type { LyricsStyleOptions } from '../types'
|
||||
import { registerPlayback, unregisterPlayback, publishMeta, clearMeta } from '../utils/audioRegistry'
|
||||
@@ -230,7 +230,27 @@ function formatTime(s: number): string {
|
||||
|
||||
// ─── Word rendering helpers ───────────────────────────────────────────────────
|
||||
|
||||
/** Karaoke word renderer — supports 'fill' (gradient sweep) and 'pop' (active word lit) modes. */
|
||||
interface WordEffects {
|
||||
strokeEnabled: boolean
|
||||
strokeWidth: number
|
||||
strokeColor: string
|
||||
shadowEnabled: boolean
|
||||
shadowX: number
|
||||
shadowY: number
|
||||
shadowBlur: number
|
||||
shadowColor: string
|
||||
shadowOpacity: number
|
||||
}
|
||||
|
||||
/**
|
||||
* Karaoke word renderer — supports 'fill' (gradient sweep) and 'pop' (active word lit) modes.
|
||||
*
|
||||
* Stroke + shadow are composited via a separately positioned behind-layer so that the
|
||||
* base text always renders in front: shadow → stroke → base text (front).
|
||||
* This is the only reliable approach for gradient text where WebkitTextFillColor is
|
||||
* transparent — CSS paint-order alone cannot push text-shadow/stroke behind a
|
||||
* background-clip:text gradient.
|
||||
*/
|
||||
function KaraokeWord({
|
||||
word,
|
||||
fill,
|
||||
@@ -242,6 +262,9 @@ function KaraokeWord({
|
||||
elRef,
|
||||
isActive,
|
||||
mode,
|
||||
popScale = 15,
|
||||
snapMs = 150,
|
||||
effects,
|
||||
}: {
|
||||
word: string
|
||||
fill: number // 0–1
|
||||
@@ -253,53 +276,127 @@ function KaraokeWord({
|
||||
elRef?: { current: HTMLSpanElement | null }
|
||||
isActive?: boolean
|
||||
mode?: 'fill' | 'pop'
|
||||
popScale?: number
|
||||
snapMs?: number
|
||||
effects?: WordEffects
|
||||
}) {
|
||||
const base: React.CSSProperties = {
|
||||
const strokeVal = effects?.strokeEnabled && effects.strokeWidth > 0
|
||||
? `${effects.strokeWidth}px ${effects.strokeColor}` : undefined
|
||||
const shadowVal = effects?.shadowEnabled
|
||||
? `${effects.shadowX}px ${effects.shadowY}px ${effects.shadowBlur}px ${hexToRgba(effects.shadowColor, effects.shadowOpacity)}`
|
||||
: undefined
|
||||
const needsLayer = !!(strokeVal || shadowVal)
|
||||
|
||||
// Pop scale via CSS transform — GPU-accelerated, no layout reflow (unlike font-size changes)
|
||||
const popTransform = mode === 'pop'
|
||||
? `scale(${isActive ? 1 + popScale / 100 : 1})`
|
||||
: undefined
|
||||
|
||||
// ── Wrapper layout props (applied to the outermost element in every branch) ──
|
||||
const wrapStyle = {
|
||||
display: 'inline-block',
|
||||
verticalAlign: 'top',
|
||||
verticalAlign: mode === 'pop' ? 'middle' : 'top',
|
||||
marginRight: isWordEnd ? '0.25em' : '0',
|
||||
fontSize,
|
||||
}
|
||||
position: needsLayer ? 'relative' : undefined,
|
||||
transform: popTransform,
|
||||
transition: mode === 'pop' ? `transform ${snapMs}ms ease-out, color ${snapMs}ms ease-out` : undefined,
|
||||
willChange: mode === 'pop' ? 'transform' : undefined,
|
||||
} as React.CSSProperties
|
||||
|
||||
// ── Behind-layer span (stroke + shadow, rendered under the fill text) ──────
|
||||
const behindLayer = needsLayer ? (
|
||||
<span
|
||||
aria-hidden="true"
|
||||
style={{
|
||||
position: 'absolute',
|
||||
left: 0,
|
||||
top: 0,
|
||||
display: 'block',
|
||||
fontSize,
|
||||
color: strokeVal ? effects!.strokeColor : 'transparent',
|
||||
WebkitTextFillColor: strokeVal ? effects!.strokeColor : 'transparent',
|
||||
WebkitTextStroke: strokeVal,
|
||||
paintOrder: 'stroke fill',
|
||||
strokeLinejoin: 'round',
|
||||
strokeLinecap: 'round',
|
||||
textShadow: shadowVal,
|
||||
pointerEvents: 'none',
|
||||
userSelect: 'none',
|
||||
whiteSpace: 'nowrap',
|
||||
zIndex: 0,
|
||||
} as any}
|
||||
>{word}</span>
|
||||
) : null
|
||||
|
||||
// Positioned so z-index works; z-index 1 ensures fill is always above the behind-layer (z-index 0)
|
||||
const frontLayerBase = needsLayer
|
||||
? { position: 'relative' as const, zIndex: 1, display: 'block' }
|
||||
: {}
|
||||
|
||||
if (mode === 'pop') {
|
||||
const popStyle = {
|
||||
...frontLayerBase,
|
||||
color: (isActive || done) ? bright : dim,
|
||||
transition: 'color 0.15s ease-out',
|
||||
backgroundImage: 'none',
|
||||
WebkitBackgroundClip: 'border-box',
|
||||
WebkitTextFillColor: 'currentColor',
|
||||
backgroundClip: 'border-box',
|
||||
WebkitTextStroke: '0 transparent',
|
||||
textShadow: 'none',
|
||||
}
|
||||
if (!needsLayer) {
|
||||
return (
|
||||
<span ref={el => { if (elRef) elRef.current = el }} style={{ ...wrapStyle, ...popStyle } as any}>
|
||||
{word}
|
||||
</span>
|
||||
)
|
||||
}
|
||||
return (
|
||||
<span
|
||||
ref={el => { if (elRef) elRef.current = el }}
|
||||
style={{
|
||||
...base,
|
||||
verticalAlign: 'middle',
|
||||
color: (isActive || done) ? bright : dim,
|
||||
fontSize: isActive ? fontSize * 1.15 : fontSize,
|
||||
transition: 'font-size 0.08s ease, color 0.08s ease',
|
||||
// Explicitly clear gradient-clip props so they don't bleed in from a prior fill-mode render
|
||||
backgroundImage: 'none',
|
||||
WebkitBackgroundClip: 'border-box',
|
||||
WebkitTextFillColor: 'currentColor',
|
||||
backgroundClip: 'border-box',
|
||||
} as React.CSSProperties}
|
||||
>
|
||||
<span style={wrapStyle}>
|
||||
{behindLayer}
|
||||
<span ref={el => { if (elRef) elRef.current = el }} style={popStyle as any}>{word}</span>
|
||||
</span>
|
||||
)
|
||||
}
|
||||
|
||||
// fill mode: gradient sweep
|
||||
const pct = done ? 100 : Math.round(fill * 100)
|
||||
const fillStyle = {
|
||||
...frontLayerBase,
|
||||
backgroundImage: `linear-gradient(to right, ${bright} ${pct}%, ${dim} ${pct}%)`,
|
||||
WebkitBackgroundClip: 'text',
|
||||
WebkitTextFillColor: 'transparent',
|
||||
backgroundClip: 'text',
|
||||
WebkitTextStroke: '0 transparent',
|
||||
textShadow: 'none',
|
||||
}
|
||||
if (!needsLayer) {
|
||||
return (
|
||||
<span ref={el => { if (elRef) elRef.current = el }} style={{ ...wrapStyle, ...fillStyle } as any}>
|
||||
{word}
|
||||
</span>
|
||||
)
|
||||
}
|
||||
const pct = done ? 100 : Math.round(fill * 100)
|
||||
return (
|
||||
<span
|
||||
ref={el => { if (elRef) elRef.current = el }}
|
||||
style={{
|
||||
...base,
|
||||
backgroundImage: `linear-gradient(to right, ${bright} ${pct}%, ${dim} ${pct}%)`,
|
||||
WebkitBackgroundClip: 'text',
|
||||
WebkitTextFillColor: 'transparent',
|
||||
backgroundClip: 'text',
|
||||
} as React.CSSProperties}
|
||||
>
|
||||
{word}
|
||||
<span style={wrapStyle}>
|
||||
{behindLayer}
|
||||
<span ref={el => { if (elRef) elRef.current = el }} style={fillStyle as any}>{word}</span>
|
||||
</span>
|
||||
)
|
||||
}
|
||||
|
||||
// ─── Style Picker Panel ───────────────────────────────────────────────────────
|
||||
|
||||
|
||||
function hexToRgba(hex: string, opacity: number): string {
|
||||
const r = parseInt(hex.slice(1, 3), 16)
|
||||
const g = parseInt(hex.slice(3, 5), 16)
|
||||
const b = parseInt(hex.slice(5, 7), 16)
|
||||
return `rgba(${r}, ${g}, ${b}, ${opacity})`
|
||||
}
|
||||
|
||||
interface StyleState {
|
||||
fontFamily: string
|
||||
fontSize: number
|
||||
@@ -312,15 +409,57 @@ interface StyleState {
|
||||
dynBg: boolean
|
||||
karaokeMode: 'fill' | 'pop'
|
||||
fontBold: boolean
|
||||
strokeEnabled: boolean
|
||||
strokeWidth: number
|
||||
strokeColor: string
|
||||
shadowEnabled: boolean
|
||||
shadowBlur: number
|
||||
shadowX: number
|
||||
shadowY: number
|
||||
shadowColor: string
|
||||
shadowOpacity: number
|
||||
scaleX: number
|
||||
scaleY: number
|
||||
popScale: number
|
||||
popSnap: number
|
||||
}
|
||||
|
||||
const DEFAULT_STYLE: StyleState = {
|
||||
fontFamily: 'system-ui, sans-serif',
|
||||
fontSize: 20,
|
||||
bgColor: '#0f172a',
|
||||
textColor: '#c8d3e0',
|
||||
highlightColor: '#3b82f6',
|
||||
wordHighlight: '#60a5fa',
|
||||
textAlign: 'center',
|
||||
lineSpacing: 1.6,
|
||||
dynBg: false,
|
||||
karaokeMode: 'fill',
|
||||
fontBold: false,
|
||||
strokeEnabled: false,
|
||||
strokeWidth: 2,
|
||||
strokeColor: '#000000',
|
||||
shadowEnabled: false,
|
||||
shadowBlur: 4,
|
||||
shadowX: 2,
|
||||
shadowY: 2,
|
||||
shadowColor: '#000000',
|
||||
shadowOpacity: 1,
|
||||
scaleX: 1,
|
||||
scaleY: 1,
|
||||
popScale: 15,
|
||||
popSnap: 150,
|
||||
}
|
||||
|
||||
function StylePicker({
|
||||
style,
|
||||
onChange,
|
||||
onReset,
|
||||
hasCoverArt,
|
||||
}: {
|
||||
style: StyleState
|
||||
onChange: (patch: Partial<StyleState>) => void
|
||||
onReset: () => void
|
||||
hasCoverArt?: boolean
|
||||
}) {
|
||||
return (
|
||||
@@ -370,6 +509,11 @@ function StylePicker({
|
||||
</button>
|
||||
)
|
||||
})}
|
||||
<button
|
||||
onClick={onReset}
|
||||
title="Reset to defaults"
|
||||
className="ml-1 px-1.5 py-0.5 rounded text-[10px] text-slate-500 hover:text-slate-200 hover:bg-white/10 transition-colors"
|
||||
>Reset</button>
|
||||
</div>
|
||||
</div>
|
||||
{/* Color row */}
|
||||
@@ -379,7 +523,6 @@ function StylePicker({
|
||||
<ColorSwatch label="Line" value={style.highlightColor} onChange={v => onChange({ highlightColor: v })} />
|
||||
<ColorSwatch label="Word" value={style.wordHighlight} onChange={v => onChange({ wordHighlight: v })} />
|
||||
<div className="flex items-center gap-1 ml-1 border-l border-white/10 pl-2">
|
||||
<span className="text-[10px] text-slate-500">Fill</span>
|
||||
{(['fill', 'pop'] as const).map(m => (
|
||||
<button
|
||||
key={m}
|
||||
@@ -398,6 +541,89 @@ function StylePicker({
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
{/* Effects row — stroke + shadow */}
|
||||
<div className="flex items-center gap-3 flex-wrap">
|
||||
<div className="flex items-center gap-1">
|
||||
<button
|
||||
onClick={() => onChange({ strokeEnabled: !style.strokeEnabled })}
|
||||
className={`text-[10px] px-1.5 py-0.5 rounded transition-colors ${style.strokeEnabled ? 'bg-white/20 text-white' : 'text-slate-400 hover:text-slate-200'}`}
|
||||
title="Toggle stroke"
|
||||
>Stroke</button>
|
||||
{style.strokeEnabled && <>
|
||||
<ColorSwatch label="" value={style.strokeColor} onChange={v => onChange({ strokeColor: v })} />
|
||||
<input type="range" min={0.5} max={6} step={0.5}
|
||||
value={style.strokeWidth}
|
||||
onChange={e => onChange({ strokeWidth: +e.target.value })}
|
||||
className="w-16 h-1.5 accent-brand-400" title="Stroke width" />
|
||||
<span className="text-[10px] tabular-nums text-slate-400 w-4">{style.strokeWidth}</span>
|
||||
</>}
|
||||
</div>
|
||||
<div className="flex items-center gap-1">
|
||||
<button
|
||||
onClick={() => onChange({ shadowEnabled: !style.shadowEnabled })}
|
||||
className={`text-[10px] px-1.5 py-0.5 rounded transition-colors ${style.shadowEnabled ? 'bg-white/20 text-white' : 'text-slate-400 hover:text-slate-200'}`}
|
||||
title="Toggle shadow"
|
||||
>Shadow</button>
|
||||
{style.shadowEnabled && <>
|
||||
<ColorSwatch label="" value={style.shadowColor} onChange={v => onChange({ shadowColor: v })} />
|
||||
<input type="range" min={0} max={1} step={0.05}
|
||||
value={style.shadowOpacity}
|
||||
onChange={e => onChange({ shadowOpacity: +e.target.value })}
|
||||
className="w-10 h-1.5 accent-brand-400" title="Opacity" />
|
||||
<input type="range" min={0} max={20} step={1}
|
||||
value={style.shadowBlur}
|
||||
onChange={e => onChange({ shadowBlur: +e.target.value })}
|
||||
className="w-14 h-1.5 accent-brand-400" title="Blur" />
|
||||
<input type="range" min={-10} max={10} step={1}
|
||||
value={style.shadowX}
|
||||
onChange={e => onChange({ shadowX: +e.target.value })}
|
||||
className="w-10 h-1.5 accent-brand-400" title="X" />
|
||||
<input type="range" min={-10} max={10} step={1}
|
||||
value={style.shadowY}
|
||||
onChange={e => onChange({ shadowY: +e.target.value })}
|
||||
className="w-10 h-1.5 accent-brand-400" title="Y" />
|
||||
</>}
|
||||
</div>
|
||||
</div>
|
||||
{/* Scale row — scaleX, scaleY + pop size (conditional) */}
|
||||
<div className="flex items-center gap-3 flex-wrap">
|
||||
<div className="flex items-center gap-1">
|
||||
<span className="text-[10px] text-slate-500">W</span>
|
||||
<input type="range" min={0.5} max={2} step={0.05}
|
||||
value={style.scaleX}
|
||||
onChange={e => onChange({ scaleX: +e.target.value })}
|
||||
className="w-20 h-1.5 accent-brand-400" title="Horizontal scale" />
|
||||
<span className="text-[10px] tabular-nums text-slate-400 w-7">{style.scaleX.toFixed(2)}</span>
|
||||
</div>
|
||||
<div className="flex items-center gap-1">
|
||||
<span className="text-[10px] text-slate-500">H</span>
|
||||
<input type="range" min={0.5} max={2} step={0.05}
|
||||
value={style.scaleY}
|
||||
onChange={e => onChange({ scaleY: +e.target.value })}
|
||||
className="w-20 h-1.5 accent-brand-400" title="Vertical scale" />
|
||||
<span className="text-[10px] tabular-nums text-slate-400 w-7">{style.scaleY.toFixed(2)}</span>
|
||||
</div>
|
||||
{style.karaokeMode === 'pop' && (
|
||||
<div className="flex items-center gap-1">
|
||||
<span className="text-[10px] text-slate-500">Pop</span>
|
||||
<input type="range" min={15} max={25} step={1}
|
||||
value={style.popScale}
|
||||
onChange={e => onChange({ popScale: +e.target.value })}
|
||||
className="w-16 h-1.5 accent-brand-400" title="Pop word scale %" />
|
||||
<span className="text-[10px] tabular-nums text-slate-400 w-6">{style.popScale}%</span>
|
||||
</div>
|
||||
)}
|
||||
{style.karaokeMode === 'pop' && (
|
||||
<div className="flex items-center gap-1">
|
||||
<span className="text-[10px] text-slate-500">Snap</span>
|
||||
<input type="range" min={50} max={500} step={25}
|
||||
value={style.popSnap}
|
||||
onChange={e => onChange({ popSnap: +e.target.value })}
|
||||
className="w-16 h-1.5 accent-brand-400" title="Transition duration (ms)" />
|
||||
<span className="text-[10px] tabular-nums text-slate-400 w-8">{style.popSnap}ms</span>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
{/* Dynamic BG from album art — only shown when cover art is available */}
|
||||
{hasCoverArt && (
|
||||
<label className="flex items-center gap-2 cursor-pointer select-none">
|
||||
@@ -561,17 +787,15 @@ export default function LyricsLivePreview({ lrcText, audioUrl, stems, title, sty
|
||||
// Editable style state — seeded from styleOptions prop, then overridden by any saved preference
|
||||
const [style, setStyle] = useState<StyleState>(() => {
|
||||
const defaults: StyleState = {
|
||||
fontFamily: styleOptions?.fontFamily ?? 'system-ui, sans-serif',
|
||||
fontSize: styleOptions?.fontSize ?? 20,
|
||||
bgColor: styleOptions?.backgroundColor ?? '#0f172a',
|
||||
textColor: styleOptions?.textColor ?? '#c8d3e0',
|
||||
highlightColor: styleOptions?.highlightColor ?? '#3b82f6',
|
||||
wordHighlight: styleOptions?.wordHighlightColor ?? '#60a5fa',
|
||||
textAlign: (styleOptions?.textAlign ?? 'center') as 'left' | 'center' | 'right',
|
||||
lineSpacing: styleOptions?.lineSpacing ?? 1.6,
|
||||
dynBg: false,
|
||||
karaokeMode: 'fill',
|
||||
fontBold: false,
|
||||
...DEFAULT_STYLE,
|
||||
fontFamily: styleOptions?.fontFamily ?? DEFAULT_STYLE.fontFamily,
|
||||
fontSize: styleOptions?.fontSize ?? DEFAULT_STYLE.fontSize,
|
||||
bgColor: styleOptions?.backgroundColor ?? DEFAULT_STYLE.bgColor,
|
||||
textColor: styleOptions?.textColor ?? DEFAULT_STYLE.textColor,
|
||||
highlightColor: styleOptions?.highlightColor ?? DEFAULT_STYLE.highlightColor,
|
||||
wordHighlight: styleOptions?.wordHighlightColor ?? DEFAULT_STYLE.wordHighlight,
|
||||
textAlign: (styleOptions?.textAlign ?? DEFAULT_STYLE.textAlign) as 'left' | 'center' | 'right',
|
||||
lineSpacing: styleOptions?.lineSpacing ?? DEFAULT_STYLE.lineSpacing,
|
||||
}
|
||||
try {
|
||||
const saved = localStorage.getItem('stemengine-lyric-style')
|
||||
@@ -586,11 +810,22 @@ export default function LyricsLivePreview({ lrcText, audioUrl, stems, title, sty
|
||||
return next
|
||||
})
|
||||
}, [])
|
||||
const resetStyle = useCallback(() => {
|
||||
try { localStorage.removeItem('stemengine-lyric-style') } catch { /* ignore */ }
|
||||
setStyle(DEFAULT_STYLE)
|
||||
}, [])
|
||||
|
||||
// Destructure for convenience
|
||||
const { fontFamily, fontSize: baseFontSize, bgColor, textColor, highlightColor, wordHighlight, textAlign, lineSpacing, dynBg, karaokeMode, fontBold } = style
|
||||
const { fontFamily, fontSize: baseFontSize, bgColor, textColor, highlightColor, wordHighlight, textAlign, lineSpacing, dynBg, karaokeMode, fontBold, strokeEnabled, strokeWidth, strokeColor, shadowEnabled, shadowBlur, shadowX, shadowY, shadowColor, shadowOpacity, scaleX, scaleY, popScale, popSnap } = style
|
||||
// fontSize is finalised after isFullscreen is available (declared below)
|
||||
|
||||
// Passed to KaraokeWord so each word can render its own stroke/shadow behind-layer.
|
||||
// Memoized so RAF-triggered re-renders don't create a new object reference every frame.
|
||||
const wordEffects = useMemo<WordEffects>(
|
||||
() => ({ strokeEnabled, strokeWidth, strokeColor, shadowEnabled, shadowX, shadowY, shadowBlur, shadowColor, shadowOpacity }),
|
||||
[strokeEnabled, strokeWidth, strokeColor, shadowEnabled, shadowX, shadowY, shadowBlur, shadowColor, shadowOpacity]
|
||||
)
|
||||
|
||||
// Track whether cover art image loaded successfully
|
||||
const [artLoaded, setArtLoaded] = useState(false)
|
||||
|
||||
@@ -1296,6 +1531,9 @@ export default function LyricsLivePreview({ lrcText, audioUrl, stems, title, sty
|
||||
elRef={wi === activeWordIdx ? activeWordSpanRef : undefined}
|
||||
isActive={wi === activeWordIdx}
|
||||
mode={karaokeMode}
|
||||
popScale={popScale}
|
||||
snapMs={popSnap}
|
||||
effects={wordEffects}
|
||||
/>
|
||||
)
|
||||
})
|
||||
@@ -1407,6 +1645,9 @@ export default function LyricsLivePreview({ lrcText, audioUrl, stems, title, sty
|
||||
elRef={wi === activeWordIdx ? activeWordSpanRef : undefined}
|
||||
isActive={wi === activeWordIdx}
|
||||
mode={karaokeMode}
|
||||
popScale={popScale}
|
||||
snapMs={popSnap}
|
||||
effects={wordEffects}
|
||||
/>
|
||||
)
|
||||
})
|
||||
@@ -1512,6 +1753,9 @@ export default function LyricsLivePreview({ lrcText, audioUrl, stems, title, sty
|
||||
elRef={wi === activeWordIdx ? activeWordSpanRef : undefined}
|
||||
isActive={wi === activeWordIdx}
|
||||
mode={karaokeMode}
|
||||
popScale={popScale}
|
||||
snapMs={popSnap}
|
||||
effects={wordEffects}
|
||||
/>
|
||||
)
|
||||
})
|
||||
@@ -1564,11 +1808,20 @@ export default function LyricsLivePreview({ lrcText, audioUrl, stems, title, sty
|
||||
flex: isFullscreen ? '1 1 0' : undefined,
|
||||
overflow: 'hidden',
|
||||
position: 'relative',
|
||||
}}
|
||||
textShadow: shadowEnabled
|
||||
? `${shadowX}px ${shadowY}px ${shadowBlur}px ${hexToRgba(shadowColor, shadowOpacity)}`
|
||||
: undefined,
|
||||
WebkitTextStroke: (strokeEnabled && strokeWidth > 0)
|
||||
? `${strokeWidth}px ${strokeColor}`
|
||||
: undefined,
|
||||
paintOrder: (strokeEnabled && strokeWidth > 0) ? 'stroke fill' : undefined,
|
||||
strokeLinejoin: (strokeEnabled && strokeWidth > 0) ? 'round' : undefined,
|
||||
strokeLinecap: (strokeEnabled && strokeWidth > 0) ? 'round' : undefined,
|
||||
} as any}
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
transform: `translateY(${translateY}px)`,
|
||||
transform: `translateY(${translateY}px) scaleX(${scaleX}) scaleY(${scaleY})`,
|
||||
transition: 'transform 0.35s cubic-bezier(0.33, 1, 0.68, 1)',
|
||||
willChange: 'transform',
|
||||
textAlign,
|
||||
@@ -1585,7 +1838,7 @@ export default function LyricsLivePreview({ lrcText, audioUrl, stems, title, sty
|
||||
{!isFullscreen && coverArtUrl && artLoaded && (
|
||||
<div style={{
|
||||
position: 'absolute', top: 8, left: 8, zIndex: 10,
|
||||
display: 'flex', flexDirection: 'column', alignItems: 'flex-start', gap: 3,
|
||||
display: 'flex', flexDirection: 'row', alignItems: 'center', gap: 8,
|
||||
background: 'linear-gradient(135deg, rgba(0,0,0,0.55) 0%, transparent 100%)',
|
||||
padding: '6px 14px 6px 6px',
|
||||
borderRadius: 8,
|
||||
@@ -1597,7 +1850,7 @@ export default function LyricsLivePreview({ lrcText, audioUrl, stems, title, sty
|
||||
style={{ width: 48, height: 48, objectFit: 'cover', borderRadius: 6, flexShrink: 0 }}
|
||||
/>
|
||||
{(artist || title) && (
|
||||
<div style={{ maxWidth: 120, overflow: 'hidden' }}>
|
||||
<div style={{ maxWidth: 120, overflow: 'hidden', fontFamily, WebkitTextStroke: 'initial', textShadow: 'none' } as any}>
|
||||
{artist && (
|
||||
<p style={{ margin: 0, fontSize: 10, color: '#cbd5e1', fontWeight: 600, lineHeight: 1.3,
|
||||
overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>
|
||||
@@ -1754,7 +2007,7 @@ export default function LyricsLivePreview({ lrcText, audioUrl, stems, title, sty
|
||||
? 'flex flex-col'
|
||||
: 'rounded-xl overflow-hidden border border-slate-200/30 dark:border-gray-700/50'
|
||||
}
|
||||
style={isFullscreen ? { backgroundColor: effectiveBg } : undefined}
|
||||
style={undefined}
|
||||
>
|
||||
{/* Visual style tabs + toolbar — scrollable on narrow screens */}
|
||||
<div className={`flex items-center gap-1 px-2 py-1 border-b overflow-x-auto [&::-webkit-scrollbar]:hidden ${isFullscreen ? 'bg-black/40 border-white/10' : 'bg-slate-100/80 dark:bg-gray-800/80 border-slate-200/30 dark:border-gray-700/50'}`}>
|
||||
@@ -1810,7 +2063,7 @@ export default function LyricsLivePreview({ lrcText, audioUrl, stems, title, sty
|
||||
{/* Style picker panel */}
|
||||
{showStylePicker && (
|
||||
<div className={isFullscreen ? 'bg-black/50' : 'bg-slate-100/80 dark:bg-gray-800/80'}>
|
||||
<StylePicker style={style} onChange={patchStyle} hasCoverArt={!!coverArtUrl && artLoaded} />
|
||||
<StylePicker style={style} onChange={patchStyle} onReset={resetStyle} hasCoverArt={!!coverArtUrl && artLoaded} />
|
||||
{/* Speaker colour swatches — always shown so user knows if diarization is missing */}
|
||||
<div className="px-3 py-2 border-b border-white/10 flex items-center gap-3 flex-wrap">
|
||||
<span className="text-[10px] text-slate-500 shrink-0">Speakers</span>
|
||||
@@ -1915,7 +2168,7 @@ export default function LyricsLivePreview({ lrcText, audioUrl, stems, title, sty
|
||||
}}
|
||||
onError={e => { (e.currentTarget as HTMLImageElement).style.display = 'none' }}
|
||||
/>
|
||||
<div style={{ textAlign: isNarrow ? 'left' : 'center', maxWidth: '100%', minWidth: 0 }}>
|
||||
<div style={{ textAlign: isNarrow ? 'left' : 'center', maxWidth: '100%', minWidth: 0, fontFamily, WebkitTextStroke: 'initial', textShadow: 'none' } as any}>
|
||||
{artist && (
|
||||
<p style={{ margin: isNarrow ? 0 : '0 0 4px 0', fontSize: isNarrow ? 13 : 16,
|
||||
color: '#e2e8f0', fontWeight: 700, lineHeight: 1.3,
|
||||
@@ -1925,7 +2178,7 @@ export default function LyricsLivePreview({ lrcText, audioUrl, stems, title, sty
|
||||
)}
|
||||
{(songTitle ?? title) && (
|
||||
<p style={{ margin: 0, fontSize: isNarrow ? 11 : 13, color: '#94a3b8',
|
||||
lineHeight: 1.3, wordBreak: 'break-word', whiteSpace: 'nowrap',
|
||||
fontWeight: fontBold ? 700 : 400, lineHeight: 1.3, wordBreak: 'break-word', whiteSpace: 'nowrap',
|
||||
overflow: 'hidden', textOverflow: 'ellipsis' }}>
|
||||
{songTitle ?? title}
|
||||
</p>
|
||||
|
||||
Reference in new issue
Block a user