source: frontend/node_modules/postcss-calc/README.md

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 3.0 KB
Line 
1# PostCSS Calc [<img src="https://postcss.github.io/postcss/logo.svg" alt="PostCSS" width="90" height="90" align="right">][PostCSS]
2
3[![NPM Version][npm-img]][npm-url]
4[![Support Chat][git-img]][git-url]
5
6[PostCSS Calc] lets you reduce `calc()` references whenever it's possible.
7When multiple units are mixed together in the same expression, the `calc()`
8statement is left as is, to fallback to the [W3C calc() implementation].
9
10## Installation
11
12```bash
13npm install postcss-calc
14```
15
16## Usage
17
18```js
19// dependencies
20var fs = require("fs")
21var postcss = require("postcss")
22var calc = require("postcss-calc")
23
24// css to be processed
25var css = fs.readFileSync("input.css", "utf8")
26
27// process css
28var output = postcss()
29 .use(calc())
30 .process(css)
31 .css
32```
33
34Using this `input.css`:
35
36```css
37h1 {
38 font-size: calc(16px * 2);
39 height: calc(100px - 2em);
40 width: calc(2*var(--base-width));
41 margin-bottom: calc(16px * 1.5);
42}
43```
44
45you will get:
46
47```css
48h1 {
49 font-size: 32px;
50 height: calc(100px - 2em);
51 width: calc(2*var(--base-width));
52 margin-bottom: 24px
53}
54```
55Checkout [tests] for more examples.
56
57### Options
58
59#### `precision` (default: `5`)
60
61Allow you to define the precision for decimal numbers.
62
63```js
64var out = postcss()
65 .use(calc({precision: 10}))
66 .process(css)
67 .css
68```
69
70#### `preserve` (default: `false`)
71
72Allow you to preserve calc() usage in output so browsers will handle decimal
73precision themselves.
74
75```js
76var out = postcss()
77 .use(calc({preserve: true}))
78 .process(css)
79 .css
80```
81
82#### `warnWhenCannotResolve` (default: `false`)
83
84Adds warnings when calc() are not reduced to a single value.
85
86```js
87var out = postcss()
88 .use(calc({warnWhenCannotResolve: true}))
89 .process(css)
90 .css
91```
92
93#### `mediaQueries` (default: `false`)
94
95Allows calc() usage as part of media query declarations.
96
97```js
98var out = postcss()
99 .use(calc({mediaQueries: true}))
100 .process(css)
101 .css
102```
103
104#### `selectors` (default: `false`)
105
106Allows calc() usage as part of selectors.
107
108```js
109var out = postcss()
110 .use(calc({selectors: true}))
111 .process(css)
112 .css
113```
114
115Example:
116
117```css
118div[data-size="calc(3*3)"] {
119 width: 100px;
120}
121```
122
123---
124
125## Related PostCSS plugins
126To replace the value of CSS custom properties at build time, try [PostCSS Custom Properties].
127
128## Contributing
129
130Work on a branch, install dev-dependencies, respect coding style & run tests
131before submitting a bug fix or a feature.
132
133```bash
134git clone git@github.com:postcss/postcss-calc.git
135git checkout -b patch-1
136npm install
137npm test
138```
139
140## [Changelog](CHANGELOG.md)
141
142## [License](LICENSE)
143
144[git-img]: https://img.shields.io/badge/support-chat-blue.svg
145[git-url]: https://gitter.im/postcss/postcss
146[npm-img]: https://img.shields.io/npm/v/postcss-calc.svg
147[npm-url]: https://www.npmjs.com/package/postcss-calc
148
149[PostCSS]: https://github.com/postcss
150[PostCSS Calc]: https://github.com/postcss/postcss-calc
151[PostCSS Custom Properties]: https://github.com/postcss/postcss-custom-properties
152[tests]: src/__tests__/index.js
153[W3C calc() implementation]: https://www.w3.org/TR/css3-values/#calc-notation
Note: See TracBrowser for help on using the repository browser.