Fixeds QR flashing
All checks were successful
Ascently - Docs Deploy / build-and-push (push) Successful in 3m49s
All checks were successful
Ascently - Docs Deploy / build-and-push (push) Successful in 3m49s
This commit is contained in:
@@ -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 (
|
||||||
|
|||||||
Reference in New Issue
Block a user