3

I'm trying to make a Mixin output two different things based on context. Like so:

.seticon(@r,@g,@b) {
    b {
        background-color: rgb(@r,@g,@b);
    }
    &.act b {
        .box-shadow(0 0 5px 1px rgba(@r,@g,@b,0.45));
    }
    &.act.hover b {
        background: #000;
        .box-shadow(inset 0 0 0 3px rgb(@r,@g,@b) !important;
    }
}

.nonreceivable {
    .seticon(@r,@g,@b) {
        b {
            background: #000 !important;
            .box-shadow(inset 0 0 0 2px rgb(@r,@g,@b));
        }
    }
}

Now .seticon works as expected, but .nonreceivable .seticon doesn't seem to work. Is this a bug, or am I doing something wrong or isn't this intended by the Less developers? How would you instead solve this?

Harry
  • 87,580
  • 25
  • 202
  • 214

1 Answers1

0

Is nonreceivable class applied to the same element or parent element? if it's parent, it should work. Otherwise, put an & in front of .section

.nonreceivable {
 &.seticon(@r,@g,@b) {
    b {
        background: #000 !important;
        .box-shadow(inset 0 0 0 2px rgb(@r,@g,@b));
    }
}
}
Aakash Goel
  • 1,169
  • 2
  • 13
  • 22
  • 1
    Adding a `&` in front of the mixin name wouldn't really work mate. It would actually cause a compile error (atleast in the latest versions of the compiler). – Harry Oct 20 '14 at 12:19