UNPKG

tailwindcss-css-variables-palette-plugin

Version:
2 lines (1 loc) 2.81 kB
var F=Object.defineProperty;var p=Object.getOwnPropertySymbols;var L=Object.prototype.hasOwnProperty,j=Object.prototype.propertyIsEnumerable;var h=(s,c,a)=>c in s?F(s,c,{enumerable:!0,configurable:!0,writable:!0,value:a}):s[c]=a,l=(s,c)=>{for(var a in c||(c={}))L.call(c,a)&&h(s,a,c[a]);if(p)for(var a of p(c))j.call(c,a)&&h(s,a,c[a]);return s};(function(s,c){typeof exports=="object"&&typeof module!="undefined"?module.exports=c():typeof define=="function"&&define.amd?define(c):(s=typeof globalThis!="undefined"?globalThis:s||self,s["tailwindcss-palette-css-variables"]=c())})(this,function(){"use strict";var s={},c={};Object.defineProperty(c,"__esModule",{value:!0}),c.default=void 0;function a(t,n){return{handler:t,config:n}}a.withOptions=function(t,n=()=>({})){const e=function(r){return{__options:r,handler:t(r),config:n(r)}};return e.__isOptionsFunction=!0,e.__pluginFunction=t,e.__configFunction=n,e};var $=a;c.default=$,Object.defineProperty(s,"__esModule",{value:!0}),s.default=void 0;var _=b(c);function b(t){return t&&t.__esModule?t:{default:t}}var v=_.default;s.default=v;let i=s;var P=(i.__esModule?i:{default:i}).default;function f(t){const n=t.replace(/##/g,"#"),e=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(n);if(!e)return null;const[,r,o,u]=e;return{r:parseInt(r,16),g:parseInt(o,16),b:parseInt(u,16)}}function d(t,n,e){const r=o=>`0${o.toString(16)}`.slice(-2);return`#${r(t)}${r(n)}${r(e)}`}const x=(t,n)=>{const e=f(`#${t}`);if(!e)return"";const r=Math.round(e.r+(255-e.r)*n),o=Math.round(e.g+(255-e.g)*n),u=Math.round(e.b+(255-e.b)*n);return d(r,o,u)},M=(t,n)=>{const e=f(t);if(!e)return"";const r=Math.round(e.r*n),o=Math.round(e.g*n),u=Math.round(e.b*n);return d(r,o,u)},m=(t,n)=>{const e=`#${n.replace(/#/g,"")}`,r={name:t,colors:{DEFAULT:e,500:`#${n.replace(/#/g,"")}`}},o={100:.9,200:.75,300:.6,400:.3,600:.9,700:.75,800:.6,900:.49};return[100,200,300,400].forEach(u=>{r.colors[u]=x(n,o[u])}),[600,700,800,900].forEach(u=>{r.colors[u]=M(n,o[u])}),r},T=(t,n)=>{const e={};return Object.keys(n).map(r=>{const o=n[r],u=r==="DEFAULT"?`--color-${t}`:`--color-${t}-${r}`;e[r]=`var(${u}, ${o})`}),{colorsObject:e,colorName:t}},O=(t,n)=>{const e=m(t,n);return T(e.name,e.colors)},E=t=>{const n=Object.keys(t).map(r=>({name:r,value:t[r]})),e={};return n.forEach(r=>{const o=O(r.name,r.value);e[o.colorName]=o.colorsObject}),e},g=(t,n="")=>Object.keys(t).reduce((e,r)=>{const o=t[r],u=r==="DEFAULT"?{[`--color${n}`]:o}:{[`--color${n}-${r}`]:o},w=typeof o=="string"?u:g(o,`-${r}`);return l(l({},e),w)},{});return P.withOptions(function(t){return function({addBase:n,theme:e}){n({":root":g(e("colors"))})}},function(t){const n=E(t==null?void 0:t.colors);return{theme:{extend:{colors:l({inherit:"inherit",current:"currentColor",transparent:"transparent",black:"#000",white:"#fff"},n)}}}})});