UNPKG

@infinityfx/fluid

Version:

React UI library, using zero-runtime CSS-in-JS.

3 lines (2 loc) 1.97 kB
function t(...t){return t.filter((t=>"string"==typeof t)).join(" ")}function n(t,n){const o=Object.assign({},t);for(const e in n)e in t?o[e]+=` ${n[e]}`:o[e]=n[e];return o}function o(...t){return n=>{t.forEach((t=>{t&&(t instanceof Function?t(n):t.current=n)}))}}function e(){return document.cookie.split(";").reduce(((t,n)=>{const[o,e]=n.split("=");return o&&e&&(t[decodeURIComponent(o.trim())]=decodeURIComponent(e.trim())),t}),{})}function r(t,n,o={}){o=Object.assign({path:"/",secure:!0,sameSite:"Lax"},o);const e=Object.entries(o).map((([t,n])=>("maxAge"===t&&(t="max-Age"),t=t.charAt(0).toUpperCase()+t.slice(1),"boolean"==typeof n?n?`${t};`:"":void 0===n?"":`${t}=${n};`))).join(" ");return`${t}=${n}; ${e}`}function a(t){return`${t.map((t=>t.toString(16).padStart(2,"0"))).join("")}`}function i(t){const n=t.toLowerCase().match(/^#?([\da-f]{1,2})([\da-f]{1,2})([\da-f]{1,2})([\da-f]{2})?$/i);return n?n.slice(1,4).map((t=>parseInt(t.padStart(2,t),16))):[0,0,0]}function c([t,n,o]){n/=100,o/=100;const e=n=>(n+t/60)%6,r=t=>Math.round(255*o*(1-n*Math.max(0,Math.min(e(t),4-e(t),1))));return[r(5),r(3),r(1)]}function u([t,n,o]){t/=255,n/=255,o/=255;const e=Math.max(t,n,o),r=e-Math.min(t,n,o);let a=0;return r&&e===t&&(a=(n-o)/r),r&&e===n&&(a=2+(o-t)/r),r&&e===o&&(a=4+(t-n)/r),[60*(a<0?a+6:a),e&&r/e*100,100*e]}function s(t,n,o){const e=i(t),r=i(n);return new Array(o).fill(0).map(((t,n)=>{const a=n/o;return`#${[e[0]*(1-a)+r[0]*a,e[1]*(1-a)+r[1]*a,e[2]*(1-a)+r[2]*a].map((t=>Math.round(t).toString(16).padStart(2,"0"))).join("")}`}))}const f={hue:0,saturation:1,lightness:2};function p(t,n){const o=u(i(t));return o[f[n]]=("hue"===n?180:100)-o[f[n]],o[0]<0&&(o[0]=360-o[0]),`#${a(c(o))}`}const m="FLUID_PREF_COLOR_SCHEME";export{m as COLOR_SCHEME_COOKIE,t as classes,n as combineClasses,o as combineRefs,e as cookies,r as formatCookie,i as hexToRgb,c as hsvToRgb,p as invertColorChannel,s as mixColors,a as rgbToHex,u as rgbToHsv}; //# sourceMappingURL=utils.mjs.map