Skip to content

Commit c12c2bd

Browse files
authored
postcss-nested-calc (#566)
* postcss-nested-calc * fmt * ignore custom properties * fmt * fmt * simplify the examples * remove cssdb for now
1 parent 0109549 commit c12c2bd

24 files changed

+831
-0
lines changed

.github/ISSUE_TEMPLATE/css-issue.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ body:
8686
- PostCSS Lab Function
8787
- PostCSS Logical
8888
- PostCSS Media Query Ranges
89+
- PostCSS Nested Calc
8990
- PostCSS Nesting
9091
- PostCSS OKLab Function
9192
- PostCSS Overflow Shorthand

.github/ISSUE_TEMPLATE/plugin-issue.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ body:
8888
- PostCSS Lab Function
8989
- PostCSS Logical
9090
- PostCSS Media Query Ranges
91+
- PostCSS Nested Calc
9192
- PostCSS Nesting
9293
- PostCSS OKLab Function
9394
- PostCSS Overflow Shorthand

.github/labeler.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,10 @@
132132
- plugins/postcss-media-query-ranges/**
133133
- experimental/postcss-media-query-ranges/**
134134

135+
"plugins/postcss-nested-calc":
136+
- plugins/postcss-nested-calc/**
137+
- experimental/postcss-nested-calc/**
138+
135139
"plugins/postcss-nesting":
136140
- plugins/postcss-nesting/**
137141
- experimental/postcss-nesting/**

package-lock.json

Lines changed: 28 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
node_modules
2+
package-lock.json
3+
yarn.lock
4+
*.result.css
5+
*.result.css.map
6+
dist/*

plugins/postcss-nested-calc/.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
v16.13.1

plugins/postcss-nested-calc/.tape.mjs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import postcssTape from '../../packages/postcss-tape/dist/index.mjs';
2+
import plugin from '@csstools/postcss-nested-calc';
3+
4+
postcssTape(plugin)({
5+
basic: {
6+
message: "supports basic usage",
7+
},
8+
'basic:preserve-false': {
9+
message: "supports basic usage with { preserve: false }",
10+
options: {
11+
preserve: false
12+
}
13+
},
14+
'examples/example': {
15+
message: 'minimal example',
16+
},
17+
'examples/example:preserve-false': {
18+
message: 'minimal example',
19+
options: {
20+
preserve: false
21+
}
22+
},
23+
});
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Changes to PostCSS Nested Calc
2+
3+
### 1.0.0 (Unreleased)
4+
5+
- Initial version
Lines changed: 176 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
# Installing PostCSS Nested Calc
2+
3+
[PostCSS Nested Calc] runs in all Node environments, with special instructions for:
4+
5+
| [Node](#node) | [PostCSS CLI](#postcss-cli) | [Webpack](#webpack) | [Create React App](#create-react-app) | [Gulp](#gulp) | [Grunt](#grunt) |
6+
| --- | --- | --- | --- | --- | --- |
7+
8+
## Node
9+
10+
Add [PostCSS Nested Calc] to your project:
11+
12+
```bash
13+
npm install postcss @csstools/postcss-nested-calc --save-dev
14+
```
15+
16+
Use it as a [PostCSS] plugin:
17+
18+
```js
19+
const postcss = require('postcss');
20+
const postcssNestedCalc = require('@csstools/postcss-nested-calc');
21+
22+
postcss([
23+
postcssNestedCalc(/* pluginOptions */)
24+
]).process(YOUR_CSS /*, processOptions */);
25+
```
26+
27+
## PostCSS CLI
28+
29+
Add [PostCSS CLI] to your project:
30+
31+
```bash
32+
npm install postcss-cli @csstools/postcss-nested-calc --save-dev
33+
```
34+
35+
Use [PostCSS Nested Calc] in your `postcss.config.js` configuration file:
36+
37+
```js
38+
const postcssNestedCalc = require('@csstools/postcss-nested-calc');
39+
40+
module.exports = {
41+
plugins: [
42+
postcssNestedCalc(/* pluginOptions */)
43+
]
44+
}
45+
```
46+
47+
## Webpack
48+
49+
_Webpack version 5_
50+
51+
Add [PostCSS Loader] to your project:
52+
53+
```bash
54+
npm install postcss-loader @csstools/postcss-nested-calc --save-dev
55+
```
56+
57+
Use [PostCSS Nested Calc] in your Webpack configuration:
58+
59+
```js
60+
module.exports = {
61+
module: {
62+
rules: [
63+
{
64+
test: /\.css$/i,
65+
use: [
66+
"style-loader",
67+
{
68+
loader: "css-loader",
69+
options: { importLoaders: 1 },
70+
},
71+
{
72+
loader: "postcss-loader",
73+
options: {
74+
postcssOptions: {
75+
plugins: [
76+
[
77+
"@csstools/postcss-nested-calc",
78+
{
79+
// Options
80+
},
81+
],
82+
],
83+
},
84+
},
85+
},
86+
],
87+
},
88+
],
89+
},
90+
};
91+
```
92+
93+
## Create React App
94+
95+
Add [React App Rewired] and [React App Rewire PostCSS] to your project:
96+
97+
```bash
98+
npm install react-app-rewired react-app-rewire-postcss @csstools/postcss-nested-calc --save-dev
99+
```
100+
101+
Use [React App Rewire PostCSS] and [PostCSS Nested Calc] in your
102+
`config-overrides.js` file:
103+
104+
```js
105+
const reactAppRewirePostcss = require('react-app-rewire-postcss');
106+
const postcssNestedCalc = require('@csstools/postcss-nested-calc');
107+
108+
module.exports = config => reactAppRewirePostcss(config, {
109+
plugins: () => [
110+
postcssNestedCalc(/* pluginOptions */)
111+
]
112+
});
113+
```
114+
115+
## Gulp
116+
117+
Add [Gulp PostCSS] to your project:
118+
119+
```bash
120+
npm install gulp-postcss @csstools/postcss-nested-calc --save-dev
121+
```
122+
123+
Use [PostCSS Nested Calc] in your Gulpfile:
124+
125+
```js
126+
const postcss = require('gulp-postcss');
127+
const postcssNestedCalc = require('@csstools/postcss-nested-calc');
128+
129+
gulp.task('css', function () {
130+
var plugins = [
131+
postcssNestedCalc(/* pluginOptions */)
132+
];
133+
134+
return gulp.src('./src/*.css')
135+
.pipe(postcss(plugins))
136+
.pipe(gulp.dest('.'));
137+
});
138+
```
139+
140+
## Grunt
141+
142+
Add [Grunt PostCSS] to your project:
143+
144+
```bash
145+
npm install grunt-postcss @csstools/postcss-nested-calc --save-dev
146+
```
147+
148+
Use [PostCSS Nested Calc] in your Gruntfile:
149+
150+
```js
151+
const postcssNestedCalc = require('@csstools/postcss-nested-calc');
152+
153+
grunt.loadNpmTasks('grunt-postcss');
154+
155+
grunt.initConfig({
156+
postcss: {
157+
options: {
158+
processors: [
159+
postcssNestedCalc(/* pluginOptions */)
160+
]
161+
},
162+
dist: {
163+
src: '*.css'
164+
}
165+
}
166+
});
167+
```
168+
169+
[Gulp PostCSS]: https://github.com/postcss/gulp-postcss
170+
[Grunt PostCSS]: https://github.com/nDmitry/grunt-postcss
171+
[PostCSS]: https://github.com/postcss/postcss
172+
[PostCSS CLI]: https://github.com/postcss/postcss-cli
173+
[PostCSS Loader]: https://github.com/postcss/postcss-loader
174+
[PostCSS Nested Calc]: https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-nested-calc
175+
[React App Rewire PostCSS]: https://github.com/csstools/react-app-rewire-postcss
176+
[React App Rewired]: https://github.com/timarney/react-app-rewired

0 commit comments

Comments
 (0)