-
Notifications
You must be signed in to change notification settings - Fork 41
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
Strange less-syntax bug #13
Comments
Both examples are incomplete. (Even assuming |
the error looks like it is occurring in cleancss - if you create an example of the output from less and try it in cleancss, i expect it will error.. so this probably needs raising with cleancss.. |
My bad, it's something wrong in mixin... But first variant works as well. |
seven-phases-max: code is based on yours from Stackoverflow :) I wrote to you email about this but has no answer. Can you help to add support for full 'font' properties? |
(probably, though I assume it was not that bloated originally... For a use-case like above I feel I would suggest something like http://stackoverflow.com/questions/27192493) |
No, here is your original mixin: http://stackoverflow.com/questions/25083818/ |
Here my final version of mixin. It contains all that I want, but it very terrible to look. Is it possible to optimize something here? @isresponsive: true;
@font-size-base: 16px;
// Universal value setter
.set-value_(@property; @value; @responsive: @isresponsive) {
// String, percentage and relative unit values
.setter(@p; @v) when not (isnumber(@v)), (ispercentage(@v)), (isem(@v)), (isunit(@v, rem)),
(isunit(@v, ex)), (isunit(@v, ch)), (isunit(@v, vw)), (isunit(@v, vh)),
(isunit(@v, vmin)), (isunit(@v, vmax)) {
@{p}+_: @v;
}
// Non-unit and pixel values
.setter(@p; @v) when (default()) {
& when (@responsive) {
@{p}+_: unit((@v / @font-size-base), rem);
}
& when not (@responsive) {
@{p}+_: unit(@v, px);
}
}
.setter(@property; @value);
// Font support
& when (@property = font) {
@check: ~`function(){var v="@{value}";return !!v.match(/\//)}()`;
@v1-value: ~`function(){var v="@{value}";return parseFloat(v=v.replace(/^(\d+).*\/(\d+).*$/, '$1'))}()`;
@v1-unit: ~`function(){var v="@{value}";return v=v.replace(/^\d+(.*)\/\d+(.*)$/, '$1')}()`;
@v2-value: ~`function(){var v="@{value}";return parseFloat(v=v.replace(/^(\d+).*\/(\d+).*$/, '$2'))}()`;
@v2-unit: ~`function(){var v="@{value}";return v=v.replace(/^\d+(.*)\/\d+(.*)$/, '$2')}()`;
& when (@check) {
.set-value(font-size; unit(@v1-value, @v1-unit); line-height; unit(@v2-value, @v2-unit); @responsive);
}
}
}
.set-value(@args...) when (length(@args) > 1) {
.r(@a) when (extract(@a, length(@a)) = true), (extract(@a, length(@a)) = false) {
@l: (length(@a) - 1);
@responsive: extract(@a, length(@a));
}
.r(@a) when (default()) {
@l: length(@a);
@responsive: @isresponsive;
}
.r(@args);
.i; .i(@i: @l) when (@i > 1) {
.i((@i - 2));
@property: extract(@args, (@i - 1));
@values: extract(@args, @i);
.j(@property; @values; @responsive);
}
.j(@p; @v; @r; @j: length(@v)) when (@j > 0) {
.j(@p; @v; @r; (@j - 1));
.set-value_(@p; extract(@v, @j); @r);
}
} Example: .set-value(font; 14px/230% 'Arial'; margin: 0 16 0 0); Output: font: 14px/230% Arial, Helvetica, sans-serif;
font-size: 0.875rem;
line-height: 230%;
margin: 0 1rem 0 0; |
Sorry for that the discussion went beyond of project "less-plugin-clean-css". |
(Well, my answer in that SO topic only shows how to simplify already about to exist mixin for the particular |
Thanks for answer. |
I'm trying to compile files with this code:
and it was compiled as well.
But this (it compiled as well without clean-css enabled):
thrown an error:
![111](https://cloud.githubusercontent.com/assets/1394335/8886361/8fc4e61c-3271-11e5-8b17-8c8dbf4ad3da.png)
The text was updated successfully, but these errors were encountered: