123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
-
- .light when (lightness(@a) > 50%) {
- color: green;
- }
- .dark when (lightness(@a) < 50%) {
- color: orange;
- }
- @a: #ddd;
- .see-the {
- @a: #444; // this mirrors what mixins do - they evaluate the guards at the point of definition
- .light();
- .dark();
- }
- .hide-the {
- .light();
- .dark();
- }
- .multiple-conditions-1 when (@b = 1), (@c = 2), (@d = 3) {
- color: red;
- }
- .multiple-conditions-2 when (@b = 1), (@c = 2), (@d = 2) {
- color: blue;
- }
- @b: 2;
- @c: 3;
- @d: 3;
- .inheritance when (@b = 2) {
- .test {
- color: black;
- }
- &:hover {
- color: pink;
- }
- .hideme when (@b = 1) {
- color: green;
- }
- & when (@b = 1) {
- hideme: green;
- }
- }
- .hideme when (@b = 1) {
- .test {
- color: black;
- }
- &:hover {
- color: pink;
- }
- .hideme when (@b = 1) {
- color: green;
- }
- }
- & when (@b = 1) {
- .hideme {
- color: red;
- }
- }
- .mixin-with-guard-inside(@colWidth) {
- // selector with guard (applies also to & when() ...)
- .clsWithGuard when (@colWidth <= 0) {
- dispaly: none;
- }
- }
- .mixin-with-guard-inside(0px);
- .dont-split-me-up {
- width: 1px;
- & when (@c = 3) {
- color: red;
- }
- & when (@c = 3) {
- height: 1px;
- }
- + & when (@c = 3) { // creates invalid css but tests that we don't fold it in
- sibling: true;
- }
- }
- .scope-check when (@c = 3) {
- @k: 1px;
- & when (@c = 3) {
- @k: 2px;
- sub-prop: @k;
- }
- prop: @k;
- }
- .scope-check-2 {
- .scope-check();
- @k:4px;
- }
- .errors-if-called when (@c = never) {
- .mixin-doesnt-exist();
- }
- a:hover when (2 = true) {5:-}
|