feat(machine): operator branding — optional logo-dark.png variant

Sibling-file convention: drop a logo-dark.png alongside logo.png in
/var/lib/bitspire/branding/ and the renderer uses it whenever the
effective color mode is dark, falling back to logo.png when absent.
No branding.json change — the file name itself is the contract.

Wiring:
- electron/main.ts:loadBranding() reads logo-dark.png and base64-encodes
  it into logoDarkDataUrl on the IPC payload
- composables/useTheme.ts exposes an `isDark` computed that resolves
  the 'system' colorMode via the prefers-color-scheme media query (and
  reacts to OS-level dark-mode changes via the existing listener)
- composables/useBranding.ts switches logoUrl reactively based on isDark
- IdleView already binds to logoUrl — no template change needed

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Padreug 2026-05-25 15:01:55 +02:00
commit b6169da45d
6 changed files with 57 additions and 14 deletions

View file

@ -60,16 +60,20 @@ function loadEnvFile() {
loadEnvFile()
// Branding loader — reads /var/lib/bitspire/branding/{logo.png,branding.json}
// and surfaces them on get-config. Per issue #47: local-file is the V1
// source; V2 will overlay a higher-priority Nostr-event source from
// satmachineadmin (issue #48). Renderer applies via useBranding().
// Branding loader — reads /var/lib/bitspire/branding/{logo.png,
// logo-dark.png,branding.json} and surfaces them on get-config. Per
// issue #47: local-file is the V1 source; V2 will overlay a
// higher-priority Nostr-event source from satmachineadmin (issue #48).
// Renderer applies via useBranding().
type BrandingConfig = {
title: string | null
theme: string | null
customColors?: Record<string, string>
customColorsDark?: Record<string, string>
logoDataUrl: string | null
/** Optional dark-mode logo variant. Renderer falls back to logoDataUrl
* when null. */
logoDarkDataUrl: string | null
}
const VALID_THEMES = new Set([
@ -94,6 +98,7 @@ function loadBranding(): BrandingConfig | null {
let customColors: Record<string, string> | undefined
let customColorsDark: Record<string, string> | undefined
let logoDataUrl: string | null = null
let logoDarkDataUrl: string | null = null
const jsonPath = path.join(brandingDir, 'branding.json')
if (fs.existsSync(jsonPath)) {
@ -131,16 +136,27 @@ function loadBranding(): BrandingConfig | null {
}
}
const logoDarkPath = path.join(brandingDir, 'logo-dark.png')
if (fs.existsSync(logoDarkPath)) {
try {
const buf = fs.readFileSync(logoDarkPath)
logoDarkDataUrl = `data:image/png;base64,${buf.toString('base64')}`
} catch (e) {
console.warn('[Electron] Failed to read logo-dark.png:', e)
}
}
if (
title === null &&
theme === null &&
!customColors &&
!customColorsDark &&
logoDataUrl === null
logoDataUrl === null &&
logoDarkDataUrl === null
) {
return null
}
return { title, theme, customColors, customColorsDark, logoDataUrl }
return { title, theme, customColors, customColorsDark, logoDataUrl, logoDarkDataUrl }
}
// Determine if we're in development