1.0.0 • Published 8 years ago
bredon-plugin-unit v1.0.0
bredon-plugin-unit
The unit plugin will convert, normalize and minify unit values.
Installation
yarn add bredon-plugin-unitYou may alternatively use npm i --save bredon-plugin-unit.
Usage
import { compile } from 'bredon'
import unitPlugin from 'bredon-plugin-unit'
const input = '12pt 0.25turn 3s 15px 2.53cm'
const output = compile(input, {
plugins: [
unitPlugin()
]
})
console.log(output)
// => 16px 90deg 3000ms 15px 95.622pxConfiguration
By default the output precision is 4.
The default unit formats are:
- length:
px - time:
ms - angle:
deg
| Options | Value | Default | Description |
|---|---|---|---|
| precision | number | 4 | The prefered precision |
| formats | Object | { length: 'px', time: 'ms', angle: 'deg' } | The prefered unit formats |
import { compile } from 'bredon'
import unitPlugin from 'bredon-plugin-unit'
const input = '12pt 0.25turn 3s 15px 2.53cm'
const output = compile(input, {
plugins: [
unitPlugin({
precision: 2,
formats: {
length: 'mm',
angle: 'grad',
time: 's',
}
})
]
})
console.log(output)
// => 4.23mm 100grad 3s 3.97mm 25.3mmLicense
Bredon is licensed under the MIT License. Documentation is licensed under Creative Common License. Created with ♥ by @rofrischmann and all the great contributors.
1.0.0
8 years ago