@f/css-default-units

Add default units to css values

Stats

StarsIssuesVersionUpdatedCreatedSize
@f/css-default-units
001.0.16 years ago6 years agoMinified + gzip package size for @f/css-default-units in KB

Readme

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

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.