@wordpress/components
Version:
UI components for WordPress.
14 lines (11 loc) • 358 B
JavaScript
const SPACE_GRID_BASE = 8;
/**
* Creates a spacing CSS value (px) based on grid system values.
*
* @param {number} [value=1] Multiplier against the grid base value (8)
* @return {string} The spacing value (px).
*/
export function space( value = 1 ) {
if ( isNaN( value ) ) return `${ SPACE_GRID_BASE }px`;
return `${ SPACE_GRID_BASE * value }px`;
}