SPB Git forge

spb/ai-atlas

Public
41commits 1branches 0releases
4.6 MBsize
maindefault branch
12 days agolast push
HTML 77.2% TypeScript 10.5% Python 9.6% JavaScript 2.5%
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 `lib/density.ts`.5 */6export const THEME_KEY = 'aia-theme';7export const DENSITY_KEY = 'aia-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'||d==='dense'){document.documentElement.setAttribute('data-density',d);}}catch(e){}})();`;1213export const PREPAINT_SCRIPT = THEME_SCRIPT + DENSITY_SCRIPT;14