Address review: the SVG footer badge rendered too small, and the default hero should feature the Runic Gateway emblem rather than the moon. - Footer: drop powered-by.svg; render the emblem PNG beside a "Powered by Runic Gateway" label (left-justified, info text stays centered). - Default hero: brand.hero (and the client fallbacks) now default to the emblem PNG. The untouched default hero centers the square emblem behind the text as a medallion with a symmetric legibility overlay (per-layer background-size so the overlay stays full-bleed). BRAND_HERO still overrides. - Admin login / player shell / maintenance backgrounds center the emblem as a capped medallion instead of a cropped full-bleed cover. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XmHdsbnLzDMAVQkAoTQSBe
54 lines
1.6 KiB
JavaScript
54 lines
1.6 KiB
JavaScript
import { createContext, useContext, useEffect, useState, useCallback } from 'react'
|
|
import { api } from '../api/client.js'
|
|
|
|
const SiteContext = createContext(null)
|
|
|
|
// Public site settings + mode (always reachable, even during maintenance).
|
|
export function SiteProvider({ children }) {
|
|
const [settings, setSettings] = useState({})
|
|
const [loading, setLoading] = useState(true)
|
|
|
|
const refresh = useCallback(async () => {
|
|
try {
|
|
const data = await api.publicSettings()
|
|
setSettings(data || {})
|
|
} catch {
|
|
setSettings({})
|
|
} finally {
|
|
setLoading(false)
|
|
}
|
|
}, [])
|
|
|
|
useEffect(() => {
|
|
refresh()
|
|
}, [refresh])
|
|
|
|
const brand = settings.brand || {}
|
|
|
|
// Apply the instance accent color to the CSS variable the theme is built on,
|
|
// so branding flows to every `var(--accent)` at runtime (no rebuild).
|
|
useEffect(() => {
|
|
if (brand.accent) document.documentElement.style.setProperty('--accent', brand.accent)
|
|
}, [brand.accent])
|
|
|
|
const value = {
|
|
settings,
|
|
loading,
|
|
refresh,
|
|
brand,
|
|
mode: settings.site_mode || 'live',
|
|
siteTitle: brand.name || settings.site_title || 'Runic Gateway',
|
|
siteShortName: brand.shortName || brand.name || settings.site_title || 'Runic Gateway',
|
|
contactEmail: brand.contactEmail || settings.contact_email || '',
|
|
heroImage: brand.hero || '/assets/img/runic-emblem.png',
|
|
}
|
|
|
|
return <SiteContext.Provider value={value}>{children}</SiteContext.Provider>
|
|
}
|
|
|
|
export function useSite() {
|
|
const ctx = useContext(SiteContext)
|
|
if (!ctx) throw new Error('useSite must be used within SiteProvider')
|
|
return ctx
|
|
}
|