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) • 747 B
JavaScript
import{b as n,c as S}from"./chunk-XDBZ6FPN.mjs";import{b as T,c as d,d as l}from"./chunk-2YWS4AKP.mjs";var c=[l,d,T],s,f=g=>{let[e,i]=S(g);!s&&typeof window!=n&&(s=window.r);let t=o=>r=>i(m=>({...m,[o]:r})),h={theme:e.t,darkTheme:e.d,lightTheme:e.l,colorSchemePref:e.c,systemColorScheme:e.s,resolvedColorScheme:e.c===l||e.c===""?e.s:e.c,resolvedTheme:e.t,setTheme:t("t"),setDarkTheme:t("d"),setLightTheme:t("l"),setThemeSet:({darkTheme:o,lightTheme:r})=>i(m=>({...m,d:o,l:r})),setColorSchemePref:t("c"),toggleColorScheme(o){let r=c.indexOf(e.c),m=c.length;(r===-1||o&&r===m-1)&&(r=0),t("c")(c[(r+1)%m])},setForcedColorScheme:t("fc"),setForcedTheme:t("f")};if(s){let o=s(e);h.resolvedColorScheme=o[0],h.resolvedTheme=o[1]}return h};export{f as a};