An object of CSS properties that don't accept values with units
92
Quality
Pending
Does it follow best practices?
Impact
92%
0.92xAverage score across 7 eval scenarios
A utility that processes CSS style values and automatically adds pixel units to numeric values when appropriate.
"width" with value 100, returns "100px" @test"margin" with value 20, returns "20px" @test"padding" with value 15, returns "15px" @test"flex" with value 1, returns 1 (no unit added) @test"opacity" with value 0.5, returns 0.5 (no unit added) @test"zIndex" with value 999, returns 999 (no unit added) @test"lineHeight" with value 1.5, returns 1.5 (no unit added) @test"width" with value 0, returns 0 (no unit needed for zero) @test"margin" with value 0, returns 0 (no unit needed for zero) @test"width" with value "100px", returns "100px" unchanged @test"color" with value "red", returns "red" unchanged @test@generates
/**
* Processes a CSS property value and adds 'px' unit if needed.
*
* @param {string} property - The CSS property name (e.g., 'width', 'flex', 'opacity')
* @param {string|number} value - The value for the property
* @returns {string|number} The processed value with units added if appropriate
*/
function processStyleValue(property, value) {
// IMPLEMENTATION HERE
}
module.exports = { processStyleValue };Provides an object of CSS properties that don't accept unit values.
@satisfied-by
Install with Tessl CLI
npx tessl i tessl/npm-emotion--unitless