@previewcn/devtools 0.1.0-alpha.5 → 0.1.0-alpha.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -8,5 +8,5 @@
8
8
  html, body, .font-sans {
9
9
  font-family: ${r} !important;
10
10
  }
11
- `;}function I(e){e.colorPreset!==null&&C(e.colorPreset),e.radius!==null&&b(e.radius),e.darkMode!==null&&w(e.darkMode),e.font!==null&&P(e.font);}function A(){let e=document.getElementById(L);e&&e.remove();let o=document.getElementById(R);o&&o.remove();let r=document.documentElement;r.style.removeProperty("--radius"),r.style.removeProperty("color-scheme"),r.classList.remove("light","dark");}var L,R,F=p(()=>{T();M();L="previewcn-devtools-theme-colors",R="previewcn-devtools-theme-font";});function ye(){if(typeof window>"u")return {};try{let e=localStorage.getItem(D);if(e)return JSON.parse(e)}catch{}return {}}function S(e){if(!(typeof window>"u"))try{localStorage.setItem(D,JSON.stringify(e));}catch{}}function K(){let[e,o]=react.useState(()=>({...G,...ye()})),r=react.useCallback(i=>{o(d=>{let s={...d,colorPreset:i};return S(s),s}),C(i);},[]),n=react.useCallback(i=>{o(d=>{let s={...d,radius:i};return S(s),s}),b(i);},[]),c=react.useCallback(i=>{o(d=>{let s={...d,darkMode:i};return S(s),s}),w(i);},[]),m=react.useCallback(i=>{o(d=>{let s={...d,font:i};return S(s),s}),P(i);},[]),a=react.useCallback(()=>{typeof window<"u"&&localStorage.removeItem(D),A(),o(G);},[]);return {config:e,setColorPreset:r,setRadius:n,setDarkMode:c,setFont:m,resetTheme:a}}var D,G,j=p(()=>{"use client";F();D="previewcn-devtools-theme";G={colorPreset:null,radius:null,darkMode:null,font:null};});function X({value:e,onChange:o}){return jsxRuntime.jsxs("div",{className:"previewcn-section",children:[jsxRuntime.jsx("label",{className:"previewcn-label",children:"Color"}),jsxRuntime.jsx("div",{className:"previewcn-color-grid",children:E.map(r=>{let n=e===r.name,c=r.colors.light.primary;return jsxRuntime.jsx("button",{onClick:()=>o(r.name),className:`previewcn-color-swatch ${n?"previewcn-color-swatch--selected":""}`,style:{backgroundColor:c},"aria-label":r.label,title:r.label},r.name)})})]})}var Z=p(()=>{"use client";T();});function Ce(){return jsxRuntime.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:"m6 9 6 6 6-6"})})}function q({value:e,onChange:o}){let[r,n]=react.useState(false),m=y.find(a=>a.value===e)?.label??"Select font...";return jsxRuntime.jsxs("div",{className:"previewcn-section",children:[jsxRuntime.jsx("label",{className:"previewcn-label",children:"Font"}),jsxRuntime.jsxs("div",{className:"previewcn-select-wrapper",children:[jsxRuntime.jsxs("button",{onClick:()=>n(!r),className:"previewcn-select-trigger","aria-expanded":r,children:[jsxRuntime.jsx("span",{children:m}),jsxRuntime.jsx(Ce,{})]}),r&&jsxRuntime.jsx("div",{className:"previewcn-select-dropdown",children:y.map(a=>jsxRuntime.jsx("button",{onClick:()=>{o(a.value),n(false);},className:`previewcn-select-option ${e===a.value?"previewcn-select-option--selected":""}`,children:a.label},a.value))})]})]})}var Q=p(()=>{"use client";M();});function Pe(){return jsxRuntime.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("circle",{cx:"12",cy:"12",r:"4"}),jsxRuntime.jsx("path",{d:"M12 2v2"}),jsxRuntime.jsx("path",{d:"M12 20v2"}),jsxRuntime.jsx("path",{d:"m4.93 4.93 1.41 1.41"}),jsxRuntime.jsx("path",{d:"m17.66 17.66 1.41 1.41"}),jsxRuntime.jsx("path",{d:"M2 12h2"}),jsxRuntime.jsx("path",{d:"M20 12h2"}),jsxRuntime.jsx("path",{d:"m6.34 17.66-1.41 1.41"}),jsxRuntime.jsx("path",{d:"m19.07 4.93-1.41 1.41"})]})}function Fe(){return jsxRuntime.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z"})})}function ee({value:e,onChange:o}){let r=e??false;return jsxRuntime.jsxs("div",{className:"previewcn-section",children:[jsxRuntime.jsx("label",{className:"previewcn-label",children:"Mode"}),jsxRuntime.jsxs("div",{className:"previewcn-mode-toggle",children:[jsxRuntime.jsxs("button",{onClick:()=>o(false),className:`previewcn-mode-btn ${r?"":"previewcn-mode-btn--selected"}`,"aria-label":"Light mode",children:[jsxRuntime.jsx(Pe,{}),jsxRuntime.jsx("span",{children:"Light"})]}),jsxRuntime.jsxs("button",{onClick:()=>o(true),className:`previewcn-mode-btn ${r?"previewcn-mode-btn--selected":""}`,"aria-label":"Dark mode",children:[jsxRuntime.jsx(Fe,{}),jsxRuntime.jsx("span",{children:"Dark"})]})]})]})}var oe=p(()=>{"use client";});var re,te=p(()=>{re=[{name:"none",label:"None",value:"0rem"},{name:"sm",label:"SM",value:"0.3rem"},{name:"md",label:"MD",value:"0.5rem"},{name:"lg",label:"LG",value:"0.625rem"},{name:"xl",label:"XL",value:"0.75rem"},{name:"full",label:"Full",value:"1rem"}];});function ne({value:e,onChange:o}){return jsxRuntime.jsxs("div",{className:"previewcn-section",children:[jsxRuntime.jsx("label",{className:"previewcn-label",children:"Radius"}),jsxRuntime.jsx("div",{className:"previewcn-radius-grid",children:re.map(r=>{let n=e===r.value;return jsxRuntime.jsxs("button",{onClick:()=>o(r.value),className:`previewcn-radius-btn ${n?"previewcn-radius-btn--selected":""}`,title:r.label,children:[jsxRuntime.jsx("span",{className:"previewcn-radius-preview",style:{borderRadius:r.value}}),jsxRuntime.jsx("span",{className:"previewcn-radius-label",children:r.label})]},r.name)})})]})}var ae=p(()=>{"use client";te();});var ce={};me(ce,{default:()=>se});function Ne(){return jsxRuntime.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("path",{d:"M18 6 6 18"}),jsxRuntime.jsx("path",{d:"m6 6 12 12"})]})}function Ee(){return jsxRuntime.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"}),jsxRuntime.jsx("path",{d:"M3 3v5h5"})]})}function se({onClose:e}){let{config:o,setColorPreset:r,setRadius:n,setDarkMode:c,setFont:m,resetTheme:a}=K(),i=react.useRef(false);react.useEffect(()=>{i.current||(i.current=true,I(o));},[o]);let d=react.useCallback(v=>{v.key==="Escape"&&e();},[e]);return react.useEffect(()=>(window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)),[d]),jsxRuntime.jsx("div",{className:"previewcn-backdrop",onClick:v=>{v.target===v.currentTarget&&e();},children:jsxRuntime.jsxs("div",{className:"previewcn-panel",children:[jsxRuntime.jsxs("div",{className:"previewcn-header",children:[jsxRuntime.jsxs("div",{className:"previewcn-title",children:[jsxRuntime.jsx("span",{className:"previewcn-logo",children:"PreviewCN"}),jsxRuntime.jsx("span",{className:"previewcn-badge",children:"DEV"})]}),jsxRuntime.jsx("button",{onClick:e,className:"previewcn-close-btn","aria-label":"Close",children:jsxRuntime.jsx(Ne,{})})]}),jsxRuntime.jsxs("div",{className:"previewcn-content",children:[jsxRuntime.jsx(X,{value:o.colorPreset,onChange:r}),jsxRuntime.jsx(ne,{value:o.radius,onChange:n}),jsxRuntime.jsx(q,{value:o.font,onChange:m}),jsxRuntime.jsx(ee,{value:o.darkMode,onChange:c})]}),jsxRuntime.jsx("div",{className:"previewcn-footer",children:jsxRuntime.jsxs("button",{onClick:a,className:"previewcn-reset-btn",children:[jsxRuntime.jsx(Ee,{}),jsxRuntime.jsx("span",{children:"Reset"})]})})]})})}var de=p(()=>{"use client";j();F();Z();Q();oe();ae();});function ue(){return jsxRuntime.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor"}),jsxRuntime.jsx("circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor"}),jsxRuntime.jsx("circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor"}),jsxRuntime.jsx("circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor"}),jsxRuntime.jsx("path",{d:"M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10c.926 0 1.648-.746 1.648-1.688 0-.437-.18-.835-.437-1.125-.29-.289-.438-.652-.438-1.125a1.64 1.64 0 0 1 1.668-1.668h1.996c3.051 0 5.555-2.503 5.555-5.555C21.965 6.012 17.461 2 12 2z"})]})}function $({onClick:e}){return jsxRuntime.jsx("button",{onClick:e,className:"previewcn-trigger","aria-label":"Open PreviewCN theme editor",title:"PreviewCN Theme Editor",children:jsxRuntime.jsx(ue,{})})}var Re=react.lazy(()=>Promise.resolve().then(()=>(de(),ce))),Ie=process.env.NODE_ENV==="development";function De(){let[e,o]=react.useState(false);return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx($,{onClick:()=>o(true)}),e&&jsxRuntime.jsx(react.Suspense,{fallback:null,children:jsxRuntime.jsx(Re,{onClose:()=>o(false)})})]})}function Oe(){return Ie?jsxRuntime.jsx(De,{}):null}F();
11
+ `;}function I(e){e.colorPreset!==null&&C(e.colorPreset),e.radius!==null&&b(e.radius),e.darkMode!==null&&w(e.darkMode),e.font!==null&&P(e.font);}function A(){let e=document.getElementById(L);e&&e.remove();let o=document.getElementById(R);o&&o.remove();let r=document.documentElement;r.style.removeProperty("--radius"),r.style.removeProperty("color-scheme"),r.classList.remove("light","dark");}var L,R,F=p(()=>{T();M();L="previewcn-devtools-theme-colors",R="previewcn-devtools-theme-font";});function ye(){if(typeof window>"u")return {};try{let e=localStorage.getItem(D);if(e)return JSON.parse(e)}catch{}return {}}function S(e){if(!(typeof window>"u"))try{localStorage.setItem(D,JSON.stringify(e));}catch{}}function K(){let[e,o]=react.useState(()=>({...G,...ye()})),r=react.useCallback(i=>{o(d=>{let s={...d,colorPreset:i};return S(s),s}),C(i);},[]),n=react.useCallback(i=>{o(d=>{let s={...d,radius:i};return S(s),s}),b(i);},[]),c=react.useCallback(i=>{o(d=>{let s={...d,darkMode:i};return S(s),s}),w(i);},[]),m=react.useCallback(i=>{o(d=>{let s={...d,font:i};return S(s),s}),P(i);},[]),a=react.useCallback(()=>{typeof window<"u"&&localStorage.removeItem(D),A(),o(G);},[]);return {config:e,setColorPreset:r,setRadius:n,setDarkMode:c,setFont:m,resetTheme:a}}var D,G,j=p(()=>{"use client";F();D="previewcn-devtools-theme";G={colorPreset:null,radius:null,darkMode:null,font:null};});function X({value:e,onChange:o}){return jsxRuntime.jsxs("div",{className:"previewcn-section",children:[jsxRuntime.jsx("label",{className:"previewcn-label",children:"Color"}),jsxRuntime.jsx("div",{className:"previewcn-color-grid",children:E.map(r=>{let n=e===r.name,c=r.colors.light.primary;return jsxRuntime.jsx("button",{onClick:()=>o(r.name),className:`previewcn-color-swatch ${n?"previewcn-color-swatch--selected":""}`,style:{backgroundColor:c},"aria-label":r.label,title:r.label},r.name)})})]})}var Z=p(()=>{"use client";T();});function Ce(){return jsxRuntime.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:"m6 9 6 6 6-6"})})}function q({value:e,onChange:o}){let[r,n]=react.useState(false),m=y.find(a=>a.value===e)?.label??"Select font...";return jsxRuntime.jsxs("div",{className:"previewcn-section",children:[jsxRuntime.jsx("label",{className:"previewcn-label",children:"Font"}),jsxRuntime.jsxs("div",{className:"previewcn-select-wrapper",children:[jsxRuntime.jsxs("button",{onClick:()=>n(!r),className:"previewcn-select-trigger","aria-expanded":r,children:[jsxRuntime.jsx("span",{children:m}),jsxRuntime.jsx(Ce,{})]}),r&&jsxRuntime.jsx("div",{className:"previewcn-select-dropdown",children:y.map(a=>jsxRuntime.jsx("button",{onClick:()=>{o(a.value),n(false);},className:`previewcn-select-option ${e===a.value?"previewcn-select-option--selected":""}`,children:a.label},a.value))})]})]})}var Q=p(()=>{"use client";M();});function Pe(){return jsxRuntime.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("circle",{cx:"12",cy:"12",r:"4"}),jsxRuntime.jsx("path",{d:"M12 2v2"}),jsxRuntime.jsx("path",{d:"M12 20v2"}),jsxRuntime.jsx("path",{d:"m4.93 4.93 1.41 1.41"}),jsxRuntime.jsx("path",{d:"m17.66 17.66 1.41 1.41"}),jsxRuntime.jsx("path",{d:"M2 12h2"}),jsxRuntime.jsx("path",{d:"M20 12h2"}),jsxRuntime.jsx("path",{d:"m6.34 17.66-1.41 1.41"}),jsxRuntime.jsx("path",{d:"m19.07 4.93-1.41 1.41"})]})}function Fe(){return jsxRuntime.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z"})})}function ee({value:e,onChange:o}){let r=e??false;return jsxRuntime.jsxs("div",{className:"previewcn-section",children:[jsxRuntime.jsx("label",{className:"previewcn-label",children:"Mode"}),jsxRuntime.jsxs("div",{className:"previewcn-mode-toggle",children:[jsxRuntime.jsxs("button",{onClick:()=>o(false),className:`previewcn-mode-btn ${r?"":"previewcn-mode-btn--selected"}`,"aria-label":"Light mode",children:[jsxRuntime.jsx(Pe,{}),jsxRuntime.jsx("span",{children:"Light"})]}),jsxRuntime.jsxs("button",{onClick:()=>o(true),className:`previewcn-mode-btn ${r?"previewcn-mode-btn--selected":""}`,"aria-label":"Dark mode",children:[jsxRuntime.jsx(Fe,{}),jsxRuntime.jsx("span",{children:"Dark"})]})]})]})}var oe=p(()=>{"use client";});var re,te=p(()=>{re=[{name:"none",label:"None",value:"0rem"},{name:"sm",label:"SM",value:"0.3rem"},{name:"md",label:"MD",value:"0.5rem"},{name:"lg",label:"LG",value:"0.625rem"},{name:"xl",label:"XL",value:"0.75rem"},{name:"full",label:"Full",value:"1rem"}];});function ne({value:e,onChange:o}){return jsxRuntime.jsxs("div",{className:"previewcn-section",children:[jsxRuntime.jsx("label",{className:"previewcn-label",children:"Radius"}),jsxRuntime.jsx("div",{className:"previewcn-radius-grid",children:re.map(r=>{let n=e===r.value;return jsxRuntime.jsxs("button",{onClick:()=>o(r.value),className:`previewcn-radius-btn ${n?"previewcn-radius-btn--selected":""}`,title:r.label,children:[jsxRuntime.jsx("span",{className:"previewcn-radius-preview",style:{borderRadius:r.value}}),jsxRuntime.jsx("span",{className:"previewcn-radius-label",children:r.label})]},r.name)})})]})}var ae=p(()=>{"use client";te();});var ce={};me(ce,{default:()=>se});function Ne(){return jsxRuntime.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("path",{d:"M18 6 6 18"}),jsxRuntime.jsx("path",{d:"m6 6 12 12"})]})}function Ee(){return jsxRuntime.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"}),jsxRuntime.jsx("path",{d:"M3 3v5h5"})]})}function se({onClose:e}){let{config:o,setColorPreset:r,setRadius:n,setDarkMode:c,setFont:m,resetTheme:a}=K(),i=react.useRef(false);react.useEffect(()=>{i.current||(i.current=true,I(o));},[o]);let d=react.useCallback(v=>{v.key==="Escape"&&e();},[e]);return react.useEffect(()=>(window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)),[d]),jsxRuntime.jsx("div",{className:"previewcn-backdrop",onClick:v=>{v.target===v.currentTarget&&e();},children:jsxRuntime.jsxs("div",{className:"previewcn-panel",children:[jsxRuntime.jsxs("div",{className:"previewcn-header",children:[jsxRuntime.jsxs("div",{className:"previewcn-title",children:[jsxRuntime.jsx("span",{className:"previewcn-logo",children:"PreviewCN"}),jsxRuntime.jsx("span",{className:"previewcn-badge",children:"DEV"})]}),jsxRuntime.jsx("button",{onClick:e,className:"previewcn-close-btn","aria-label":"Close",children:jsxRuntime.jsx(Ne,{})})]}),jsxRuntime.jsxs("div",{className:"previewcn-content",children:[jsxRuntime.jsx(X,{value:o.colorPreset,onChange:r}),jsxRuntime.jsx(ne,{value:o.radius,onChange:n}),jsxRuntime.jsx(q,{value:o.font,onChange:m}),jsxRuntime.jsx(ee,{value:o.darkMode,onChange:c})]}),jsxRuntime.jsx("div",{className:"previewcn-footer",children:jsxRuntime.jsxs("button",{onClick:a,className:"previewcn-reset-btn",children:[jsxRuntime.jsx(Ee,{}),jsxRuntime.jsx("span",{children:"Reset"})]})})]})})}var de=p(()=>{"use client";j();F();Z();Q();oe();ae();});function ue(){return jsxRuntime.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor"}),jsxRuntime.jsx("circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor"}),jsxRuntime.jsx("circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor"}),jsxRuntime.jsx("circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor"}),jsxRuntime.jsx("path",{d:"M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10c.926 0 1.648-.746 1.648-1.688 0-.437-.18-.835-.437-1.125-.29-.289-.438-.652-.438-1.125a1.64 1.64 0 0 1 1.668-1.668h1.996c3.051 0 5.555-2.503 5.555-5.555C21.965 6.012 17.461 2 12 2z"})]})}function $({onClick:e}){return jsxRuntime.jsx("button",{onClick:e,className:"previewcn-trigger","aria-label":"Open PreviewCN theme editor",title:"PreviewCN Theme Editor",children:jsxRuntime.jsx(ue,{})})}var Re=react.lazy(()=>Promise.resolve().then(()=>(de(),ce))),Ie=process.env.NODE_ENV==="development";function De(){let[e,o]=react.useState(false);return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[!e&&jsxRuntime.jsx($,{onClick:()=>o(true)}),e&&jsxRuntime.jsx(react.Suspense,{fallback:null,children:jsxRuntime.jsx(Re,{onClose:()=>o(false)})})]})}function Oe(){return Ie?jsxRuntime.jsx(De,{}):null}F();
12
12
  exports.PreviewcnDevtools=Oe;exports.applyColors=C;exports.applyDarkMode=w;exports.applyFont=P;exports.applyRadius=b;exports.applyTheme=I;
package/dist/index.js CHANGED
@@ -8,5 +8,5 @@ import {lazy,useRef,useEffect,useCallback,useState,Suspense}from'react';import {
8
8
  html, body, .font-sans {
9
9
  font-family: ${r} !important;
10
10
  }
11
- `;}function I(e){e.colorPreset!==null&&C(e.colorPreset),e.radius!==null&&b(e.radius),e.darkMode!==null&&w(e.darkMode),e.font!==null&&P(e.font);}function A(){let e=document.getElementById(L);e&&e.remove();let o=document.getElementById(R);o&&o.remove();let r=document.documentElement;r.style.removeProperty("--radius"),r.style.removeProperty("color-scheme"),r.classList.remove("light","dark");}var L,R,F=p(()=>{T();M();L="previewcn-devtools-theme-colors",R="previewcn-devtools-theme-font";});function ye(){if(typeof window>"u")return {};try{let e=localStorage.getItem(D);if(e)return JSON.parse(e)}catch{}return {}}function S(e){if(!(typeof window>"u"))try{localStorage.setItem(D,JSON.stringify(e));}catch{}}function K(){let[e,o]=useState(()=>({...G,...ye()})),r=useCallback(i=>{o(d=>{let s={...d,colorPreset:i};return S(s),s}),C(i);},[]),n=useCallback(i=>{o(d=>{let s={...d,radius:i};return S(s),s}),b(i);},[]),c=useCallback(i=>{o(d=>{let s={...d,darkMode:i};return S(s),s}),w(i);},[]),m=useCallback(i=>{o(d=>{let s={...d,font:i};return S(s),s}),P(i);},[]),a=useCallback(()=>{typeof window<"u"&&localStorage.removeItem(D),A(),o(G);},[]);return {config:e,setColorPreset:r,setRadius:n,setDarkMode:c,setFont:m,resetTheme:a}}var D,G,j=p(()=>{"use client";F();D="previewcn-devtools-theme";G={colorPreset:null,radius:null,darkMode:null,font:null};});function X({value:e,onChange:o}){return jsxs("div",{className:"previewcn-section",children:[jsx("label",{className:"previewcn-label",children:"Color"}),jsx("div",{className:"previewcn-color-grid",children:E.map(r=>{let n=e===r.name,c=r.colors.light.primary;return jsx("button",{onClick:()=>o(r.name),className:`previewcn-color-swatch ${n?"previewcn-color-swatch--selected":""}`,style:{backgroundColor:c},"aria-label":r.label,title:r.label},r.name)})})]})}var Z=p(()=>{"use client";T();});function Ce(){return jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"m6 9 6 6 6-6"})})}function q({value:e,onChange:o}){let[r,n]=useState(false),m=y.find(a=>a.value===e)?.label??"Select font...";return jsxs("div",{className:"previewcn-section",children:[jsx("label",{className:"previewcn-label",children:"Font"}),jsxs("div",{className:"previewcn-select-wrapper",children:[jsxs("button",{onClick:()=>n(!r),className:"previewcn-select-trigger","aria-expanded":r,children:[jsx("span",{children:m}),jsx(Ce,{})]}),r&&jsx("div",{className:"previewcn-select-dropdown",children:y.map(a=>jsx("button",{onClick:()=>{o(a.value),n(false);},className:`previewcn-select-option ${e===a.value?"previewcn-select-option--selected":""}`,children:a.label},a.value))})]})]})}var Q=p(()=>{"use client";M();});function Pe(){return jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("circle",{cx:"12",cy:"12",r:"4"}),jsx("path",{d:"M12 2v2"}),jsx("path",{d:"M12 20v2"}),jsx("path",{d:"m4.93 4.93 1.41 1.41"}),jsx("path",{d:"m17.66 17.66 1.41 1.41"}),jsx("path",{d:"M2 12h2"}),jsx("path",{d:"M20 12h2"}),jsx("path",{d:"m6.34 17.66-1.41 1.41"}),jsx("path",{d:"m19.07 4.93-1.41 1.41"})]})}function Fe(){return jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z"})})}function ee({value:e,onChange:o}){let r=e??false;return jsxs("div",{className:"previewcn-section",children:[jsx("label",{className:"previewcn-label",children:"Mode"}),jsxs("div",{className:"previewcn-mode-toggle",children:[jsxs("button",{onClick:()=>o(false),className:`previewcn-mode-btn ${r?"":"previewcn-mode-btn--selected"}`,"aria-label":"Light mode",children:[jsx(Pe,{}),jsx("span",{children:"Light"})]}),jsxs("button",{onClick:()=>o(true),className:`previewcn-mode-btn ${r?"previewcn-mode-btn--selected":""}`,"aria-label":"Dark mode",children:[jsx(Fe,{}),jsx("span",{children:"Dark"})]})]})]})}var oe=p(()=>{"use client";});var re,te=p(()=>{re=[{name:"none",label:"None",value:"0rem"},{name:"sm",label:"SM",value:"0.3rem"},{name:"md",label:"MD",value:"0.5rem"},{name:"lg",label:"LG",value:"0.625rem"},{name:"xl",label:"XL",value:"0.75rem"},{name:"full",label:"Full",value:"1rem"}];});function ne({value:e,onChange:o}){return jsxs("div",{className:"previewcn-section",children:[jsx("label",{className:"previewcn-label",children:"Radius"}),jsx("div",{className:"previewcn-radius-grid",children:re.map(r=>{let n=e===r.value;return jsxs("button",{onClick:()=>o(r.value),className:`previewcn-radius-btn ${n?"previewcn-radius-btn--selected":""}`,title:r.label,children:[jsx("span",{className:"previewcn-radius-preview",style:{borderRadius:r.value}}),jsx("span",{className:"previewcn-radius-label",children:r.label})]},r.name)})})]})}var ae=p(()=>{"use client";te();});var ce={};me(ce,{default:()=>se});function Ne(){return jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M18 6 6 18"}),jsx("path",{d:"m6 6 12 12"})]})}function Ee(){return jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"}),jsx("path",{d:"M3 3v5h5"})]})}function se({onClose:e}){let{config:o,setColorPreset:r,setRadius:n,setDarkMode:c,setFont:m,resetTheme:a}=K(),i=useRef(false);useEffect(()=>{i.current||(i.current=true,I(o));},[o]);let d=useCallback(v=>{v.key==="Escape"&&e();},[e]);return useEffect(()=>(window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)),[d]),jsx("div",{className:"previewcn-backdrop",onClick:v=>{v.target===v.currentTarget&&e();},children:jsxs("div",{className:"previewcn-panel",children:[jsxs("div",{className:"previewcn-header",children:[jsxs("div",{className:"previewcn-title",children:[jsx("span",{className:"previewcn-logo",children:"PreviewCN"}),jsx("span",{className:"previewcn-badge",children:"DEV"})]}),jsx("button",{onClick:e,className:"previewcn-close-btn","aria-label":"Close",children:jsx(Ne,{})})]}),jsxs("div",{className:"previewcn-content",children:[jsx(X,{value:o.colorPreset,onChange:r}),jsx(ne,{value:o.radius,onChange:n}),jsx(q,{value:o.font,onChange:m}),jsx(ee,{value:o.darkMode,onChange:c})]}),jsx("div",{className:"previewcn-footer",children:jsxs("button",{onClick:a,className:"previewcn-reset-btn",children:[jsx(Ee,{}),jsx("span",{children:"Reset"})]})})]})})}var de=p(()=>{"use client";j();F();Z();Q();oe();ae();});function ue(){return jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor"}),jsx("circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor"}),jsx("circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor"}),jsx("circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor"}),jsx("path",{d:"M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10c.926 0 1.648-.746 1.648-1.688 0-.437-.18-.835-.437-1.125-.29-.289-.438-.652-.438-1.125a1.64 1.64 0 0 1 1.668-1.668h1.996c3.051 0 5.555-2.503 5.555-5.555C21.965 6.012 17.461 2 12 2z"})]})}function $({onClick:e}){return jsx("button",{onClick:e,className:"previewcn-trigger","aria-label":"Open PreviewCN theme editor",title:"PreviewCN Theme Editor",children:jsx(ue,{})})}var Re=lazy(()=>Promise.resolve().then(()=>(de(),ce))),Ie=process.env.NODE_ENV==="development";function De(){let[e,o]=useState(false);return jsxs(Fragment,{children:[jsx($,{onClick:()=>o(true)}),e&&jsx(Suspense,{fallback:null,children:jsx(Re,{onClose:()=>o(false)})})]})}function Oe(){return Ie?jsx(De,{}):null}F();
11
+ `;}function I(e){e.colorPreset!==null&&C(e.colorPreset),e.radius!==null&&b(e.radius),e.darkMode!==null&&w(e.darkMode),e.font!==null&&P(e.font);}function A(){let e=document.getElementById(L);e&&e.remove();let o=document.getElementById(R);o&&o.remove();let r=document.documentElement;r.style.removeProperty("--radius"),r.style.removeProperty("color-scheme"),r.classList.remove("light","dark");}var L,R,F=p(()=>{T();M();L="previewcn-devtools-theme-colors",R="previewcn-devtools-theme-font";});function ye(){if(typeof window>"u")return {};try{let e=localStorage.getItem(D);if(e)return JSON.parse(e)}catch{}return {}}function S(e){if(!(typeof window>"u"))try{localStorage.setItem(D,JSON.stringify(e));}catch{}}function K(){let[e,o]=useState(()=>({...G,...ye()})),r=useCallback(i=>{o(d=>{let s={...d,colorPreset:i};return S(s),s}),C(i);},[]),n=useCallback(i=>{o(d=>{let s={...d,radius:i};return S(s),s}),b(i);},[]),c=useCallback(i=>{o(d=>{let s={...d,darkMode:i};return S(s),s}),w(i);},[]),m=useCallback(i=>{o(d=>{let s={...d,font:i};return S(s),s}),P(i);},[]),a=useCallback(()=>{typeof window<"u"&&localStorage.removeItem(D),A(),o(G);},[]);return {config:e,setColorPreset:r,setRadius:n,setDarkMode:c,setFont:m,resetTheme:a}}var D,G,j=p(()=>{"use client";F();D="previewcn-devtools-theme";G={colorPreset:null,radius:null,darkMode:null,font:null};});function X({value:e,onChange:o}){return jsxs("div",{className:"previewcn-section",children:[jsx("label",{className:"previewcn-label",children:"Color"}),jsx("div",{className:"previewcn-color-grid",children:E.map(r=>{let n=e===r.name,c=r.colors.light.primary;return jsx("button",{onClick:()=>o(r.name),className:`previewcn-color-swatch ${n?"previewcn-color-swatch--selected":""}`,style:{backgroundColor:c},"aria-label":r.label,title:r.label},r.name)})})]})}var Z=p(()=>{"use client";T();});function Ce(){return jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"m6 9 6 6 6-6"})})}function q({value:e,onChange:o}){let[r,n]=useState(false),m=y.find(a=>a.value===e)?.label??"Select font...";return jsxs("div",{className:"previewcn-section",children:[jsx("label",{className:"previewcn-label",children:"Font"}),jsxs("div",{className:"previewcn-select-wrapper",children:[jsxs("button",{onClick:()=>n(!r),className:"previewcn-select-trigger","aria-expanded":r,children:[jsx("span",{children:m}),jsx(Ce,{})]}),r&&jsx("div",{className:"previewcn-select-dropdown",children:y.map(a=>jsx("button",{onClick:()=>{o(a.value),n(false);},className:`previewcn-select-option ${e===a.value?"previewcn-select-option--selected":""}`,children:a.label},a.value))})]})]})}var Q=p(()=>{"use client";M();});function Pe(){return jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("circle",{cx:"12",cy:"12",r:"4"}),jsx("path",{d:"M12 2v2"}),jsx("path",{d:"M12 20v2"}),jsx("path",{d:"m4.93 4.93 1.41 1.41"}),jsx("path",{d:"m17.66 17.66 1.41 1.41"}),jsx("path",{d:"M2 12h2"}),jsx("path",{d:"M20 12h2"}),jsx("path",{d:"m6.34 17.66-1.41 1.41"}),jsx("path",{d:"m19.07 4.93-1.41 1.41"})]})}function Fe(){return jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z"})})}function ee({value:e,onChange:o}){let r=e??false;return jsxs("div",{className:"previewcn-section",children:[jsx("label",{className:"previewcn-label",children:"Mode"}),jsxs("div",{className:"previewcn-mode-toggle",children:[jsxs("button",{onClick:()=>o(false),className:`previewcn-mode-btn ${r?"":"previewcn-mode-btn--selected"}`,"aria-label":"Light mode",children:[jsx(Pe,{}),jsx("span",{children:"Light"})]}),jsxs("button",{onClick:()=>o(true),className:`previewcn-mode-btn ${r?"previewcn-mode-btn--selected":""}`,"aria-label":"Dark mode",children:[jsx(Fe,{}),jsx("span",{children:"Dark"})]})]})]})}var oe=p(()=>{"use client";});var re,te=p(()=>{re=[{name:"none",label:"None",value:"0rem"},{name:"sm",label:"SM",value:"0.3rem"},{name:"md",label:"MD",value:"0.5rem"},{name:"lg",label:"LG",value:"0.625rem"},{name:"xl",label:"XL",value:"0.75rem"},{name:"full",label:"Full",value:"1rem"}];});function ne({value:e,onChange:o}){return jsxs("div",{className:"previewcn-section",children:[jsx("label",{className:"previewcn-label",children:"Radius"}),jsx("div",{className:"previewcn-radius-grid",children:re.map(r=>{let n=e===r.value;return jsxs("button",{onClick:()=>o(r.value),className:`previewcn-radius-btn ${n?"previewcn-radius-btn--selected":""}`,title:r.label,children:[jsx("span",{className:"previewcn-radius-preview",style:{borderRadius:r.value}}),jsx("span",{className:"previewcn-radius-label",children:r.label})]},r.name)})})]})}var ae=p(()=>{"use client";te();});var ce={};me(ce,{default:()=>se});function Ne(){return jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M18 6 6 18"}),jsx("path",{d:"m6 6 12 12"})]})}function Ee(){return jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"}),jsx("path",{d:"M3 3v5h5"})]})}function se({onClose:e}){let{config:o,setColorPreset:r,setRadius:n,setDarkMode:c,setFont:m,resetTheme:a}=K(),i=useRef(false);useEffect(()=>{i.current||(i.current=true,I(o));},[o]);let d=useCallback(v=>{v.key==="Escape"&&e();},[e]);return useEffect(()=>(window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)),[d]),jsx("div",{className:"previewcn-backdrop",onClick:v=>{v.target===v.currentTarget&&e();},children:jsxs("div",{className:"previewcn-panel",children:[jsxs("div",{className:"previewcn-header",children:[jsxs("div",{className:"previewcn-title",children:[jsx("span",{className:"previewcn-logo",children:"PreviewCN"}),jsx("span",{className:"previewcn-badge",children:"DEV"})]}),jsx("button",{onClick:e,className:"previewcn-close-btn","aria-label":"Close",children:jsx(Ne,{})})]}),jsxs("div",{className:"previewcn-content",children:[jsx(X,{value:o.colorPreset,onChange:r}),jsx(ne,{value:o.radius,onChange:n}),jsx(q,{value:o.font,onChange:m}),jsx(ee,{value:o.darkMode,onChange:c})]}),jsx("div",{className:"previewcn-footer",children:jsxs("button",{onClick:a,className:"previewcn-reset-btn",children:[jsx(Ee,{}),jsx("span",{children:"Reset"})]})})]})})}var de=p(()=>{"use client";j();F();Z();Q();oe();ae();});function ue(){return jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor"}),jsx("circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor"}),jsx("circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor"}),jsx("circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor"}),jsx("path",{d:"M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10c.926 0 1.648-.746 1.648-1.688 0-.437-.18-.835-.437-1.125-.29-.289-.438-.652-.438-1.125a1.64 1.64 0 0 1 1.668-1.668h1.996c3.051 0 5.555-2.503 5.555-5.555C21.965 6.012 17.461 2 12 2z"})]})}function $({onClick:e}){return jsx("button",{onClick:e,className:"previewcn-trigger","aria-label":"Open PreviewCN theme editor",title:"PreviewCN Theme Editor",children:jsx(ue,{})})}var Re=lazy(()=>Promise.resolve().then(()=>(de(),ce))),Ie=process.env.NODE_ENV==="development";function De(){let[e,o]=useState(false);return jsxs(Fragment,{children:[!e&&jsx($,{onClick:()=>o(true)}),e&&jsx(Suspense,{fallback:null,children:jsx(Re,{onClose:()=>o(false)})})]})}function Oe(){return Ie?jsx(De,{}):null}F();
12
12
  export{Oe as PreviewcnDevtools,C as applyColors,w as applyDarkMode,P as applyFont,b as applyRadius,I as applyTheme};
