nextjs-darkmode-lite
Version:
Unleash the Power of React Server Components! Use dark/light mode on your site with confidence, without losing any advantages of React Server Components
3 lines (2 loc) • 1.19 kB
JavaScript
"use client";
;var c=Object.defineProperty;var w=Object.getOwnPropertyDescriptor;var _=Object.getOwnPropertyNames;var b=Object.prototype.hasOwnProperty;var v=(e,t)=>{for(var r in t)c(e,r,{get:t[r],enumerable:!0})},g=(e,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of _(t))!b.call(e,o)&&o!==r&&c(e,o,{get:()=>t[o],enumerable:!(s=w(t,o))||s.enumerable});return e};var k=e=>g(c({},"__esModule",{value:!0}),e);var R={};v(R,{Switch:()=>C});module.exports=k(R);var p={switch:"ndm__switch",n:"ndm__n"};var f=require("r18gs");var n="system",a="dark",z="",i=[a,z,n];var h=()=>(0,f.useRGS)("ndm",()=>{if(typeof document=="undefined")return{m:n,s:a};let[e,t]=["m","sm"].map(r=>document.documentElement.getAttribute("data-"+r));return{m:e!=null?e:n,s:t}});var m=require("react/jsx-runtime"),C=({tag:e="button",size:t=24,skipSystem:r,children:s,...o})=>{let[{m:u,s:S},x]=h(),y=i.length-(r?1:0);o.onClick=()=>x({s:S,m:i[(i.indexOf(u)+1)%y]});let d=p.switch,l={"--size":`${t}px`};return s||(o.className+=" "+d,o.style={...o.style,...l}),(0,m.jsxs)(e,{suppressHydrationWarning:!0,...o,children:[s&&(0,m.jsx)("div",{className:d,style:l}),s]})};0&&(module.exports={Switch});