nextjs-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) • 672 B
JavaScript
var w=(T,p,a,S,v)=>{window.m=matchMedia("(prefers-color-scheme: dark)");let C=["color-scheme","csp","theme","th"];window.u=(e,t)=>{var h;let c=(h=document.querySelector(t))!=null?h:document.documentElement,n=[];C.forEach((d,l)=>{n.push(d+"-"+e[l]),c.setAttribute("data-"+d,e[l])}),n[0]=e[0],a&&(n=n.map(d=>{var l;return(l=a[d])!=null?l:d})),c.className=n.join(" ")};let g=localStorage.getItem(T),F={...g?JSON.parse(g):p,s:m.matches?p.d:p.l},s,o,y,i;window.f=(e,t)=>{o=i=e,s=y=t},f(S,v),window.r=e=>{o=i!=null?i:e.f,s=y!=null?y:e.fc;let t=s!=null?s:e.c,c=t===p.c?e.s:t,n=c===""?e.t:c===p.d?e.d:e.l,h=o!=null?o:n;return[c||e.s,t,h,o!=null?o:e.t]},u(r(F),T)};export{w as a};