mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-11-01 18:32:27 +00:00
Ensure NIP-46 QR code renders on white background
This commit is contained in:
1 parent
a0d4c86ab4
commit
e3c7b93d1e
3 files changed
+39
-10
No files matched your search
@@ -930,11 +930,35 @@ export default class LoginModalController {
|
||||
}
|
||||
if (qrContainer instanceof HTMLElement) {
|
||||
qrContainer.innerHTML = "";
|
||||
const resolveTokenColor = (tokenName, fallback) => {
|
||||
if (!tokenName) {
|
||||
return fallback;
|
||||
}
|
||||
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, {
|
||||
width: 224,
|
||||
height: 224,
|
||||
width: 256,
|
||||
height: 256,
|
||||
colorLight: qrLightColor,
|
||||
colorDark: qrDarkColor,
|
||||
});
|
||||
} catch (error) {
|
||||
qrInstance = null;
|
||||
|
||||
Reference in new issue
Block a user