18 lines
888 B
JavaScript
18 lines
888 B
JavaScript
/* Apply saved theme & accent before first paint to avoid a flash.
|
|
*
|
|
* This is the desktop build's copy of the inline snippet nuxt.config.ts puts
|
|
* in <head> for the web (keep the two in step). Out here as a file because a
|
|
* window may be held to a Content Security Policy — see src-tauri/README.md —
|
|
* and `script-src 'self'` would have no room for a script written inline in
|
|
* the HTML.
|
|
* A classic <script src> in <head> still runs before the page paints, so the
|
|
* surfaces arrive already the right way round. */
|
|
try {
|
|
var d = document.documentElement
|
|
var s = localStorage.getItem('mathew-theme')
|
|
var t = s || (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light')
|
|
d.setAttribute('data-theme', t)
|
|
var a = localStorage.getItem('mathew-accent')
|
|
if (a && a !== 'violet') d.setAttribute('data-accent', a)
|
|
} catch (e) {}
|