I am trying to write a mixin for border-radius than only outputs when the values, set by a variable, are >= 0. I set the base value in a variable as 3px, so if I enter -1 or no for example, the border-radius mixin would not create any properties in the final stylesheet. I can get this to work for if I want to have the same value for every corner. But I can't workout how to get it working if I want to use the shorthand i.e 3px 3px 0 0. I think it is an issue with the 3px being changed by a variable and 0 in both scenarios. My code at the moment is
.border-radius(@r) when not (@r = no), (@r = 0) {
-webkit-border-radius: @r;
-moz-border-radius: @r;
border-radius: @r;
}
.border-radius(@r) when (@r = no), (@r = 0) {}
@baseBorderRadius: 3px;
.class1 { .border-radius(@baseBorderRadius); }
// This outputs fine: 3px 3px 3px 3px
.class2 { .border-radius(@baseBorderRadius @baseBorderRadius 0 0); }
// This outputs fine 3px 3px 0 0
@baseBorderRadius: no; // If I change the variable to try and disable/not run the mixin
.class1 { .border-radius(@baseBorderRadius); }
// This does what I want and doesn't run the mixin
.class2 { .border-radius(@baseBorderRadius @baseBorderRadius 0 0); }
// THIS IS THE PROBLEM! This outputs: no no 0 0
So I need a way to disable/not run the mixin if it contains a certain value or word defined from a global variable. I am doing this for a theme variables file where, based on the branding, companies might want rounded corners or not and I would prefer not to have loads of 0 values unnecessarily included in the final stylesheet.
I would really appreciate any help with this, even if it is just to find out that what I want to do isn't possible within LESS. Thank you