File tree Expand file tree Collapse file tree 4 files changed +29
-38
lines changed Expand file tree Collapse file tree 4 files changed +29
-38
lines changed Original file line number Diff line number Diff line change
1
+ # 2.0.0 - 2014-08-06
2
+
3
+ * Plugin now return a function to have a consistent api. ([ ref1] ( https://github.com/ianstormtaylor/rework-color-function/issues/6 ) , [ ref2] ( https://twitter.com/jongleberry/status/496552790416576513 ) )
4
+
1
5
# 1.0.0 - 2014-08-04
2
6
3
7
First release based on [ rework-calc] ( https://github.com/reworkcss/rework-calc ) v1.1.0 (code mainly exported to [ ` reduce-css-calc ` ] ( https://github.com/MoOx/reduce-css-calc ) )
Original file line number Diff line number Diff line change @@ -17,7 +17,10 @@ npm install postcss-calc
17
17
var postcss = require (" postcss" )
18
18
var calc = require (" postcss-calc" )
19
19
20
- var css = postcss (calc).process (cssString).css ;
20
+ var css = postcss ()
21
+ .use (calc ())
22
+ .process (cssString)
23
+ .css
21
24
```
22
25
23
26
## Supported feature
@@ -41,7 +44,7 @@ var css = fs.readFileSync("style.css", "utf8")
41
44
42
45
var output = postcss ()
43
46
.use (customProperties ())
44
- .use (calc)
47
+ .use (calc () )
45
48
.process (css)
46
49
.css
47
50
```
Original file line number Diff line number Diff line change 1
1
/**
2
2
* Module dependencies.
3
3
*/
4
- var reduceCssCalc = require ( "reduce-css-calc" )
4
+ var reduceCSSCalc = require ( "reduce-css-calc" )
5
5
6
6
/**
7
7
* Expose `plugin`.
@@ -10,47 +10,31 @@ var reduceCssCalc = require("reduce-css-calc")
10
10
module . exports = plugin
11
11
12
12
/**
13
- * Plugin to convert CSS color functions .
13
+ * Plugin to convert all function calls .
14
14
*
15
15
* @param {Object } stylesheet
16
16
*/
17
17
18
- function plugin ( style ) {
19
- style . eachRule ( rule )
20
- }
21
-
22
- /**
23
- * Convert an entire `rule`.
24
- *
25
- * @param {Object } rule
26
- */
27
-
28
- function rule ( obj ) {
29
- obj . each ( declaration )
30
- }
31
-
32
- /**
33
- * Convert a declaration.
34
- *
35
- * @param {Object } dec
36
- */
37
-
38
- function declaration ( dec ) {
39
- if ( ! dec . value ) {
40
- return
41
- }
42
-
43
- try {
44
- dec . value = convert ( dec . value )
45
- }
46
- catch ( err ) {
47
- err . position = dec . position
48
- throw err
18
+ function plugin ( ) {
19
+ return function ( style ) {
20
+ style . eachDecl ( function declaration ( dec ) {
21
+ if ( ! dec . value ) {
22
+ return
23
+ }
24
+
25
+ try {
26
+ dec . value = convert ( dec . value )
27
+ }
28
+ catch ( err ) {
29
+ err . position = dec . position
30
+ throw err
31
+ }
32
+ } )
49
33
}
50
34
}
51
35
52
36
/**
53
- * Reduce css calc()
37
+ * Reduce CSS calc()
54
38
*
55
39
* @param {String } string
56
40
* @return {String }
@@ -61,5 +45,5 @@ function convert(string) {
61
45
return string
62
46
}
63
47
64
- return reduceCssCalc ( string )
48
+ return reduceCSSCalc ( string )
65
49
}
Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ function fixture(name) {
13
13
test ( "resolve what is possible in complex calc" , function ( t ) {
14
14
var actual = postcss ( )
15
15
. use ( customProperties ( ) )
16
- . use ( calc )
16
+ . use ( calc ( ) )
17
17
. process ( fixture ( "calc" ) )
18
18
. css
19
19
. trim ( )
You can’t perform that action at this time.
0 commit comments