2.3.4 • Published 7 years ago

cssobj-plugin-default-unit v2.3.4

Weekly downloads
6
License
MIT
Repository
github
Last release
7 years ago

cssobj-plugin-default-unit

Join the chat at https://gitter.im/css-in-js/cssobj Build Status

Add default unit to css numeric-like values, which have to specify an unit.

Install

npm install cssobj/cssobj-plugin-default-unit

Usage

var cssobj_core = require('cssobj-core')
var defaultUnit = require('cssobj-plugin-default-unit')
var cssobj = cssobj_core({plugins: [ defaultUnit('px') ]})

var obj = { p: { fontSize: 12 } }
var result = cssobj(obj)

// the css: p {font-size: 12px;}

API

var plugin = defaultUnit(unit)

Get plugin function to apply, pass unit.

PARAMS

unit

  • Type: string
  • Default: 'px'

The unit as default unit to add to numeric-like values, accordingly to Unitless List

RETURN

A function can be as cssobj plugin.

Example

defaultUnit()  // default unit is 'px'

defaultUnit('em')  // default unit is 'em'

Caveat

line-height will NOT add unit, since below:

p { lineHeight: 1.5 }
p { lineHeight: '22px' }

It's both valid with or w/o unit, so this plugin don't touch it.

2.3.4

7 years ago

2.3.3

7 years ago

2.3.2

7 years ago

2.3.1

7 years ago

2.3.0

7 years ago

2.2.1

7 years ago

2.2.0

7 years ago