antd-theme-generator
Advanced tools
Comparing version 1.0.0 to 1.0.1
20
index.js
@@ -7,2 +7,7 @@ const fs = require("fs"); | ||
const bundle = require("less-bundle-promise"); | ||
function randomColor() { | ||
return '#' + (Math.random() * 0xFFFFFF << 0).toString(16); | ||
} | ||
/* | ||
@@ -55,3 +60,2 @@ Recursively get the color code assigned to a variable e.g. | ||
let [, varName, color] = matches; | ||
// console.log(varName, color); | ||
if (color && color.startsWith("@")) { | ||
@@ -64,3 +68,2 @@ color = getColor(color, prev); | ||
} | ||
// console.log(varName, color); | ||
return prev; | ||
@@ -260,7 +263,8 @@ } catch (e) { | ||
]; | ||
bundle({ | ||
return bundle({ | ||
src: varFile | ||
}) | ||
.then(colorsLess => { | ||
const mappings = generateColorMap(colorsLess); | ||
const mappings = Object.assign(generateColorMap(colorsLess), generateColorMap(mainLessFile)); | ||
return [mappings, colorsLess]; | ||
@@ -312,3 +316,3 @@ }) | ||
const color = mappings[varName]; | ||
css = css.replace(new RegExp(`${color}`, "g"), `${varName}`); | ||
css = css.replace(new RegExp(`${color}`, "g"), varName); | ||
}); | ||
@@ -320,6 +324,3 @@ if (themeVars.includes("@primary-color")) { | ||
let color = mappings[varName]; | ||
css = css.replace( | ||
new RegExp(`${themeCompiledVars[varName]}`, "g"), | ||
`${color}` | ||
); | ||
css = css.replace(new RegExp(`${themeCompiledVars[varName]}`, "g"), color); | ||
}); | ||
@@ -352,3 +353,4 @@ } | ||
getLessVars, | ||
randomColor, | ||
renderLessContent: render | ||
}; |
{ | ||
"name": "antd-theme-generator", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": | ||
@@ -5,0 +5,0 @@ "This a script to generate color specific styles less file and which you can use to change theme dynamically in browser", |
@@ -27,3 +27,3 @@ # antd-theme-generator | ||
``` | ||
## Note: include all color variables in `varFile` that you want to change dynamically and assign them unique color codes. | ||
Add following lines in your main html file | ||
@@ -30,0 +30,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
11911
326