-
-
Notifications
You must be signed in to change notification settings - Fork 46
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
property name #1
Comments
Not now. There is limitation in PostCSS parser. But I plan to fix it in next parser release: postcss/postcss#185 Right now you can create JS mixin: var postcss = require('postcss');
item: function (mixin, prop) {
for ( var i = 0; i < 12; i++ ) {
var rule = postcss.rule({ selector: '&-' + i });
var rule.append({ prop: prop, value: (i * 8.33333333) + '%' });
mixin.insertBefore(rule);
}
}; |
Cool, thanks! var gulp = require('gulp'). postcss = require('gulp-postcss');
gulp.src('src.css')
.pipe(postcss([
require('postcss-mixin')({
mixins: {
item: function () {
//
}
}
})
])) |
Nope :(. Why you need PostCSS instance there? |
To make mixin I need require and gulp-postcss and postcss. I think this is excess. |
Just add |
Okey. I just like to optimize anything like in browser. |
Maybe you will pass instance in this? |
|
Maybe in the next release? It would be more elegant for gulp. |
Why one line of Problem is very simple:
So if I add |
mixin.insertBefore doesn't work
.pipe(gulp_postcss([
require('postcss-mixins')({
mixins: {
item: function (mixin, prop) {
var rule, i, val;
for(i = 1; i <= 12; i++ ) {
rule = postcss.rule({
selector: '&-' + i
});
val = i / 12 * 100;
rule.append({
prop: prop,
value: val.toFixed(val % 1 === 0 ? 0 : 4) + '%'
});
mixin.insertBefore(rule);
}
}
}
}),
require('postcss-custom-properties')(),
require('postcss-nested'),
require('postcss-calc')()
])) |
Please, post a full stack trace. I can’t help by this small message :). |
BTW, you can clean .pipe(gulp_postcss([
require('postcss-mixins')({
mixinsDir: __dirname + '/postcss/mixins/';
}),
require('postcss-custom-properties')(),
require('postcss-nested'),
require('postcss-calc')()
])) and put JS-mixin to var postcss = require('postcss');
module.exports = function (mixin, prop) {
var rule, i, val;
for(i = 1; i <= 12; i++ ) {
rule = postcss.rule({ selector: '&-' + i });
val = i / 12 * 100;
rule.append({
prop: prop,
value: val.toFixed(val % 1 === 0 ? 0 : 4) + '%'
});
mixin.insertBefore(rule);
}
} |
I found a problem. Use |
Thank you very much, Andrey! P.S. Don't forget to update documentation. Mixins is a good thing. |
@TrySound what docs update you ask? |
Like this? 5e9fe94 |
No, like this |
@TrySound here is all docs https://github.com/postcss/postcss/blob/master/API.md What are you ask? |
In this repo:
|
Я тебя совсем не понимаю. Объясни с самого начала, что ты хочешь. |
В документации к миксинам в разделе Function Mixin исправить добавление правила. |
А, я исправил вот так 8cccd2a |
Thanks) |
Close this issue, because we have same in PostCSS about variables |
Does argument work for property name?
The text was updated successfully, but these errors were encountered: