@f/css-default-units

1.0.1 • Public • Published

css-default-units

Build status Git tag NPM version Code style

Add default units to css values

Installation

$ npm install @f/css-default-units

Usage

This is a very simple implementation of default units. It doesn't try to do default units for complex rules like media queries. It just handles the simplest cases, e.g. height: 50 -> height: 50px. It skips unitless properties when appropriate.

var defaultUnits = require('@f/css-default-units')

function applyUnits (rule) {
  for (var key in rule) {
    rule[key] = defaultUnits(key, rule[key])
  }
}

API

cssDefaultUnits(key, value)

  • key - The css property name (in camel case or hyphenated)
  • value - The value you want to apply default units to, if appropriate

Returns: value with default units applied (if appropriate)

License

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i @f/css-default-units

Weekly Downloads

58

Version

1.0.1

License

MIT

Last publish

Collaborators

  • f