Formatting change

This commit is contained in:
RMidhunSuresh 2022-03-10 17:21:38 +05:30
parent 5210123977
commit f732164b5f

View File

@ -61,16 +61,16 @@ function extractAlias(decl) {
}
}
function addResolvedVariablesToRootSelector(root, variables, { Rule, Declaration }) {
function addResolvedVariablesToRootSelector(root, variables, {Rule, Declaration}) {
const newRule = new Rule({ selector: ":root", source: root.source });
// Add base css variables to :root
for (const [key, value] of Object.entries(variables)) {
const declaration = new Declaration({ prop: `--${key}`, value });
const declaration = new Declaration({prop: `--${key}`, value});
newRule.append(declaration);
}
// Add derived css variables to :root
resolvedMap.forEach((value, key) => {
const declaration = new Declaration({ prop: key, value });
const declaration = new Declaration({prop: key, value});
newRule.append(declaration);
});
root.append(newRule);
@ -94,7 +94,7 @@ module.exports = (opts = {}) => {
return {
postcssPlugin: "postcss-compile-variables",
Once(root, { Rule, Declaration }) {
Once(root, {Rule, Declaration}) {
/*
Go through the CSS file once to extract all aliases.
We use the extracted alias when resolving derived variables
@ -102,7 +102,7 @@ module.exports = (opts = {}) => {
*/
root.walkDecls(decl => extractAlias(decl));
root.walkDecls(decl => resolveDerivedVariable(decl, opts));
addResolvedVariablesToRootSelector(root, opts.variables, { Rule, Declaration });
addResolvedVariablesToRootSelector(root, opts.variables, {Rule, Declaration});
},
};
};