Use semantic theme variables for QR code colors

- Add --qr and --qr-foreground CSS variables to theme
- Light mode: standard gruvbox bg/fg for high contrast
- Dark mode: warm cream background, easier on eyes
- QRCode component now uses bg-qr and text-qr-foreground classes
- Reads CSS variables for qrcode.vue library props

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Patrick Mulligan 2026-01-24 13:21:59 -05:00
commit 2356befbcf
2 changed files with 23 additions and 13 deletions

View file

@ -1,5 +1,5 @@
<script setup lang="ts"> <script setup lang="ts">
import { computed } from 'vue' import { computed, ref, onMounted } from 'vue'
import QrcodeVue from 'qrcode.vue' import QrcodeVue from 'qrcode.vue'
const props = defineProps<{ const props = defineProps<{
@ -9,17 +9,19 @@ const props = defineProps<{
const qrSize = computed(() => props.size ?? 200) const qrSize = computed(() => props.size ?? 200)
// Warm cream background - easier on eyes in dark mode // Read CSS variables for theme-aware colors
// Dark brown foreground - maintains high contrast for scanning const qrBackground = ref('#f5f0e6')
const qrBackground = '#f5f0e6' // Warm cream const qrForeground = ref('#3c3836')
const qrForeground = '#3c3836' // Gruvbox dark0_hard - ensures scanability
onMounted(() => {
const styles = getComputedStyle(document.documentElement)
qrBackground.value = styles.getPropertyValue('--qr').trim() || '#f5f0e6'
qrForeground.value = styles.getPropertyValue('--qr-foreground').trim() || '#3c3836'
})
</script> </script>
<template> <template>
<div <div class="flex flex-col items-center justify-center rounded-xl bg-qr p-5">
class="flex flex-col items-center justify-center rounded-xl p-5"
:style="{ backgroundColor: qrBackground }"
>
<QrcodeVue <QrcodeVue
:value="value" :value="value"
:size="qrSize" :size="qrSize"
@ -28,10 +30,7 @@ const qrForeground = '#3c3836' // Gruvbox dark0_hard - ensures scanability
:background="qrBackground" :background="qrBackground"
:foreground="qrForeground" :foreground="qrForeground"
/> />
<code <code class="mt-3 block max-w-full break-all px-2 text-center text-xs text-qr-foreground">
class="mt-3 block max-w-full break-all px-2 text-center text-xs"
:style="{ color: qrForeground }"
>
{{ value.slice(0, 32) }}... {{ value.slice(0, 32) }}...
</code> </code>
</div> </div>

View file

@ -33,6 +33,9 @@
--color-warning-foreground: var(--warning-foreground); --color-warning-foreground: var(--warning-foreground);
--color-bitcoin: var(--bitcoin); --color-bitcoin: var(--bitcoin);
--color-bitcoin-foreground: var(--bitcoin-foreground); --color-bitcoin-foreground: var(--bitcoin-foreground);
/* QR code colors - high contrast for scanning */
--color-qr: var(--qr);
--color-qr-foreground: var(--qr-foreground);
} }
/* /*
@ -70,6 +73,10 @@
--warning-foreground: #3c3836; --warning-foreground: #3c3836;
--bitcoin: #d65d0e; /* orange */ --bitcoin: #d65d0e; /* orange */
--bitcoin-foreground: #fbf1c7; --bitcoin-foreground: #fbf1c7;
/* QR code - high contrast for scanning */
--qr: #fbf1c7; /* bg0 - light background */
--qr-foreground: #282828; /* dark0 - dark modules */
} }
.dark { .dark {
@ -100,6 +107,10 @@
--warning-foreground: #282828; --warning-foreground: #282828;
--bitcoin: #fe8019; /* bright orange */ --bitcoin: #fe8019; /* bright orange */
--bitcoin-foreground: #282828; --bitcoin-foreground: #282828;
/* QR code - warm tones easier on eyes in dark environments */
--qr: #f5f0e6; /* warm cream - softer than pure white */
--qr-foreground: #3c3836; /* gruvbox fg - maintains contrast */
} }
@layer base { @layer base {