Skip to content
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

Passing attibute names to mixins as arguments #1172

Closed
custa1200 opened this issue Feb 10, 2013 · 2 comments
Closed

Passing attibute names to mixins as arguments #1172

custa1200 opened this issue Feb 10, 2013 · 2 comments

Comments

@custa1200
Copy link

Hi,
I would like to be able to do something like this:

.TintAttribute(@attibute, @color, @value) {
/* example: .TintAttribute(background-color, @theme-accent1, 85%)*/
@newcolor: hsl(hue(@color), saturation(@color), @value);
@attibute: @newcolor;
}

So that using a mixin I could tint any element or a rule I wished to. It falls over though when I use the @Attribute argument as the attribute in the rule.

@custa1200
Copy link
Author

One way I have thought of achieving this but not sure if there is a better way is:

.TintAttribute(@attibute, @color, @value) when (@attibute = color) {
@newcolor: hsl(hue(@color), saturation(@color), @value);
color: @newcolor;
}

.TintAttribute(@attibute, @color, @value) when (@attibute = background-color) {
@newcolor: hsl(hue(@color), saturation(@color), @value);
background-color: @newcolor;
}

.TintAttribute(@attibute, @color, @value) when (@attibute = border-color) {
@newcolor: hsl(hue(@color), saturation(@color), @value);
border-color: @newcolor;
}

@lukeapage
Copy link
Member

I would just have the hsl(hue(@color), saturation(@color), @value); inline, even if you have some duplication.

Yes, you could do it with guards.

No, there is no way at the moment to have a variable property.. There have been lots of requests for this, so this is a duplicate issue. the first request is at #36.

Closing as duplicate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants