Skip to content

Commit 3095366

Browse files
authored
Merge pull request #155 from GitScrum/milestone-0.1.0
Milestone 0.1.0
2 parents 7c7befe + 56d017d commit 3095366

File tree

5 files changed

+60
-22
lines changed

5 files changed

+60
-22
lines changed

changelog.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,25 @@
1+
<a name="0.1.0"></a>
2+
# 0.1.0 (2017-04-05)
3+
4+
* 0.1.0 ([aecb563](https://github.com/gitscrum/postcss-at-rules-variables/commit/aecb563))
5+
* style(readme): fix linting ([86d8219](https://github.com/gitscrum/postcss-at-rules-variables/commit/86d8219))
6+
* style(readme): remove testen badges ([e5c9162](https://github.com/gitscrum/postcss-at-rules-variables/commit/e5c9162))
7+
* docs(readme): add description for #153 ([c0ae1ed](https://github.com/gitscrum/postcss-at-rules-variables/commit/c0ae1ed))
8+
* test(test): add test for #153 ([11ae22d](https://github.com/gitscrum/postcss-at-rules-variables/commit/11ae22d))
9+
* feat(index): add programmatically-defined variables, #153 ([d1d3800](https://github.com/gitscrum/postcss-at-rules-variables/commit/d1d3800))
10+
* chore(changelog): Update changelog ([0bfcb24](https://github.com/gitscrum/postcss-at-rules-variables/commit/0bfcb24))
11+
* chore(package): update ava-codemods to version 0.3.2 ([0b07f87](https://github.com/gitscrum/postcss-at-rules-variables/commit/0b07f87))
12+
* chore(package): update babel-preset-babili to version 0.0.11 ([4920d1f](https://github.com/gitscrum/postcss-at-rules-variables/commit/4920d1f))
13+
* chore(package): update babel-preset-env to version 1.3.2 ([d2990cb](https://github.com/gitscrum/postcss-at-rules-variables/commit/d2990cb))
14+
* chore(package): update clean and build script ([3748c21](https://github.com/gitscrum/postcss-at-rules-variables/commit/3748c21))
15+
* chore(package): update conventional-changelog-lint to version 1.1.8 ([9a03d4c](https://github.com/gitscrum/postcss-at-rules-variables/commit/9a03d4c))
16+
* chore(package): update coveralls to version 2.13.0 ([ed57585](https://github.com/gitscrum/postcss-at-rules-variables/commit/ed57585))
17+
* chore(package): update depDev ([31640b9](https://github.com/gitscrum/postcss-at-rules-variables/commit/31640b9))
18+
* chore(package): update eslint to version 3.19.0 ([e6debca](https://github.com/gitscrum/postcss-at-rules-variables/commit/e6debca))
19+
* chore(package): update updtr to version 1.0.0 ([2219b61](https://github.com/gitscrum/postcss-at-rules-variables/commit/2219b61))
20+
21+
22+
123
<a name="0.0.27"></a>
224
## 0.0.27 (2017-02-01)
325

package.json

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "postcss-at-rules-variables",
3-
"version": "0.0.27",
3+
"version": "0.1.0",
44
"description": "PostCss plugin to use CSS Custom Properties in at-rule @each, @for, @if, @else ",
55
"license": "MIT",
66
"repository": "gitscrum/postcss-at-rules-variables",
@@ -21,10 +21,9 @@
2121
"patch": "np patch --any-branch",
2222
"minor": "np minor --any-branch",
2323
"major": "np major --any-branch",
24-
"clean": "rm -rf lib && mkdir lib",
25-
"build": "npm run clean && babel src/ -d lib/",
24+
"build": "rimraf lib && babel src -d lib",
2625
"prepublish": "npm run build",
27-
"lintjs": "eslint ./src/*.js ./test/*.js",
26+
"lintjs": "eslint ./{src,test}/*.js",
2827
"lintmd": "eslint --ext md --rule indent: [error, 4] .",
2928
"pretest": "clinton && npm run lintjs && npm run lintmd",
3029
"test": "nyc ava",
@@ -52,30 +51,31 @@
5251
},
5352
"devDependencies": {
5453
"ava": "*",
55-
"ava-codemods": "^0.3.1",
54+
"ava-codemods": "^0.3.2",
5655
"babel-cli": "^6.22.2",
57-
"babel-eslint": "^7.0.0",
56+
"babel-eslint": "^7.2.1",
5857
"babel-plugin-add-module-exports": "^0.2.1",
59-
"babel-preset-babili": "0.0.10",
60-
"babel-preset-env": "^1.1.8",
58+
"babel-preset-babili": "^0.0.12",
59+
"babel-preset-env": "^1.3.2",
6160
"babel-register": "^6.22.0",
6261
"clinton": "^0.11.0",
63-
"conventional-changelog-cli": "^1.2.0",
64-
"conventional-changelog-lint": "^1.1.0",
65-
"coveralls": "^2.11.9",
66-
"eslint": "^3.14.1",
67-
"eslint-config-xo": "^0.17.0",
62+
"conventional-changelog-cli": "^1.3.1",
63+
"conventional-changelog-lint": "^1.1.8",
64+
"coveralls": "^2.13.0",
65+
"eslint": "^3.19.0",
66+
"eslint-config-xo": "^0.18.1",
6867
"eslint-formatter-pretty": "^1.1.0",
6968
"eslint-plugin-ava": "^4.0.1",
7069
"eslint-plugin-babel": "^4.0.1",
71-
"eslint-plugin-markdown": "^1.0.0-beta.2",
70+
"eslint-plugin-markdown": "^1.0.0-beta.4",
7271
"eslint-plugin-require-path-exists": "^1.1.5",
7372
"eslint-plugin-xo": "^1.0.0",
7473
"husky": "^0.13.1",
7574
"np": "^2.12.0",
7675
"nyc": "^10.1.0",
77-
"testen": "^1.8.2",
78-
"updtr": "^0.2.1"
76+
"rimraf": "^2.6.1",
77+
"testen": "^2.2.0",
78+
"updtr": "^1.0.0"
7979
},
8080
"testen": {
8181
"node": [

readme.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# postcss-at-rules-variables <a href="https://github.com/postcss/postcss"><img align="left" height="49" title="PostCSS" src="http://postcss.github.io/postcss/logo.svg"></a>
22
> [PostCSS](https://github.com/postcss/postcss) plugin to transform [W3C CSS Custom Properties](http://www.w3.org/TR/css-variables/) for at-rule’s parameters.
33
4-
[![Travis Build Status](https://img.shields.io/travis/GitScrum/postcss-at-rules-variables.svg?style=flat-square&label=unix)](https://travis-ci.org/GitScrum/postcss-at-rules-variables)[![AppVeyor Build Status](https://img.shields.io/appveyor/ci/GitScrum/postcss-at-rules-variables.svg?style=flat-square&label=windows)](https://ci.appveyor.com/project/GitScrum/postcss-at-rules-variables)[![testen badge](https://img.shields.io/badge/testen-passing-brightgreen.svg?style=flat-square)][testen repo][![node](https://img.shields.io/node/v/postcss-at-rules-variables.svg?maxAge=2592000&style=flat-square)]()[![npm version](https://img.shields.io/npm/v/postcss-at-rules-variables.svg?style=flat-square)](https://www.npmjs.com/package/postcss-at-rules-variables)[![Dependency Status](https://david-dm.org/gitscrum/postcss-at-rules-variables.svg?style=flat-square)](https://david-dm.org/gitscrum/postcss-at-rules-variables)[![XO code style](https://img.shields.io/badge/code_style-XO-5ed9c7.svg?style=flat-square)](https://github.com/sindresorhus/xo)[![Coveralls status](https://img.shields.io/coveralls/GitScrum/postcss-at-rules-variables.svg?style=flat-square)](https://coveralls.io/r/GitScrum/postcss-at-rules-variables)
4+
[![Travis Build Status](https://img.shields.io/travis/GitScrum/postcss-at-rules-variables/master.svg?style=flat-square&label=unix)](https://travis-ci.org/GitScrum/postcss-at-rules-variables)[![AppVeyor Build Status](https://img.shields.io/appveyor/ci/GitScrum/postcss-at-rules-variables/master.svg?style=flat-square&label=windows)](https://ci.appveyor.com/project/GitScrum/postcss-at-rules-variables)[![node](https://img.shields.io/node/v/postcss-at-rules-variables.svg?maxAge=2592000&style=flat-square)]()[![npm version](https://img.shields.io/npm/v/postcss-at-rules-variables.svg?style=flat-square)](https://www.npmjs.com/package/postcss-at-rules-variables)[![Dependency Status](https://david-dm.org/gitscrum/postcss-at-rules-variables.svg?style=flat-square)](https://david-dm.org/gitscrum/postcss-at-rules-variables)[![XO code style](https://img.shields.io/badge/code_style-XO-5ed9c7.svg?style=flat-square)](https://github.com/sindresorhus/xo)[![Coveralls status](https://img.shields.io/coveralls/GitScrum/postcss-at-rules-variables.svg?style=flat-square)](https://coveralls.io/r/GitScrum/postcss-at-rules-variables)
55

66
[![npm downloads](https://img.shields.io/npm/dm/postcss-at-rules-variables.svg?style=flat-square)](https://www.npmjs.com/package/postcss-at-rules-variables)[![npm](https://img.shields.io/npm/dt/postcss-at-rules-variables.svg?style=flat-square)](https://www.npmjs.com/package/postcss-at-rules-variables)[![Package Quality](http://npm.packagequality.com/shield/postcss-at-rules-variables.svg?style=flat-square)](http://packagequality.com/#?package=postcss-at-rules-variables)[![BADGINATOR](https://badginator.herokuapp.com/gitscrum/postcss-at-rules-variables.svg?style=flat-square)](https://github.com/gitscrum/postcss-at-rules-variables)
77

@@ -21,7 +21,7 @@ $ npm install postcss-at-rules-variables
2121
## Usage
2222

2323
```js
24-
// dependencies
24+
// Dependencies
2525
var fs = require('fs');
2626
var postcss = require('postcss');
2727
var atImport = require('postcss-import');
@@ -32,10 +32,10 @@ var atFor = require('postcss-for');
3232
var customProperties = require('postcss-custom-properties');
3333
var nested = require('postcss-nested');
3434

35-
// css to be processed
35+
// CSS to be processed
3636
var css = fs.readFileSync('css/input.css', 'utf8');
3737

38-
// process css
38+
// Process CSS
3939
var output = postcss()
4040
.use(atVariables({ /* atRules: ['media'] */ }))
4141
.use(atEach())
@@ -149,6 +149,12 @@ Type: `Array`
149149
Default: `['for', 'if', 'else', 'each', 'mixin', 'custom-media']`
150150
Description: *The array used in all at-rules in your project*
151151

152+
#### `variables`
153+
154+
Type: `Object`
155+
Default: `{}`
156+
Description: *Allows you to pass an object of variables for `:root`. These definitions will override any that exist in the CSS*
157+
152158
## LICENSE
153159

154160
> MIT License (MIT)

src/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,12 @@ function getProperty(nodes) {
2626

2727
export default postcss.plugin('postcss-at-rules-variables', (options = {}) => {
2828
options = {
29-
atRules: [...new Set(['for', 'if', 'else', 'each', 'mixin', 'custom-media', ...options.atRules || ''])]
29+
atRules: [...new Set(['for', 'if', 'else', 'each', 'mixin', 'custom-media', ...options.atRules || ''])],
30+
variables: options.variables || {}
3031
};
3132

3233
return nodes => {
33-
const maps = getProperty(nodes);
34+
const maps = Object.assign(getProperty(nodes), options.variables);
3435

3536
nodes.walkAtRules(new RegExp(options.atRules.join('|')), rules => {
3637
rules.params = resolveValue(rules.params, maps);

test/test.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,15 @@ test('it without variables', t => {
5454
t.is(processing(value), expected);
5555
});
5656

57+
test('chould change from options variables', t => {
58+
const expected = '@if green { .text-green { color: var(--green) }}';
59+
const value = '@if var(--green) { .text-green { color: var(--green) }}';
60+
const variables = {
61+
'--green': 'green'
62+
};
63+
t.is(processing(value, {variables: variables}), expected);
64+
});
65+
5766
test('should change for @custom-media', t => {
5867
const expected = ':root{ --breakpoint-xs: 29.25em } @custom-media --viewport-xs (width > 29.25em)';
5968
const value = ':root{ --breakpoint-xs: 29.25em } @custom-media --viewport-xs (width > var(--breakpoint-xs))';

0 commit comments

Comments
 (0)