UNPKG

t-fighting-design

Version:

Fighting design can quickly build interactive interfaces in vue3 applications, which looks good.

2 lines (1 loc) 1.07 kB
"use strict";var g=Object.defineProperty;var h=(e,r,o)=>r in e?g(e,r,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[r]=o;var l=(e,r,o)=>(h(e,typeof r!="symbol"?r+"":r,o),o);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});class s{constructor(r){l(this,"color");l(this,"hexToRgb",()=>{if(!/^\#?[0-9A-Fa-f]{6}$/.test(this.color))return console.warn("\u8F93\u5165\u9519\u8BEF\u7684 hex \u503C\u8272\u53F7");const t=this.color.replace("#","").match(/../g);for(let n=0;n<t.length;n++)t[n]=parseInt(t[n],16).toString();return t});l(this,"rgbToHex",(...r)=>{const o=[...r];for(let t=0;t<o.length;t++)o[t].length===1&&(o[t]="0"+o[t]);return"#"+o.join("")});l(this,"getDarkColor",r=>{const o=this.hexToRgb();for(let t=0;t<o.length;t++)o[t]=Math.floor(Number(o[t])*(1-r)).toString(16);return this.rgbToHex(...o)});l(this,"getLightColor",r=>{const o=this.hexToRgb();for(let t=0;t<o.length;t++)o[t]=Math.floor((255-Number(o[t]))*r+Number(o[t])).toString(16);return this.rgbToHex(...o)});this.color=r}}exports.ChangeColor=s;