rework-calc
Adding calc() support to rework
Last updated 12 years ago by joakimbeng .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install rework-calc 
SYNC missed versions from official npm registry.

rework-calc Build Status

A Rework plugin to support calc(). Particularly useful with the rework-vars

Installation

npm install rework-calc

Use

As a Rework plugin:

var rework = require('rework');
var calc = require('rework-calc');

var css = rework(cssString).use(calc).toString();

Supported feature

This simply add calc() support, a feature to do simple calculations. This can be particularly useful with the rework-vars plugin.

Note: When multiple units are mixed together in the same expression, the calc() statement is left as is, to fallback to the CSS3 calc feature.

Example (with rework-vars enabled as well):

:root {
  --main-font-size: 16px;
}

body {
  font-size: var(--main-font-size);
}

h1 {
  font-size: calc(var(--main-font-size) * 2);
  height: calc(100px - 2em);
}

yields:

body {
  font-size: 16px
}

h1 {
  font-size: 32px;
  height: calc(100px - 2em)
}

See unit tests for another example.

Unit tests

Make sure the dev-dependencies are installed, and then run:

npm test

License

MIT

Current Tags

  • 1.1.0                                ...           latest (12 years ago)

4 Versions

  • 1.1.0                                ...           12 years ago
  • 1.0.0                                ...           12 years ago
  • 0.2.2                                ...           12 years ago
  • 0.2.1                                ...           12 years ago
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (3)
Dependents (1)

Copyright 2013 - present © cnpmjs.org | Home |