You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
chatai/dist/dev/mp-weixin/utils/theme.js

44 lines
1.1 KiB

7 months ago
"use strict";
const common_vendor = require("../common/vendor.js");
const lightConfig = {
"dark-2": "shade(20%)",
"light-3": "tint(30%)",
"light-5": "tint(50%)",
"light-7": "tint(70%)",
"light-9": "tint(90%)"
};
const darkConfig = {
"light-3": "shade(20%)",
"light-5": "shade(30%)",
"light-7": "shade(50%)",
"light-9": "shade(70%)",
"dark-2": "tint(20%)"
};
const generateVarsMap = (color, type = "primary", isDark = false) => {
const colors2 = {
[`--color-${type}`]: color
};
const config = isDark ? darkConfig : lightConfig;
for (const key in config) {
colors2[`--color-${type}-${key}`] = `color(${color} ${config[key]})`;
}
return colors2;
};
const generateVars = (options, extra = {}, isDark = false) => {
const varsMap = Object.keys(options).reduce(
(prev, key) => {
return Object.assign(
prev,
generateVarsMap(options[key], key, isDark)
);
},
extra
);
const vars = Object.keys(varsMap).reduce((prev, key) => {
const color = common_vendor.lib.convert(varsMap[key]);
return `${prev}${key}:${color};`;
}, "");
return vars;
};
exports.generateVars = generateVars;