SPB Git forge
28commits 1branches 0releases
7.7 MBsize
maindefault branch
10 days agolast push
Python 66.3% TypeScript 22.7% JavaScript 8.6% HTML 1.4% CSS 0.7%
958 B · 14 lines typescript
Raw Blame History
1/**2 * Inline scripts run in <head> before paint (server-safe module: no 'use client', so the root layout can embed the strings).3 * They apply the persisted theme and density to <html> so the first frame is right. Keys are shared with4 * `components/layout/theme.tsx` and `components/layout/density.tsx`.5 */6export const THEME_KEY = 'ca-theme';7export const DENSITY_KEY = 'ca-density';89export const THEME_SCRIPT = `(function(){try{var k='${THEME_KEY}',p=localStorage.getItem(k),m=window.matchMedia('(prefers-color-scheme: dark)'),t=(p==='light'||p==='dark')?p:(m.matches?'dark':'light');document.documentElement.setAttribute('data-theme',t);document.documentElement.style.colorScheme=t;}catch(e){}})();`;1011export const DENSITY_SCRIPT = `(function(){try{var d=localStorage.getItem('${DENSITY_KEY}');if(d==='compact'){document.documentElement.setAttribute('data-density',d);}}catch(e){}})();`;1213export const PREPAINT_SCRIPT = THEME_SCRIPT + DENSITY_SCRIPT;14