This repository was archived by the owner on Dec 21, 2021. It is now read-only.
Commit c4d16ab 1 parent f2bcd1a commit c4d16ab Copy full SHA for c4d16ab
File tree 4 files changed +15
-24
lines changed
4 files changed +15
-24
lines changed Original file line number Diff line number Diff line change @@ -36,14 +36,6 @@ npm install postcss-color-functional-notation --save-dev
36
36
37
37
Use [ PostCSS Color Functional Notation] to process your CSS:
38
38
39
- ``` js
40
- const postcssColorFunctionalNotation = require (' postcss-color-functional-notation' );
41
-
42
- postcssColorFunctionalNotation .process (YOUR_CSS /* , processOptions, pluginOptions */ );
43
- ```
44
-
45
- Or use it as a [ PostCSS] plugin:
46
-
47
39
``` js
48
40
const postcss = require (' postcss' );
49
41
const postcssColorFunctionalNotation = require (' postcss-color-functional-notation' );
Original file line number Diff line number Diff line change 26
26
"node" : " >=10.0.0"
27
27
},
28
28
"dependencies" : {
29
- "postcss" : " ^7.0.27" ,
30
- "postcss-values-parser" : " ^3.2.0"
29
+ "postcss-values-parser" : " ^5.0.0"
30
+ },
31
+ "peerDependencies" : {
32
+ "postcss" : " ^8.0.0"
31
33
},
32
34
"devDependencies" : {
33
35
"@babel/core" : " ^7.9.0" ,
34
36
"@babel/preset-env" : " ^7.9.5" ,
35
37
"babel-eslint" : " ^10.1.0" ,
36
38
"eslint" : " ^6.8.0" ,
37
- "postcss-tape" : " ^5.0.2" ,
39
+ "postcss" : " ^8.0.5" ,
40
+ "postcss-tape" : " ^6.0.0" ,
38
41
"pre-commit" : " ^1.2.2" ,
39
42
"rollup" : " ^2.7.2" ,
40
43
"rollup-plugin-babel" : " ^4.4.0"
Original file line number Diff line number Diff line change 1
- import postcss from 'postcss'
2
1
import onCSSDeclaration from './onCSSDeclaration'
3
2
import options from './options'
4
3
5
4
/** Transform space and slash separated color functions in CSS. */
6
- const postcssPlugin = postcss . plugin ( 'postcss-color-functional-notation' , opts => {
5
+ export default function postcssColorFunctionalNotation ( opts ) {
7
6
options . preserve = 'preserve' in Object ( opts ) ? Boolean ( opts . preserve ) : false
8
7
9
- return root => {
10
- root . walkDecls ( onCSSDeclaration )
8
+ return {
9
+ postcssPlugin : 'postcss-color-functional-notation' ,
10
+ Declaration : onCSSDeclaration
11
11
}
12
- } )
12
+ }
13
13
14
- export default postcssPlugin
14
+ postcssColorFunctionalNotation . postcss = true
15
15
16
- /** @typedef {import('postcss').Root } CSSRoot */
17
- /** @typedef {(root: CSSRoot) => void } PostCSSTransformCallback */
18
- /** @typedef {(opts: options) => PostCSSTransformCallback } PostCSSPluginInitializer */
16
+ /** @typedef {import('postcss').Root } CSSRoot */
17
+ /** @typedef {(root: CSSRoot) => void } PostCSSTransformCallback */
18
+ /** @typedef {(opts: options) => PostCSSTransformCallback } PostCSSPluginInitializer */
Original file line number Diff line number Diff line change @@ -10,10 +10,6 @@ const onCSSFunction = node => {
10
10
const isRgbWithNumbers = isRgbColorFunctionName ( name ) && isRgbNumberFunctionContents ( nodes )
11
11
const isRgbWithPercents = isRgbColorFunctionName ( name ) && isRgbPercentFunctionContents ( nodes )
12
12
13
- if ( name === 'hsl' && ! isHsl ) {
14
- console . log ( [ name , isHue ( nodes [ 0 ] ) ] , nodes [ 0 ] )
15
- }
16
-
17
13
if ( isHsl || isRgbWithNumbers || isRgbWithPercents ) {
18
14
// rename the Color function to `hsl` or `rgb`
19
15
Object . assign ( node , { name : isHsl ? 'hsl' : 'rgb' } )
You can’t perform that action at this time.
0 commit comments