Skip to content

Commit 3f2c424

Browse files
committed
docs: improve Readme
Fix #106 * Show the effect of PostCSS Calc alone, so people don't expect it to resolve custom properties. * Remove outdated Travis badge
1 parent 754a266 commit 3f2c424

1 file changed

Lines changed: 8 additions & 44 deletions

File tree

README.md

Lines changed: 8 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
# PostCSS Calc [<img src="https://postcss.github.io/postcss/logo.svg" alt="PostCSS" width="90" height="90" align="right">][PostCSS]
22

33
[![NPM Version][npm-img]][npm-url]
4-
[![Build Status][cli-img]][cli-url]
54
[![Support Chat][git-img]][git-url]
65

7-
[PostCSS Calc] lets you reduce `calc()` references whenever it's possible. This
8-
can be particularly useful with the [PostCSS Custom Properties] plugin.
9-
6+
[PostCSS Calc] lets you reduce `calc()` references whenever it's possible.
107
When multiple units are mixed together in the same expression, the `calc()`
118
statement is left as is, to fallback to the [W3C calc() implementation].
129

@@ -34,61 +31,27 @@ var output = postcss()
3431
.css
3532
```
3633

37-
**Example** (with [PostCSS Custom Properties] enabled as well):
38-
39-
```js
40-
// dependencies
41-
var fs = require("fs")
42-
var postcss = require("postcss")
43-
var customProperties = require("postcss-custom-properties")
44-
var calc = require("postcss-calc")
45-
46-
// css to be processed
47-
var css = fs.readFileSync("input.css", "utf8")
48-
49-
// process css
50-
var output = postcss()
51-
.use(customProperties())
52-
.use(calc())
53-
.process(css)
54-
.css
55-
```
56-
5734
Using this `input.css`:
5835

5936
```css
60-
:root {
61-
--main-font-size: 16px;
62-
}
63-
64-
body {
65-
font-size: var(--main-font-size);
66-
}
67-
6837
h1 {
69-
font-size: calc(var(--main-font-size) * 2);
38+
font-size: calc(16px * 2);
7039
height: calc(100px - 2em);
71-
margin-bottom: calc(
72-
var(--main-font-size)
73-
* 1.5
74-
)
40+
width: calc(2*var(--base-width));
41+
margin-bottom: calc(16px * 1.5);
7542
}
7643
```
7744

7845
you will get:
7946

8047
```css
81-
body {
82-
font-size: 16px
83-
}
84-
8548
h1 {
8649
font-size: 32px;
8750
height: calc(100px - 2em);
51+
width: calc(2*var(--base-width));
8852
margin-bottom: 24px
8953
}
9054
```
91-
9255
Checkout [tests] for more examples.
9356

9457
### Options
@@ -159,6 +122,9 @@ div[data-size="calc(3*3)"] {
159122

160123
---
161124

125+
## Related PostCSS plugins
126+
To replace the value of CSS custom properties at build time, try [PostCSS Custom Properties].
127+
162128
## Contributing
163129

164130
Work on a branch, install dev-dependencies, respect coding style & run tests
@@ -175,8 +141,6 @@ npm test
175141

176142
## [License](LICENSE)
177143

178-
[cli-img]: https://img.shields.io/travis/postcss/postcss-calc/master.svg
179-
[cli-url]: https://travis-ci.org/postcss/postcss-calc
180144
[git-img]: https://img.shields.io/badge/support-chat-blue.svg
181145
[git-url]: https://gitter.im/postcss/postcss
182146
[npm-img]: https://img.shields.io/npm/v/postcss-calc.svg

0 commit comments

Comments
 (0)