Merge pull request #1581 from PR0M3TH3AN/fix-nip46-qr-code-styling-4704153916823307034

Fix NIP-46 QR code styling
This commit is contained in:
thePR0M3TH3AN authored and GitHub committed 2026-01-23 09:56:24 -05:00
commit b939f0fe2f
2 files changed
+18 -22

No files matched your search

+1 -1
View File
@@ -348,7 +348,7 @@
<div data-nip46-handshake-panel class="space-y-6">
<div class="flex flex-col items-center gap-6">
<div
class="flex aspect-square w-full max-w-xs items-center justify-center rounded-2xl border border-border-strong bg-white p-4 shadow-sm"
class="flex aspect-square w-full max-w-xs items-center justify-center rounded-2xl border border-border-strong bg-white text-black p-6 shadow-sm"
data-nip46-qr
aria-hidden="true"
>
+17 -21
View File
@@ -1297,28 +1297,24 @@ export default class LoginModalController {
if (qrContainer instanceof HTMLElement) {
qrContainer.innerHTML = "";
const resolveTokenColor = (tokenName, fallback) => {
if (!tokenName) {
return fallback;
// Force high-contrast black-on-white for the QR code to ensure
// it remains readable and scannable regardless of the application theme.
// We resolve these from the unified token system to ensure consistency.
let qrLightColor = "#ffffff";
let qrDarkColor = "#000000";
if (this.window && typeof this.window.getComputedStyle === "function") {
try {
const style = this.window.getComputedStyle(this.document.documentElement);
const white = style.getPropertyValue("--color-white").trim();
const black = style.getPropertyValue("--color-black").trim();
if (white) qrLightColor = white;
if (black) qrDarkColor = black;
} catch (error) {
// Fallback to hardcoded values if style resolution fails
}
const doc = this.document;
const win = this.window;
if (!doc || !win || typeof win.getComputedStyle !== "function") {
return fallback;
}
const root = doc.documentElement;
if (!root) {
return fallback;
}
const computed = win.getComputedStyle(root);
if (!computed) {
return fallback;
}
const value = computed.getPropertyValue(tokenName);
return value && value.trim() ? value.trim() : fallback;
};
const qrLightColor = resolveTokenColor("--color-white", "#ffffff");
const qrDarkColor = resolveTokenColor("--color-black", "#000000");
}
if (uri) {
try {
qrInstance = renderQrCode(qrContainer, uri, {