UNPKG

estilos

Version:

A tiny library for getting most out of CSS variables

1 lines 1.04 kB
(function(a,b){if("function"==typeof define&&define.amd)define(["exports"],b);else if("undefined"!=typeof exports)b(exports);else{var c={exports:{}};b(c.exports),a.estilos=c.exports}})("undefined"==typeof globalThis?"undefined"==typeof self?this:self:globalThis,function(a){"use strict";function b(a){return"--"+a.replace(/[A-Z]/g,a=>"-"+a.toLowerCase())}Object.defineProperty(a,"__esModule",{value:!0}),a.createState=function(a={},c=document.documentElement){var d;if("string"==typeof c){const a=document.querySelector(c);if(!a)throw new Error(`"${c}" selector does not match any element.`);else d=a}else d=c;const e=a=>getComputedStyle(d).getPropertyValue(b(a)),f=(a,c)=>d.style.setProperty(b(a),c),g=new Proxy(()=>{},{get(a,b){return e(b)},set(a,b,c){return f(b,c),!0},apply(a,b,[c]){for(let d in c)f(d,c[d]);return!0}});return g(a),g},a.$get=b,a.$var=function(a){return`var(${b(a)})`},a.addQuotes=function(a){return`"${a}"`},a.removeQuotes=function(a){let b=a.match(/(["'])(?:(?=(\\?))\2.)*?\1/);return b?.length?b[0].slice(1,-1):a}});