diff --git a/js/lyrics.js b/js/lyrics.js index c3b0125..922b2eb 100644 --- a/js/lyrics.js +++ b/js/lyrics.js @@ -926,6 +926,29 @@ export function openLyricsPanel(track, audioPlayer, lyricsManager, forceOpen = f sidePanelManager.open('lyrics', 'Lyrics', renderControls, renderContent, forceOpen); } +function getLyricsHighlightColor() { + // Check if the current theme is light + const isLight = getComputedStyle(document.documentElement).colorScheme === 'light'; + return isLight ? '#000' : '#fff'; +} + +function updateLyricsTheme() { + const highlightColor = getLyricsHighlightColor(); + document.querySelectorAll('am-lyrics').forEach((el) => { + el.setAttribute('highlight-color', highlightColor); + }); +} + +// watch for theme changes +const themeObserver = new MutationObserver(() => { + updateLyricsTheme(); +}); + +themeObserver.observe(document.documentElement, { + attributes: true, + attributeFilter: ['data-theme', 'style'], +}); + async function renderLyricsComponent(container, track, audioPlayer, lyricsManager) { container.innerHTML = '
Loading lyrics...
'; @@ -951,7 +974,7 @@ async function renderLyricsComponent(container, track, audioPlayer, lyricsManage amLyrics.setAttribute('query', `${title} ${artist}`.trim()); if (isrc) amLyrics.setAttribute('isrc', isrc); - amLyrics.setAttribute('highlight-color', '#93c5fd'); + amLyrics.setAttribute('highlight-color', getLyricsHighlightColor()); amLyrics.setAttribute('hover-background-color', 'rgba(59, 130, 246, 0.14)'); amLyrics.setAttribute('autoscroll', ''); amLyrics.setAttribute('interpolate', ''); @@ -960,8 +983,6 @@ async function renderLyricsComponent(container, track, audioPlayer, lyricsManage container.appendChild(amLyrics); - // Setup observer IMMEDIATELY to catch lyrics as they load (not after waiting) - // This is critical - observer must be running before lyrics arrive from LRCLIB lyricsManager.setupLyricsObserver(amLyrics); // If Romaji mode is enabled and track has Asian text, ensure Kuroshiro is ready diff --git a/package-lock.json b/package-lock.json index 2152da2..088afe7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -81,6 +81,7 @@ "integrity": "sha512-e7jT4DxYvIDLk1ZHmU/m/mB19rex9sv0c2ftBtjSBv+kVM/902eh0fINUzD7UwLLNR+jU585GxUJ8/EBfAM5fw==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@babel/code-frame": "^7.27.1", "@babel/generator": "^7.28.5", @@ -1609,6 +1610,7 @@ "integrity": "sha512-FA5LmZVF1VziNc0bIdCSA1IoSVnDCqE8HJIZZv2/W8YmoAM50+tnUgJR/gQZwEeIMleuIOnRnHA/UaZRNeV4iQ==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@keyv/serialize": "^1.1.1" } @@ -1650,6 +1652,7 @@ } ], "license": "MIT", + "peer": true, "engines": { "node": ">=18" }, @@ -1693,6 +1696,7 @@ } ], "license": "MIT", + "peer": true, "engines": { "node": ">=18" } @@ -3270,6 +3274,7 @@ "resolved": "https://registry.npmjs.org/@svta/cml-xml/-/cml-xml-1.0.1.tgz", "integrity": "sha512-11LkJa5kDEcsRMWkVI1ABH3KLCxGoiSVe4kQ293ItVj8ncTTQ7htmCGiJDjS+Cmy35UgF3e/vc0ysJIiWRTx2g==", "license": "Apache-2.0", + "peer": true, "engines": { "node": ">=20" }, @@ -3318,6 +3323,7 @@ "integrity": "sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg==", "dev": true, "license": "MIT", + "peer": true, "bin": { "acorn": "bin/acorn" }, @@ -3341,6 +3347,7 @@ "integrity": "sha512-B/gBuNg5SiMTrPkC+A2+cW0RszwxYmn6VYxB/inlBStS5nx6xHIt/ehKRhIMhqusl7a8LjQoZnjCs5vhwxOQ1g==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "fast-deep-equal": "^3.1.3", "fast-uri": "^3.0.1", @@ -3638,6 +3645,7 @@ } ], "license": "MIT", + "peer": true, "dependencies": { "baseline-browser-mapping": "^2.9.0", "caniuse-lite": "^1.0.30001759", @@ -4675,6 +4683,7 @@ "integrity": "sha512-LEyamqS7W5HB3ujJyvi0HQK/dtVINZvd5mAAp9eT5S/ujByGjiZLCzPcHVzuXbpJDJF/cxwHlfceVUDZ2lnSTw==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@eslint-community/eslint-utils": "^4.8.0", "@eslint-community/regexpp": "^4.12.1", @@ -7296,6 +7305,7 @@ } ], "license": "MIT", + "peer": true, "dependencies": { "nanoid": "^3.3.11", "picocolors": "^1.1.1", @@ -7379,6 +7389,7 @@ "integrity": "sha512-orRsuYpJVw8LdAwqqLykBj9ecS5/cRHlI5+nvTo8LcCKmzDmqVORXtOIYEEQuL9D4BxtA1lm5isAqzQZCoQ6Eg==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "cssesc": "^3.0.0", "util-deprecate": "^1.0.2" @@ -8484,6 +8495,7 @@ } ], "license": "MIT", + "peer": true, "dependencies": { "@csstools/css-parser-algorithms": "^3.0.5", "@csstools/css-syntax-patches-for-csstree": "^1.0.19", @@ -8934,6 +8946,7 @@ "integrity": "sha512-t/R3R/n0MSwnnazuPpPNVO60LX0SKL45pyl9YlvxIdkH0Of7D5qM2EVe+yASRIlY5pZ73nclYJfNANGWPwFDZw==", "dev": true, "license": "BSD-2-Clause", + "peer": true, "dependencies": { "@jridgewell/source-map": "^0.3.3", "acorn": "^8.15.0", @@ -9308,6 +9321,7 @@ "integrity": "sha512-dZwN5L1VlUBewiP6H9s2+B3e3Jg96D0vzN+Ry73sOefebhYr9f94wwkMNN/9ouoU8pV1BqA1d1zGk8928cx0rg==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "esbuild": "^0.27.0", "fdir": "^6.5.0", @@ -9744,6 +9758,7 @@ "integrity": "sha512-fS6iqSPZDs3dr/y7Od6y5nha8dW1YnbgtsyotCVvoFGKbERG++CVRFv1meyGDE1SNItQA8BrnCw7ScdAhRJ3XQ==", "dev": true, "license": "MIT", + "peer": true, "bin": { "rollup": "dist/bin/rollup" },