mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 03:25:12 +01:00
Document options
This commit is contained in:
parent
1663782954
commit
5210123977
@ -77,12 +77,20 @@ function addResolvedVariablesToRootSelector(root, variables, { Rule, Declaration
|
||||
}
|
||||
|
||||
/**
|
||||
* @type {import('postcss').PluginCreator}
|
||||
* @callback derive
|
||||
* @param {string} value - The base value on which an operation is applied
|
||||
* @param {string} operation - The operation to be applied (eg: darker, lighter...)
|
||||
* @param {string} argument - The argument for this operation
|
||||
*/
|
||||
/**
|
||||
*
|
||||
* @param {Object} opts - Options for the plugin
|
||||
* @param {Object} opts.variables - An object with records of the form: {base_variable_name: value}
|
||||
* @param {derive} opts.derive - The callback which contains the logic for resolving derived variables
|
||||
*/
|
||||
module.exports = (opts = {}) => {
|
||||
aliasMap = new Map();
|
||||
resolvedMap = new Map();
|
||||
const {variables} = opts;
|
||||
return {
|
||||
postcssPlugin: "postcss-compile-variables",
|
||||
|
||||
@ -94,7 +102,7 @@ module.exports = (opts = {}) => {
|
||||
*/
|
||||
root.walkDecls(decl => extractAlias(decl));
|
||||
root.walkDecls(decl => resolveDerivedVariable(decl, opts));
|
||||
addResolvedVariablesToRootSelector(root, variables, { Rule, Declaration });
|
||||
addResolvedVariablesToRootSelector(root, opts.variables, { Rule, Declaration });
|
||||
},
|
||||
};
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user