react18-themes
Version:
Unleash the Power of React Server Components! Use multiple themes on your site with confidence, without losing any advantages of React Server Components.
2 lines (1 loc) • 685 B
JavaScript
var w=(h,s,T,g,S)=>{window.m=matchMedia("(prefers-color-scheme: dark)");let v=["color-scheme","csp","theme","th"];window.u=e=>{var a;let o=(a=document.querySelector(h))!=null?a:document.documentElement,t=[];v.forEach((p,d)=>{t.push(`${p}-${e[d]}`),o.setAttribute(`data-${p}`,e[d])}),t[0]=e[0],T&&(t=t.map(p=>{var d;return(d=T[p])!=null?d:p})),o.className=t.join(" ")};let i=localStorage.getItem(h),F={...i?JSON.parse(i):s,s:m.matches?s.d:s.l},n,c,l,y;window.f=(e,o)=>{c=y=e,n=l=o},window.g=(e,o)=>{c=y!=null?y:e,n=l!=null?l:o},f(g,S),window.r=e=>{let o=n!=null?n:e.c,t=o===s.c?e.s:o,a=t===""?e.t:t===s.d?e.d:e.l,p=c!=null?c:a;return[t||e.s,o,p,c!=null?c:e.t]},u(r(F))};export{w as a};