Question

My mixin doesn 't work with 2 conditions (if is not = A or B...); My mixin :

.fontFamily(@font-family,@parent:arial) when not (@font-family = @parent) , not (@font-family = inherit)  {
font-family: "@{font-family}";}

My less file :

@font:arial;
.myclass{
.fontFamily(@font);
}

If i have only one condition, it works...but the 2 conditions in the same mixin, it doesn t work.

Was it helpful?

Solution

Logical not(A or B) is equal to not(A) and not(B) so you need to use and instead of comma (which is or), i.e.:

.fontFamily(@font-family, @parent: arial) when
    not(@font-family = @parent) and
    not(@font-family = inherit) {
        font-family: "@{font-family}";
}

.myclass-1 {
    .fontFamily(arial);
}

.myclass-2 {
    .fontFamily(inherit);
}

.myclass-3 {
    .fontFamily(laira);
}

CSS output:

.myclass-3 {
  font-family: "laira";
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top