Skip to content

Commit c858997

Browse files
committed
plugins/postcss-selector-not
1 parent 513f662 commit c858997

File tree

23 files changed

+618
-3069
lines changed

23 files changed

+618
-3069
lines changed

plugins/postcss-selector-not/.babelrc

Lines changed: 0 additions & 11 deletions
This file was deleted.

plugins/postcss-selector-not/.editorconfig

Lines changed: 0 additions & 16 deletions
This file was deleted.

plugins/postcss-selector-not/.eslintrc.yml

Lines changed: 0 additions & 34 deletions
This file was deleted.

plugins/postcss-selector-not/.github/workflows/test.yml

Lines changed: 0 additions & 28 deletions
This file was deleted.
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
11
node_modules
2-
dist
2+
package-lock.json
3+
yarn.lock
4+
*.result.css
5+
*.result.css.map
6+
dist/*
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
v16.13.1
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import postcssTape from '../../packages/postcss-tape/dist/index.mjs';
2+
import plugin from 'postcss-selector-not';
3+
4+
postcssTape(plugin)({
5+
basic: {
6+
message: "supports basic usage",
7+
},
8+
'examples/example': {
9+
message: 'minimal example',
10+
},
11+
});

plugins/postcss-selector-not/CHANGELOG.md

100755100644
File mode changed.
Lines changed: 176 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
# Installing PostCSS Selector Not
2+
3+
[PostCSS Selector Not] 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 Selector Not] to your project:
11+
12+
```bash
13+
npm install postcss postcss-selector-not --save-dev
14+
```
15+
16+
Use it as a [PostCSS] plugin:
17+
18+
```js
19+
const postcss = require('postcss');
20+
const postcssSelectorNot = require('postcss-selector-not');
21+
22+
postcss([
23+
postcssSelectorNot(/* 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 postcss-selector-not --save-dev
33+
```
34+
35+
Use [PostCSS Selector Not] in your `postcss.config.js` configuration file:
36+
37+
```js
38+
const postcssSelectorNot = require('postcss-selector-not');
39+
40+
module.exports = {
41+
plugins: [
42+
postcssSelectorNot(/* 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 postcss-selector-not --save-dev
55+
```
56+
57+
Use [PostCSS Selector Not] 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+
"postcss-selector-not",
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 postcss-selector-not --save-dev
99+
```
100+
101+
Use [React App Rewire PostCSS] and [PostCSS Selector Not] in your
102+
`config-overrides.js` file:
103+
104+
```js
105+
const reactAppRewirePostcss = require('react-app-rewire-postcss');
106+
const postcssSelectorNot = require('postcss-selector-not');
107+
108+
module.exports = config => reactAppRewirePostcss(config, {
109+
plugins: () => [
110+
postcssSelectorNot(/* pluginOptions */)
111+
]
112+
});
113+
```
114+
115+
## Gulp
116+
117+
Add [Gulp PostCSS] to your project:
118+
119+
```bash
120+
npm install gulp-postcss postcss-selector-not --save-dev
121+
```
122+
123+
Use [PostCSS Selector Not] in your Gulpfile:
124+
125+
```js
126+
const postcss = require('gulp-postcss');
127+
const postcssSelectorNot = require('postcss-selector-not');
128+
129+
gulp.task('css', function () {
130+
var plugins = [
131+
postcssSelectorNot(/* 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 postcss-selector-not --save-dev
146+
```
147+
148+
Use [PostCSS Selector Not] in your Gruntfile:
149+
150+
```js
151+
const postcssSelectorNot = require('postcss-selector-not');
152+
153+
grunt.loadNpmTasks('grunt-postcss');
154+
155+
grunt.initConfig({
156+
postcss: {
157+
options: {
158+
processors: [
159+
postcssSelectorNot(/* 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 Selector Not]: https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-selector-not
175+
[React App Rewire PostCSS]: https://github.com/csstools/react-app-rewire-postcss
176+
[React App Rewired]: https://github.com/timarney/react-app-rewired
Lines changed: 39 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,57 @@
1-
# postcss-selector-not [![CSS Standard Status](https://cssdb.org/images/badges/not-pseudo-class.svg)](https://cssdb.org/#not-pseudo-class) [<img alt="build status" src="https://github.com/postcss/postcss-selector-not/workflows/test/badge.svg" height="20">][cli-url]
1+
# PostCSS Selector Not [<img src="https://postcss.github.io/postcss/logo.svg" alt="PostCSS Logo" width="90" height="90" align="right">][postcss]
22

3-
> PostCSS plugin to transform `:not()` W3C CSS level 4 pseudo class to :not() CSS level 3 selectors
3+
[<img alt="npm version" src="https://img.shields.io/npm/v/postcss-selector-not.svg" height="20">][npm-url] [<img alt="CSS Standard Status" src="https://cssdb.org/images/badges/not-pseudo-class.svg" height="20">][css-url] [<img alt="Build Status" src="https://github.com/csstools/postcss-plugins/workflows/test/badge.svg" height="20">][cli-url] [<img alt="Discord" src="https://shields.io/badge/Discord-5865F2?logo=discord&logoColor=white">][discord]
44

5-
http://dev.w3.org/csswg/selectors-4/#negation
5+
[PostCSS Selector Not] transforms :not() W3C CSS level 4 pseudo classes to :not() CSS level 3 selectors following the [Selectors 4 Specification].
66

7-
[!['Can I use' table](https://caniuse.bitsofco.de/image/css-not-sel-list.png)](https://caniuse.com/#feat=css-not-sel-list)
7+
```pcss
8+
p:not(:first-child, .special) {
9+
color: red;
10+
}
811
9-
## Installation
12+
/* becomes */
1013
11-
```console
12-
$ npm install postcss postcss-selector-not
14+
p:not(:first-child):not(.special) {
15+
color: red;
16+
}
1317
```
1418

19+
⚠️ Only lists of simple selectors (`:not(.a, .b)`) will work as expected.
20+
Complex selectors (`:not(.a > .b, .c ~ .d)`) can not be downgraded.
21+
1522
## Usage
1623

17-
Using this `input.css`:
24+
Add [PostCSS Selector Not] to your project:
1825

19-
```css
20-
p:not(:first-child, .special) {
21-
color: red;
22-
}
26+
```bash
27+
npm install postcss postcss-selector-not --save-dev
2328
```
2429

25-
you will get:
30+
Use it as a [PostCSS] plugin:
2631

27-
```css
28-
p:not(:first-child):not(.special) {
29-
color: red;
30-
}
32+
```js
33+
const postcss = require('postcss');
34+
const postcssSelectorNot = require('postcss-selector-not');
35+
36+
postcss([
37+
postcssSelectorNot(/* pluginOptions */)
38+
]).process(YOUR_CSS /*, processOptions */);
3139
```
3240

33-
---
41+
[PostCSS Selector Not] runs in all Node environments, with special
42+
instructions for:
3443

35-
## [Changelog](CHANGELOG.md)
44+
| [Node](INSTALL.md#node) | [PostCSS CLI](INSTALL.md#postcss-cli) | [Webpack](INSTALL.md#webpack) | [Create React App](INSTALL.md#create-react-app) | [Gulp](INSTALL.md#gulp) | [Grunt](INSTALL.md#grunt) |
45+
| --- | --- | --- | --- | --- | --- |
3646

37-
## [License](LICENSE)
47+
[cli-url]: https://github.com/csstools/postcss-plugins/actions/workflows/test.yml?query=workflow/test
48+
[css-url]: https://cssdb.org/#not-pseudo-class
49+
[discord]: https://discord.gg/bUadyRwkJS
50+
[npm-url]: https://www.npmjs.com/package/postcss-selector-not
3851

39-
[cli-url]: https://github.com/postcss/postcss-selector-not/actions/workflows/test.yml?query=workflow/test
52+
[Gulp PostCSS]: https://github.com/postcss/gulp-postcss
53+
[Grunt PostCSS]: https://github.com/nDmitry/grunt-postcss
54+
[PostCSS]: https://github.com/postcss/postcss
55+
[PostCSS Loader]: https://github.com/postcss/postcss-loader
56+
[PostCSS Selector Not]: https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-selector-not
57+
[Selectors 4 Specification]: https://www.w3.org/TR/selectors-4/#negation-pseudo

0 commit comments

Comments
 (0)