How to use the postcss-values-parser.word function in postcss-values-parser

To help you get started, we’ve selected a few postcss-values-parser examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Pavliko / postcss-svg / src / lib / transpile-styles.js View on Github external
function transpileVar(node, params) {
	// css variable
	const cssvar = node.nodes[1].value;

	// css variable backup value
	const backup = node.nodes[3];

	if (cssvar in params) {
		// conditionally transpile the css var() function into the matched param
		node.replaceWith(
			parser.word({ value: params[cssvar] })
		);
	} else if (backup) {
		// conditionally transpile the css var() function into the backup value
		node.replaceWith(backup);
	}
}
github jonathantneal / postcss-color-mod-function / lib / transform.js View on Github external
node.nodes.slice(0).forEach(child => {
		if (isColorModFunction(child)) {
			// transform any variables within the color-mod() function
			if (opts.transformVars) {
				transformVariables(child, opts);
			}

			// transform any color-mod() functions
			const color = transformColorModFunction(child, opts);

			if (color) {
				// update the color-mod() function with the transformed value
				child.replaceWith(parser.word({
					raws: child.raws,
					value: opts.stringifier(color)
				}));
			}
		} else if (child.nodes && Object(child.nodes).length) {
			transformAST(child, opts);
		}
	});
}