How can I simplify this .less code to require less repetition (i.e., so that I can have many buttons with normal, rollover, and pressed states without using 3 lines for each button):
.SBtnM(@urlprefix, @width, @height, @urlsuffix) {
width: @width;
height: @height;
background-image: url(%("%s_%s.png", @urlprefix,@urlsuffix));
}
@url1prefix : 'chrome://xtoolbar/skin/img1';
toolbarbutton > .btnCSS1 {.SBtnM(@url1prefix, 42px, 24px,'normal');}
toolbarbutton:hover > .btnCSS1 {.SBtnM(@url1prefix, 42px, 24px, 'rollover');}
toolbarbutton[checked="true"] > .btnCSS1 {.SBtnM(@url1prefix, 42px, 24px, 'pressed');}
Ideally, I would want to be able to use a one-liner to handle all 3 states. E.g., something like this:
.SBtnM(@urlprefix, @width, @height) {
//Magic Happens. This part may become more complicated
}
.btnCSS1 {.SBtnM('chrome://xtoolbar/skin/img1', 42px, 24px);}
Output, for reference:
toolbarbutton > .btnCSS1 {
width: 42px;
height: 24px;
background-image: url("chrome://xtoolbar/skin/img1_normal.png");
}
toolbarbutton:hover > .btnCSS1 {
width: 42px;
height: 24px;
background-image: url("chrome://xtoolbar/skin/img1_rollover.png");
}
toolbarbutton[checked="true"] > .btnCSS1 {
width: 42px;
height: 24px;
background-image: url("chrome://xtoolbar/skin/img1_pressed.png");
}
As far as I can tell, .less doesn't have any sort of parent selector for mixins.