Fixeds QR flashing
All checks were successful
Ascently - Docs Deploy / build-and-push (push) Successful in 3m49s

This commit is contained in:
2025-10-21 08:50:34 -06:00
parent 862622b07b
commit fed9bab2ea

View File

@@ -46,7 +46,6 @@ const uniqueId = `qr-${Math.random().toString(36).substr(2, 9)}`;
(darkModeQR || lightModeQR) && ( (darkModeQR || lightModeQR) && (
<img <img
id={uniqueId} id={uniqueId}
src={lightModeQR}
alt={alt} alt={alt}
width={size} width={size}
height={size} height={size}
@@ -57,6 +56,20 @@ const uniqueId = `qr-${Math.random().toString(36).substr(2, 9)}`;
) )
} }
<script is:inline define:vars={{ uniqueId, lightModeQR, darkModeQR }}>
(function () {
const img = document.getElementById(uniqueId);
if (!img) return;
const theme = document.documentElement.getAttribute("data-theme");
if (theme === "dark" && darkModeQR) {
img.setAttribute("src", darkModeQR);
} else if (lightModeQR) {
img.setAttribute("src", lightModeQR);
}
})();
</script>
<script> <script>
function updateQRCodes() { function updateQRCodes() {
const theme = document.documentElement.getAttribute("data-theme"); const theme = document.documentElement.getAttribute("data-theme");
@@ -76,8 +89,10 @@ const uniqueId = `qr-${Math.random().toString(36).substr(2, 9)}`;
}); });
} }
// Set initial theme on page load
updateQRCodes(); updateQRCodes();
// Watch for theme changes
const observer = new MutationObserver((mutations) => { const observer = new MutationObserver((mutations) => {
mutations.forEach((mutation) => { mutations.forEach((mutation) => {
if ( if (