package/dist/styles.css CHANGED
@@ -17,7 +17,6 @@
17
17
  --tracking-tight: -0.025em;
18
18
  --tracking-wider: 0.05em;
19
19
  --radius-md: 0.375rem;
20
- --radius-xl: 0.75rem;
21
20
  --default-transition-duration: 150ms;
22
21
  --default-transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
23
22
  --default-font-family: var(--font-sans);
@@ -234,28 +233,27 @@
234
233
  position: fixed;
235
234
  inset: calc(var(--spacing) * 0);
236
235
  z-index: 99998;
237
- display: flex;
238
- align-items: flex-end;
239
- justify-content: flex-end;
240
- padding: calc(var(--spacing) * 4);
241
236
  }
242
237
  .previewcn-panel {
238
+ position: fixed;
239
+ top: calc(var(--spacing) * 0);
240
+ right: calc(var(--spacing) * 0);
243
241
  display: flex;
244
242
  flex-direction: column;
245
243
  overflow: hidden;
246
- border-radius: var(--radius-xl);
247
244
  --tw-shadow: 0 25px 50px -12px var(--tw-shadow-color, rgb(0 0 0 / 0.25));
248
245
  box-shadow: var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);
249
246
  width: 320px;
250
- max-height: calc(100vh - 32px);
247
+ height: 100vh;
248
+ height: 100dvh;
251
249
  background: oklch(0.18 0.015 260);
