ai-research-survey

Systematic scan of agentic development research. What's signal, what's noise.
git clone https://git.shiptheloop.com/ai-research-survey.git
Log | Files | Refs

theme.ts (831B)


      1 const STORAGE_KEY = 'theme';
      2 
      3 export function initTheme() {
      4   const saved = localStorage.getItem(STORAGE_KEY);
      5   const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
      6   const theme = saved || (prefersDark ? 'dark' : 'light');
      7   applyTheme(theme);
      8 
      9   const btn = document.getElementById('theme-toggle');
     10   if (btn) {
     11     btn.addEventListener('click', () => {
     12       const current = document.documentElement.getAttribute('data-theme') || 'dark';
     13       const next = current === 'dark' ? 'light' : 'dark';
     14       applyTheme(next);
     15       localStorage.setItem(STORAGE_KEY, next);
     16     });
     17   }
     18 }
     19 
     20 function applyTheme(theme: string) {
     21   document.documentElement.setAttribute('data-theme', theme);
     22   const btn = document.getElementById('theme-toggle');
     23   if (btn) btn.textContent = theme === 'dark' ? '☀' : '☾';
     24 }

Impressum · Datenschutz