# rework-calc

> calc() support for Rework

Latest version **1.1.0** (published 2014-07-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install rework-calc
pnpm add rework-calc
yarn add rework-calc
bun add rework-calc
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2014-07-06 |
| First published | 2013-12-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | joakimbeng, jonathanong, jongleberry, lydell, necolas, conradz, moox |
| Keywords | css, rework, rework-plugins, calculation, calc |

## Links

- npm: https://www.npmjs.com/package/rework-calc
- Repository: https://github.com/reworkcss/rework-calc
- Issues: https://github.com/reworkcss/rework-calc/issues
- npm.io page: https://npm.io/package/rework-calc

## Dependencies (2)

- [rework-visit](https://npm.io/package/rework-visit.md) ^1.0.0
- [balanced-match](https://npm.io/package/balanced-match.md) ~0.1.0

## Alternatives

- [style-dictionary](https://npm.io/package/style-dictionary.md) — 2.0M weekly downloads
- [postcss-merge-idents](https://npm.io/package/postcss-merge-idents.md) — 1.7M weekly downloads
- [@fontsource/noto-sans](https://npm.io/package/@fontsource/noto-sans.md) — 93.0K weekly downloads
- [uglifycss](https://npm.io/package/uglifycss.md) — 71.6K weekly downloads
- [mat4-interpolate](https://npm.io/package/mat4-interpolate.md) — 23.3K weekly downloads

## Recent versions

- 1.1.0 (latest) — 2014-07-06
- 1.0.0 — 2014-06-25
- 0.2.2 — 2014-05-03
- 0.2.1 — 2013-12-13

## README

# rework-calc [![Build Status](https://travis-ci.org/reworkcss/rework-calc.png)](https://travis-ci.org/reworkcss/rework-calc)

A [Rework](https://github.com/reworkcss/rework) plugin to support `calc()`.
Particularly useful with the [rework-vars](https://github.com/reworkcss/rework-vars)

## Installation

```bash
npm install rework-calc
```

## Use

As a Rework plugin:

```javascript
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](https://github.com/reworkcss/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](https://github.com/reworkcss/rework-vars)
enabled as well):

```css
: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:

```css
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:

```bash
npm test
```

## License

MIT

---
_Source: https://npm.io/package/rework-calc · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
