Files
otunes/apps/mobile/lib/now-playing-colors.ts
T
joshuafhigginsandClaude Opus 5.5 Verified 55de91084c fix(mobile): fill lyrics as smoothly as web
The mobile fill restarted on every progress update and word boundary, so it
hitched; it had a hard edge, re-wrapped the playing line, and line changes
snapped. A UI-thread clock now drives fills and resets only on drift, words
fill through a gradient mask like web, lines always lay out word by word,
and opacity and blur fade between lines.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 15:52:22 -05:00

44 lines
1.3 KiB
TypeScript

import type { CoverPalette } from "@/lib/cover-palette"
/** Now Playing colors: the cover palette plus translucent tints of its text color. */
export type NowPlayingColors = {
background: string
foreground: string
secondaryForeground: string
sliderTrack: string
sliderFill: string
control: string
controlPressed: string
selected: string
selectedForeground: string
highlight: string
/** Words of the playing line not yet sung. */
lyricsUnsung: string
isDark: boolean
}
export function nowPlayingColors(palette: CoverPalette): NowPlayingColors {
const { foreground } = palette
return {
background: palette.background,
foreground,
secondaryForeground: palette.secondaryForeground,
sliderTrack: withAlpha(foreground, 0.2),
sliderFill: withAlpha(foreground, 0.6),
control: withAlpha(foreground, 0.14),
controlPressed: withAlpha(foreground, 0.1),
selected: withAlpha(foreground, 0.8),
selectedForeground: palette.background,
highlight: withAlpha(foreground, 0.1),
lyricsUnsung: withAlpha(foreground, 0.55),
isDark: palette.isDark,
}
}
function withAlpha(color: string, alpha: number) {
const match = /^#([0-9a-f]{6})$/i.exec(color.trim())
if (!match) return color
const value = parseInt(match[1], 16)
return `rgba(${(value >> 16) & 255}, ${(value >> 8) & 255}, ${value & 255}, ${alpha})`
}