rework-plugin-function
Advanced tools
Comparing version 0.1.3 to 1.0.0
{ | ||
"name": "rework-plugin-function", | ||
"version": "0.1.3", | ||
"version": "1.0.0", | ||
"description": "function() plugin for rework, formerly included in core", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
rework-plugin-function | ||
==================== | ||
[![Build Status](https://travis-ci.org/reworkcss/rework-plugin-function.png)](https://travis-ci.org/reworkcss/rework-plugin-function) | ||
function() plugin for rework, formerly included in core | ||
Add user-defined CSS functions. | ||
For example create `black(0.5)` shortcut, to replace | ||
long `rgba(0, 0, 0, 0.5)`. | ||
```js | ||
var rework = require('rework'), | ||
var reworkFunction = require('rework-plugin-function'); | ||
var css = rework(css) | ||
.use(reworkFunction({ black: black })) | ||
.toString() | ||
function black(opacity) { | ||
return 'rgba(0, 0, 0, ' + opacity + ')'; | ||
} | ||
``` | ||
User code will receive CSS arguments and replace user-defined function | ||
by returned code. | ||
```css | ||
input { | ||
box-shadow: 0 0 5px black(0.7); | ||
} | ||
``` | ||
yields: | ||
```css | ||
input { | ||
box-shadow: 0 0 5px rgba(0, 0, 0, 0.7); | ||
} | ||
``` | ||
Nested functions works well too: | ||
```javascript | ||
var css = rework(css) | ||
.use(reworkFunction({ | ||
subtract: function(a, b) { return a - b }, | ||
multiply: function(a, b) { return a * b }, | ||
divide: function(a, b) { return a / b }, | ||
floor: Math.floor | ||
})) | ||
.toString() | ||
``` | ||
```css | ||
input { | ||
top: divide(subtract(30, floor(multiply(20, 10))), 2); | ||
} | ||
``` | ||
Would yield: | ||
```css | ||
input { | ||
top: -85; | ||
} | ||
``` |
Sorry, the diff of this file is not supported yet
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
0
69
0
5451
6
84