Merge "Fix highlight display for enhanced mode"
[lhc/web/wiklou.git] / resources / src / mediawiki.rcfilters / styles / mw.rcfilters.mixins.less
1 @import 'mediawiki.mixins';
2 @import 'mw.rcfilters.variables';
3
4 .animation-delay( ... ) {
5 -webkit-animation-delay: @arguments; // Chrome 4-42, Safari 4-8, Opera 15-29, Android 2.1-4.4.4
6 -moz-animation-delay: @arguments; // Firefox 5-15
7 animation-delay: @arguments; // Chrome 43+, Firefox 16+, IE 10+, Edge 12+, Safari 9+, Opera 12.10 & 30+, iOS 9+, Android 47+
8 }
9
10 // This is a general mixin for a color circle
11 .mw-rcfilters-mixin-circle( @color: #fff, @diameter: 2em, @padding: 0.5em, @border: false, @borderColor: #54595d, @emptyBackground: false ) {
12 .box-sizing( border-box );
13 min-width: @diameter;
14 width: @diameter;
15 min-height: @diameter;
16 height: @diameter;
17 margin: @padding;
18 border-radius: 50%;
19
20 & when ( @emptyBackground = false ) {
21 background-color: @color;
22 }
23 & when ( @emptyBackground = true ) {
24 background-color: @highlight-none;
25 }
26
27 & when ( @border = true ) {
28 border: 1px solid @borderColor;
29 }
30 }
31
32 // This is the circle that appears next to the results
33 // Its visibility is directly dependent on whether there is
34 // a color class on its parent element
35 .result-circle( @colorName: 'none' ) {
36 &-@{colorName} {
37 .mw-rcfilters-mixin-circle( ~'@{highlight-@{colorName}}', @result-circle-diameter, 0 );
38 display: none;
39
40 .mw-rcfilters-highlight-color-@{colorName} & {
41 display: inline-block;
42 }
43 }
44 }
45
46 // A mixin just for changesListWrapperWidget page, to output the scope of the widget
47 // so it is before the rest of the rule; we need the li& to be in
48 // between the wrapper scope and the color-cX class, which doesn't
49 // work if the rules are inside the above widget LESS scope
50 .highlight-changesListWrapperWidget( @bgcolor ) {
51 .mw-rcfilters-ui-changesListWrapperWidget li&,
52 .mw-rcfilters-ui-changesListWrapperWidget & tr:first-child,
53 .mw-rcfilters-ui-changesListWrapperWidget tr&.mw-rcfilters-ui-changesListWrapperWidget-enhanced-toplevel:not(.mw-rcfilters-ui-changesListWrapperWidget-enhanced-grey) td:not( :nth-child( -n+2 ) ),
54 .mw-rcfilters-ui-changesListWrapperWidget tr&.mw-rcfilters-ui-changesListWrapperWidget-enhanced-nested:not(.mw-rcfilters-ui-changesListWrapperWidget-enhanced-grey) td:not( :nth-child( -n+3 ) ) {
55 background-color: @bgcolor;
56 }
57 }
58
59 // This mixin produces color mixes for two, three and four colors
60 .highlight-color-mix( @color1, @color2, @color3: false, @color4: false ) {
61 @highlight-color-class-var: ~'.mw-rcfilters-highlight-color-@{color1}.mw-rcfilters-highlight-color-@{color2}';
62
63 // The nature of these variables and them being inside
64 // a 'tint' and 'average' LESS functions is such where
65 // the parsing is failing if it is done inside those functions.
66 // Instead, we first construct their LESS variable names,
67 // and then we call them inside those functions by calling @@var
68 @c1var: ~'highlight-@{color1}';
69 @c2var: ~'highlight-@{color2}';
70
71 // Two colors
72 @{highlight-color-class-var} when ( @color3 = false ) and ( @color4 = false ) and not ( @color1 = false ), ( @color2 = false ) {
73 .highlight-changesListWrapperWidget( tint( average( @@c1var, @@c2var ), 50% ) );
74 }
75 // Three colors
76 @{highlight-color-class-var}.mw-rcfilters-highlight-color-@{color3} when ( @color4 = false ) and not ( @color3 = false ) {
77 @c3var: ~'highlight-@{color3}';
78 .highlight-changesListWrapperWidget( tint( mix( @@c1var, average( @@c2var, @@c3var ), 33% ), 30% ) );
79 }
80
81 // Four colors
82 @{highlight-color-class-var}.mw-rcfilters-highlight-color-@{color3}.mw-rcfilters-highlight-color-@{color4} when not ( @color4 = false ) {
83 @c3var: ~'highlight-@{color3}';
84 @c4var: ~'highlight-@{color4}';
85 .highlight-changesListWrapperWidget( tint( mix( @@c1var, mix( @@c2var, average( @@c3var, @@c4var ), 25% ), 25% ), 25% ) );
86 }
87 }