UNPKG

@jay-js/system

Version:

A powerful and flexible TypeScript library for UI, state management, lazy loading, routing and managing draggable elements in modern web applications.

13 lines (12 loc) 471 B
import { setTheme } from "./setTheme.js"; import { themeOptions } from "./themeDefineOptions.js"; export function initTheme() { let themeToSet = themeOptions.defaultTheme; const storedTheme = localStorage.getItem("theme"); if (storedTheme) { themeToSet = storedTheme; } else if (window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches) { themeToSet = themeOptions.defaultDarkTheme; } setTheme(themeToSet); }