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) • 774 B
JavaScript
import{b as y,c as T}from"./chunk-XDBZ6FPN.mjs";import{a as h,b as l,c as F}from"./chunk-2YWS4AKP.mjs";var c,D,S,o,U=(n="none")=>{let t=document.createElement("style");return t.textContent=`transition:${n.split(";")[0]}!important;`,document.head.appendChild(t),()=>{getComputedStyle(document.body),setTimeout(()=>document.head.removeChild(t),1)}},P=({forcedTheme:n,forcedColorScheme:t,targetSelector:i,themeTransition:v})=>{let s=i||"#"+h,[d,a]=T(i);if(typeof m!=y&&!o&&([c,D,S,o]=[m,u,r,f],c.addEventListener("change",()=>a(e=>({...e,s:c.matches?F:l}))),addEventListener("storage",e=>{e.key===s&&a(p=>({...p,...JSON.parse(e.newValue||"{}")}))})),o){o(n,t);let e=U(v);D(S(d),s),e();let{f:p,fc:w,...E}=d;localStorage.setItem(s,JSON.stringify(E))}return null};export{P as a};