UNPKG

donut-theme-plugin

Version:

a vue3 plugin-adapter for element-plus theme-chalk by js-object

2 lines (1 loc) 1.16 kB
(function(s,o){typeof exports=="object"&&typeof module<"u"?o(exports):typeof define=="function"&&define.amd?define(["exports"],o):(s=typeof globalThis<"u"?globalThis:s||self,o(s.donutThemePlugin={}))})(this,function(s){"use strict";const o=n=>typeof n=="object"&&n!==null,b=(n,e,t)=>{t=Math.max(Math.min(Number(t),1),0);const u=parseInt(n.substring(1,3),16),r=parseInt(n.substring(3,5),16),c=parseInt(n.substring(5,7),16),f=parseInt(e.substring(1,3),16),i=parseInt(e.substring(3,5),16),l=parseInt(e.substring(5,7),16),a=Math.round(u*(1-t)+f*t),p=Math.round(r*(1-t)+i*t),y=Math.round(c*(1-t)+l*t),g=`0${(a||0).toString(16)}`.slice(-2),h=`0${(p||0).toString(16)}`.slice(-2),$=`0${(y||0).toString(16)}`.slice(-2);return`#${g}${h}${$}`},d=Symbol(),m=(n,e)=>{if(e&&o(e)){n.provide(d,e);const t=document.documentElement;Object.keys(e).forEach(u=>{const r=`--el-color-${u}`,c=e[u];t.style.setProperty(r,c),[3,5,7,8,9].forEach(i=>{const l=b(c,"#ffffff",i/10);t.style.setProperty(`${r}-light-${i}`,l)});const f=b(c,"#000000",.2);t.style.setProperty(`${r}-dark-2`,f)})}};s.ThemeInjectKey=d,s.ThemePlugin=m,Object.defineProperty(s,Symbol.toStringTag,{value:"Module"})});