Merge "Fix documentation of languageinfo name prop"
[lhc/web/wiklou.git] / resources / src / mediawiki.less / mediawiki.mixins.less
1 // Common LESS mixin library for MediaWiki
2 //
3 // By default the folder containing this file is included in the LESS import paths,
4 // which makes this file importable by all less files via `@import 'mediawiki.mixins';`.
5 //
6 // The mixins included below are considered a public interface for MediaWiki extensions.
7 // The signatures of parametrized mixins should be kept as stable as possible.
8 //
9 // See <http://lesscss.org/#-mixins> for more information about how to write mixins.
10
11 .background-image( @url ) {
12 background-image: e( '/* @embed */' ) url( @url );
13 }
14
15 .horizontal-gradient( @startColor: #808080, @endColor: #fff, @startPos: 0, @endPos: 100% ) {
16 background-color: average( @startColor, @endColor );
17 background-image: -webkit-gradient( linear, left top, right top, color-stop( @startPos, @startColor ), color-stop( @endPos, @endColor ) );
18 background-image: -webkit-linear-gradient( left, @startColor @startPos, @endColor @endPos );
19 background-image: -moz-linear-gradient( left, @startColor @startPos, @endColor @endPos );
20 background-image: linear-gradient( to right, @startColor @startPos, @endColor @endPos );
21 }
22
23 .vertical-gradient( @startColor: #808080, @endColor: #fff, @startPos: 0, @endPos: 100% ) {
24 background-color: average( @startColor, @endColor );
25 background-image: -webkit-gradient( linear, right top, right bottom, color-stop( @startPos, @startColor ), color-stop( @endPos, @endColor ) );
26 background-image: -webkit-linear-gradient( top, @startColor @startPos, @endColor @endPos );
27 background-image: -moz-linear-gradient( top, @startColor @startPos, @endColor @endPos );
28 background-image: linear-gradient( to bottom, @startColor @startPos, @endColor @endPos );
29 }
30
31 // SVG support using a transparent gradient to guarantee cross-browser
32 // compatibility (browsers able to understand gradient syntax support also SVG).
33 // http://pauginer.tumblr.com/post/36614680636/invisible-gradient-technique
34 //
35 // We do not embed the fallback image on the assumption that the gain for old browsers
36 // is not worth the harm done to modern ones.
37 .background-image-svg( @svg, @fallback ) {
38 background-image: url( @fallback );
39 background-image: linear-gradient( transparent, transparent ), e( '/* @embed */' ) url( @svg );
40 }
41
42 // Shorthand for background-image-svg. Use if your PNG and SVG have the same name
43 // and only if you cannot use ResourceLoaderImage module for some particular reason.
44 .background-image-svg-quick( @url ) {
45 .background-image-svg( ~'@{url}.svg', ~'@{url}.png' );
46 }
47
48 .list-style-image( @url ) {
49 list-style-image: e( '/* @embed */' ) url( @url );
50 }
51
52 .hyphens( @value: auto ) {
53 & when ( @value = auto ) {
54 // Legacy `word-wrap`; IE 6-11, Edge 12+, Firefox 3.5+, Chrome 4+, Safari 3.1+,
55 // Opera 11.5+, iOS 3.2+, Android 2.1+
56 // `overflow-wrap` is W3 standard, but it doesn't seem as if browser vendors
57 // will abandon `word-wrap` (it has wider support), therefore no duplication.
58 word-wrap: break-word;
59 }
60 & when ( @value = none ) {
61 word-wrap: normal;
62 }
63
64 // CSS3 hyphenation
65 -webkit-hyphens: @value; // Safari 5.1+, iOS 4.3+
66 -moz-hyphens: @value; // Firefox 6-42
67 -ms-hyphens: @value; // IE 10-11, Edge 12+
68 hyphens: @value; // Firefox 43+, Chrome 55+, Android 62+, UC Browser 11.8+, Samsung 6.2+
69 }
70
71 .transform( @value ) {
72 -webkit-transform: @value; // Safari 3.1-8.0, iOS 3.2-8.4, Android 2.1-4.4.4
73 -moz-transform: @value; // Firefox 3.5-15
74 transform: @value; // Chrome 36+, Firefox 16+, IE 10+, Safari 9+, Opera 23+, iOS 9.2+, Android 5+
75 }
76
77 .transition( @value ) {
78 -webkit-transition: @value; // Safari 3.1-6.0, iOS 3.2-6.1, Android 2.1-4.3
79 -moz-transition: @value; // Firefox 4-15
80 transition: @value; // Chrome 26+, Firefox 16+, IE 10+, Safari 6.1+, Opera 12.1+, iOS 7+, Android 4.4+
81 }
82
83 // Provide a hardware accelerated transform transition
84 // We can't use `.transition()` because WebKit requires `-webkit-` prefix before `transform`
85 // Example usage: `.transition-transform( 1s, opacity 2s );`
86 // First parameter is additional options for `transform` transition commencing with
87 // duration property @see https://www.w3.org/TR/css3-transitions/#transition-duration-property
88 // and remaining parameters are additional transitions."
89 .transition-transform( ... ) {
90 -webkit-backface-visibility: hidden; // Older Webkit browsers: Promote element to a composite layer & involve the GPU
91 -webkit-transition: -webkit-transform @arguments; // Safari 3.1-8, iOS 3.2-8.4, Android 2.1-4.4.4
92 -moz-transition: -moz-transform @arguments; // Firefox 4-15 for `-moz-transition`
93 transition: transform @arguments; // Chrome 36+, Firefox 16+, IE 10+, Safari 9+, Opera 12.1+, iOS 9.2+, Android 36+
94 }
95
96 .box-sizing( @value ) {
97 -webkit-box-sizing: @value; // Safari 3.1-5.0, iOS 3.2-4.3, Android 2.1-3.0
98 -moz-box-sizing: @value; // Firefox 4-28,
99 box-sizing: @value; // Chrome 10+, Firefox 29+, IE 8+, Safari 5.1+, Opera 10+, iOS 5+, Android 4+
100 }
101
102 .box-shadow( @value ) {
103 -webkit-box-shadow: @value; // Safari 3.1-5.0, iOS 3.2-4.3, Android 2.1-3.0
104 box-shadow: @value; // Chrome 10+, Firefox 4+, IE 9+, Safari 5.1+, Opera 11+, iOS 5+, Android 4+
105 }
106
107 .column-count( @value ) {
108 -webkit-column-count: @value;
109 -moz-column-count: @value;
110 column-count: @value;
111 }
112
113 .column-width( @value ) {
114 -webkit-column-width: @value; // Chrome Any, Safari 3+, Opera 15+
115 -moz-column-width: @value; // Firefox 1.5+
116 column-width: @value; // IE 10+, Opera 11.1-12.1
117 }
118
119 .column-break-inside-avoid() {
120 -webkit-column-break-inside: avoid; // Chrome Any, Safari 3+, Opera 15+
121 page-break-inside: avoid; // Firefox 1.5+
122 break-inside: avoid-column; // IE 10+, Opera 11.1-12.1
123 }
124
125 .flex-display( @display: flex ) {
126 display: ~'-webkit-@{display}'; // iOS 6-, Safari 3.1-6
127 display: ~'-moz-@{display}'; // Firefox 21-
128 display: ~'-ms-@{display}box'; // IE 10
129 display: @display;
130 }
131
132 .flex-wrap( @wrap: wrap ) {
133 -webkit-flex-wrap: @wrap; // iOS 6-, Safari 3.1-6
134 -moz-flex-wrap: @wrap; // Firefox 21-
135 -ms-flex-wrap: @wrap; // IE 10
136 flex-wrap: @wrap;
137 }
138
139 .flex( @grow: 1, @shrink: 1, @width: auto, @order: 1 ) {
140 // For 2009/2012 spec alignment consistency with current default
141 -webkit-box-pack: justify; // iOS 6-, Safari 3.1-6
142 -moz-box-pack: justify; // Firefox 21-
143 -ms-flex-pack: justify; // IE 10 (2012 spec)
144 justify-content: space-between; // Current default
145
146 // 2009 spec only supports 'flexible' as opposed to grow (flexPositive)
147 // and shrink (flexNegative); default to grow value
148 -webkit-box-flex: @grow; // iOS 6-, Safari 3.1-6
149 -moz-box-flex: @grow; // Firefox 21-
150 width: @width; // Fallback for flex-basis
151 -ms-flex: @grow @shrink @width; // IE 10
152 flex: @grow @shrink @width;
153 -webkit-box-ordinal-group: @order; // iOS 6-, Safari 3.1-6
154 -moz-box-ordinal-group: @order; // Firefox 21-
155 -ms-flex-order: @order; // IE 10
156 order: @order;
157 }
158
159 /* stylelint-disable selector-no-vendor-prefix, at-rule-no-unknown */
160 .mixin-placeholder( @rules ) {
161 // WebKit, Blink, Edge
162 &::-webkit-input-placeholder {
163 @rules();
164 }
165 // Internet Explorer 10-11
166 &:-ms-input-placeholder {
167 @rules();
168 }
169 // Firefox 19-
170 &::-moz-placeholder {
171 @rules();
172 }
173 // Firefox 4-18
174 &:-moz-placeholder {
175 @rules();
176 }
177 // W3C Standard Selectors Level 4
178 &::placeholder {
179 @rules();
180 }
181 }
182 /* stylelint-enable selector-no-vendor-prefix, at-rule-no-unknown */
183
184 // Screen Reader Helper Mixin
185 .mixin-screen-reader-text() {
186 display: block;
187 position: absolute !important; /* stylelint-disable-line declaration-no-important */
188 clip: rect( 1px, 1px, 1px, 1px );
189 width: 1px;
190 height: 1px;
191 margin: -1px;
192 border: 0;
193 padding: 0;
194 overflow: hidden;
195 }