252
- border: 1px solid oklch(0.3 0.02 260);
250
+ border-left: 1px solid oklch(0.3 0.02 260);
253
251
  color: oklch(0.95 0 0);
254
252
  font-family: system-ui,
255
253
  -apple-system,
256
254
  sans-serif;
257
255
  font-size: 14px;
258
- animation: previewcn-slide-up 0.2s ease-out;
256
+ animation: previewcn-slide-in-right 0.25s ease-out;
259
257
  }
260
258
  .previewcn-header {
261
259
  display: flex;
@@ -512,6 +510,14 @@
512
510
  transform: translateY(0);
513
511
  }
514
512
  }
513
+ @keyframes previewcn-slide-in-right {
514
+ from {
515
+ transform: translateX(100%);
516
+ }
517
+ to {
518
+ transform: translateX(0);
519
+ }
520
+ }
515
521
  @property --tw-border-style {
516
522
  syntax: "*";
517
523
  inherits: false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@previewcn/devtools",
3
- "version": "0.1.0-alpha.5",
3
+ "version": "0.1.0-alpha.6",
4
4
  "description": "Embedded devtools for PreviewCN - real-time shadcn/ui theme preview inside your app",
5
5
  "keywords": ["shadcn", "shadcn-ui", "theme", "preview", "devtools", "react", "tailwind"],
6
6
  "license": "MIT",