Skip to content

Milstone 0.0.19 #43

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Apr 2, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
root = true

[*]
indent_style = tab
[*.*]
indent_style = space
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[{package.json,*.yml}]
indent_style = space
indent_size = 2

[*.js]
indent_style = tab

[*.md]
trim_trailing_whitespace = false
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
## [0.0.19] - 02-04-2016
### Added
- Added #34, husky

### Change
- Change #40, update .editorconfig, change tab to space all and js to tab
- Change #5, update readme change tab to space
- Change #37, testing src instead lib
- Move #35, updtr to npm run updateDev
- Change #42, lodash merge to deep-assign

### Remove
- Remove #36, balance-match not used

### Fixed
- Fixed #39, resolve export default for require

## [0.0.18] - 18-03-2016
### Added
- Added #1, ava
Expand Down
72 changes: 36 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,44 +9,44 @@ Used in conjunction with the plugin [postcss-each], [postcss-conditionals], [pos
```css
/* input.css */
:root {
--array: foo, bar, baz;
--from: 1;
--to: 3;
--icon-exclude: 2;
--color-danger: red;
--array: foo, bar, baz;
--from: 1;
--to: 3;
--icon-exclude: 2;
--color-danger: red;
}

@each $val in var(--array) {
@import "$val.css";
@import "$val.css";
}
```

```css
/* foo.css */
html {
background-color: var(--color-danger);
background-color: var(--color-danger);
}
```

```css
/* bar.css */
.some-class {
color: #fff;

@for $val from var(--from) to var(--to) {
@if $val != var(--icon-exclude) {
.icon-$val {
background-position: 0 $(val)px;
}
}
}
color: #fff;

@for $val from var(--from) to var(--to) {
@if $val != var(--icon-exclude) {
.icon-$val {
background-position: 0 $(val)px;
}
}
}
}
```

```css
/* baz.css */
h1 {
font-size: 24px;
font-size: 24px;
}

@import "biz.css";
Expand All @@ -55,29 +55,29 @@ h1 {
```css
/* biz.css */
h2 {
color: olive;
color: olive;
}
```

```css
/* Output example */
html {
background-color: red;
background-color: red;
}
.some-class {
color: #fff;
.icon-1 {
background-position: 0 1px;
}
.icon-3 {
background-position: 0 3px;
}
color: #fff;
.icon-1 {
background-position: 0 1px;
}
.icon-3 {
background-position: 0 3px;
}
}
h1 {
font-size: 24px;
font-size: 24px;
}
h2 {
color: olive;
color: olive;
}

```
Expand All @@ -97,7 +97,7 @@ var fs = require("fs");
var postcss = require("postcss");
var atImport = require("postcss-import");
var atEach = require("postcss-each");
var atVariables = require("postcss-at-rules-variables").default;
var atVariables = require("postcss-at-rules-variables");
var atIf = require('postcss-conditionals');
var atFor = require('postcss-for');
var customProperties = require("postcss-custom-properties");
Expand All @@ -111,10 +111,10 @@ var output = postcss()
.use(atVariables({ /* options */ }))
.use(atEach())
.use(atImport({
plugins: [
require("postcss-at-rules-variables").default({ /* options */ }),
require("postcss-import")
]
plugins: [
require("postcss-at-rules-variables").default({ /* options */ }),
require("postcss-import")
]
}))
.use(atFor())
.use(atIf())
Expand All @@ -136,6 +136,6 @@ Default: `['for', 'if', 'else', 'each']`

See [PostCSS](https://github.com/postcss/postcss) docs for examples for your environment.

[postcss-conditionals]: https://github.com/andyjansson/postcss-conditionals
[postcss-each]: https://github.com/outpunk/postcss-each
[postcss-for]: https://github.com/antyakushev/postcss-for
[postcss-conditionals]: https://github.com/andyjansson/postcss-conditionals
[postcss-each]: https://github.com/outpunk/postcss-each
[postcss-for]: https://github.com/antyakushev/postcss-for
15 changes: 11 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
{
"name": "postcss-at-rules-variables",
"version": "0.0.18",
"version": "0.0.19",
"description": "PostCss plugin to use CSS Custom Properties in at-rule @each, @for, @if, @else ",
"main": "./lib/index.js",
"scripts": {
"test": "xo ./src/*.js ./test/*.js && nyc ava",
"clean": "rm -rf lib && mkdir lib",
"build": "npm run clean && babel src/index.js --out-file lib/index.js && npm t",
"prepublish": "updtr && npm run build"
"postinstall": "npm run updateDev",
"prepublish": "npm run build",
"prepush": "npm test",
"updateDev": "updtr"
},
"keywords": [
"postcss",
Expand All @@ -29,23 +32,27 @@
},
"license": "MIT",
"dependencies": {
"balanced-match": "^0.3.0",
"lodash": "^4.6.1",
"deep-assign": "^2.0.0",
"postcss": "^5.0.19"
},
"devDependencies": {
"ava": "^0.13.0",
"babel-cli": "^6.6.5",
"babel-plugin-add-module-exports": "^0.1.2",
"babel-preset-node5": "^11.0.0",
"babel-register": "^6.7.2",
"coveralls": "^2.11.8",
"husky": "^0.11.4",
"nyc": "^6.1.1",
"updtr": "^0.1.7",
"xo": "^0.13.0"
},
"babel": {
"presets": [
"node5"
],
"plugins": [
"add-module-exports"
]
},
"ava": {
Expand Down
4 changes: 2 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import postcss from 'postcss';
import {merge} from 'lodash';
import deepAssign from 'deep-assign';

const VAR_FUNC_IDENTIFIER = 'var';
const maps = {};
Expand All @@ -18,7 +18,7 @@ export default postcss.plugin('postcss-at-rules-variables', options => {
atRules: ['for', 'if', 'else', 'each']
};

const mergeOptions = merge(DEFAULT, options, (a, b) => {
const mergeOptions = deepAssign(DEFAULT, options, (a, b) => {
if (Array.isArray(a)) {
return a.concat(b);
}
Expand Down
6 changes: 3 additions & 3 deletions test/test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import postcss from 'postcss';
import test from 'ava';
import plugin from '../lib/index';
import plugin from '../src/index';

const processing = (input, opts) => {
return postcss([plugin(opts)]).process(input).css;
Expand Down Expand Up @@ -43,8 +43,8 @@ test('it change two properties for @if, @else if', t => {
});

test('it change multi properties for @each', t => {
const expected = ':root{ --array: foo, bar, baz; } @each $val in foo, bar, baz';
const value = ':root{ --array: foo, bar, baz; } @each $val in var(--array)';
const expected = ':root{ --array: foo, bar, baz; } @each $val in foo, bar, baz @for foo, bar, baz';
const value = ':root{ --array: foo, bar, baz; } @each $val in var(--array) @for var(--array)';
t.is(processing(value, {atRules: ['each']}), expected);
});

Expand Down