Merge "Use MediaWiki\SuppressWarnings around trigger_error('') instead @"
[lhc/web/wiklou.git] / resources / src / mediawiki.ui / components / buttons.less
1 @import 'mediawiki.mixins';
2 @import 'mediawiki.ui/variables';
3
4 // Buttons
5 // Helper mixins
6 // Primary buttons mixin
7 .button-colors-primary( @bgColor, @highlightColor, @activeColor ) {
8 background-color: @bgColor;
9 color: #fff;
10 // border of the same color as background so that light background and
11 // dark background buttons are the same height and width
12 border: 1px solid @bgColor;
13
14 &:hover {
15 background-color: @highlightColor;
16 border-color: @highlightColor;
17 }
18
19 &:focus {
20 box-shadow: inset 0 0 0 1px @bgColor, inset 0 0 0 2px #fff;
21 }
22
23 &:active,
24 &.is-on {
25 background-color: @activeColor;
26 border-color: @activeColor;
27 box-shadow: none;
28 }
29
30 &:disabled {
31 background-color: @colorGray12;
32 color: #fff;
33 border-color: @colorGray12;
34
35 // Make sure disabled buttons don't have hover and active states
36 &:hover,
37 &:active {
38 background-color: @colorGray12;
39 color: #fff;
40 border-color: @colorGray12;
41 box-shadow: none;
42 }
43 }
44 }
45
46 // All buttons start with `.mw-ui-button` class, modified by other classes.
47 // It can be any element. Due to a lack of a CSS reset, the exact styling of
48 // the button depends on what type of element is used.
49 // There are two kinds of buttons, the default is a "Call to Action" with an obvious border
50 // and there is a quiet kind without a border.
51 //
52 // Styleguide 2.
53
54 // Neutral button styling
55 //
56 // These are the main actions on the page/workflow. The page should have only one of progressive and destructive buttons, the rest being quiet.
57 //
58 // Markup:
59 // <div>
60 // <button class="mw-ui-button">.mw-ui-button</button>
61 // </div>
62 // <div>
63 // <button class="mw-ui-button" disabled>.mw-ui-button</button>
64 // </div>
65 //
66 // Styleguide 2.1.
67 .mw-ui-button {
68 background-color: @colorGray15;
69 color: @colorButtonText;
70 // Container layout
71 display: inline-block;
72 .box-sizing( border-box );
73 min-width: 4em;
74 max-width: 28.75em; // equivalent to 460px, @see T95367
75 margin: 0;
76 padding: 0.546875em 1em;
77 border: @border-width-base @border-style-base @border-color-base;
78 border-radius: @borderRadius;
79 // Inherit the font rather than apply user agent stylesheet (T72072)
80 font-family: inherit;
81 font-size: 1em;
82 font-weight: bold;
83 line-height: 1.286;
84 text-align: center;
85 // Disable weird iOS styling
86 -webkit-appearance: none;
87 // IE 6 & 7 hack
88 // https://stackoverflow.com/a/5838575/365238
89 *display: inline; /* stylelint-disable-line declaration-block-no-duplicate-properties */
90 zoom: 1;
91 // Ensure that buttons and inputs are nicely aligned when they have differing heights
92 vertical-align: middle;
93 // Interaction styling
94 cursor: pointer;
95
96 // Make sure that `color` isn't inheriting from user-agent styles
97 &:visited {
98 color: @colorButtonText;
99 }
100
101 &:hover {
102 background-color: @background-color-base;
103 color: @colorGray4;
104 border-color: @colorGray10;
105 }
106
107 &:focus {
108 background-color: @background-color-base;
109 // Make sure that `color` isn't inheriting from user-agent styles
110 color: @colorButtonText;
111 border-color: @colorProgressive;
112 box-shadow: inset 0 0 0 1px @colorProgressive, inset 0 0 0 2px @background-color-base;
113 outline-width: 0;
114
115 // Remove the inner border and padding in Firefox.
116 &::-moz-focus-inner {
117 border-color: transparent;
118 padding: 0;
119 }
120 }
121
122 &:active,
123 &.is-on {
124 background-color: @colorGray12;
125 color: @colorGray1;
126 border-color: @colorGray7;
127 box-shadow: none;
128 }
129
130 &:disabled,
131 &.mw-ui-quiet.mw-ui-progressive,
132 &.mw-ui-quiet.mw-ui-destructive {
133 background-color: @colorGray12;
134 color: @colorBaseInverted;
135 border-color: @colorGray12;
136 cursor: default;
137
138 // Make sure disabled buttons don't have hover and active states
139 &:hover,
140 &:active {
141 background-color: @colorGray12;
142 color: @colorBaseInverted;
143 box-shadow: none;
144 border-color: @colorGray12;
145 }
146 }
147
148 // `:not()` is used exclusively for `transition`s as both are not supported by IE < 9
149 &:not( :disabled ) {
150 .transition( ~'background-color 100ms, color 100ms, border-color 100ms, box-shadow 100ms' );
151 }
152
153 // Styling for specific button types
154 // -----------------------------------------
155
156 // Quiet buttons
157 //
158 // Use quiet buttons when they are less important and alongside other progressive or destructive buttons. It should be used for an action that exits the user from the current view/workflow.
159 // Its use is not recommended on mobile/tablet due to lack of hover state.
160 //
161 // Markup:
162 // <div>
163 // <button class="mw-ui-button mw-ui-quiet">.mw-ui-button</button>
164 // </div>
165 // <div>
166 // <button class="mw-ui-button mw-ui-destructive mw-ui-quiet">.mw-ui-destructive</button>
167 // </div>
168 // <div>
169 // <button class="mw-ui-button mw-ui-destructive mw-ui-quiet" disabled>.mw-ui-destructive</button>
170 // </div>
171 // <div>
172 // <button class="mw-ui-button mw-ui-progressive mw-ui-quiet">.mw-ui-progressive</button>
173 // </div>
174 // <div>
175 // <button class="mw-ui-button mw-ui-progressive mw-ui-quiet" disabled>.mw-ui-progressive</button>
176 // </div>
177 //
178 // Styleguide 2.1.1.
179 &.mw-ui-quiet {
180 background-color: transparent;
181 // Quiet buttons all start gray, and reveal
182 // progressive/destructive color on hover and active.
183 color: @colorButtonText;
184 border-color: transparent;
185
186 &:hover {
187 background-color: transparent;
188 color: @colorButtonTextHighlight;
189 border-color: transparent;
190 box-shadow: none;
191 }
192
193 &:active {
194 background-color: transparent;
195 color: @colorButtonTextActive;
196 border-color: transparent;
197 }
198
199 &:focus {
200 background-color: transparent;
201 color: @colorButtonText;
202 border-color: transparent;
203 box-shadow: none;
204 }
205
206 &:disabled {
207 background-color: transparent;
208 color: @colorDisabledText;
209 border-color: transparent;
210 }
211 }
212
213 // Progressive buttons
214 //
215 // Use progressive buttons for actions which lead to a next step in the process.
216 //
217 // Markup:
218 // <div>
219 // <button class="mw-ui-button mw-ui-progressive">.mw-ui-progressive</button>
220 // </div>
221 // <div>
222 // <button class="mw-ui-button mw-ui-progressive" disabled>.mw-ui-progressive</button>
223 // </div>
224 //
225 // Styleguide 2.1.2.
226 &.mw-ui-progressive {
227 .button-colors-primary( @colorProgressive, @colorProgressiveHighlight, @colorProgressiveActive );
228
229 &.mw-ui-quiet {
230 color: @colorProgressive;
231
232 &:hover {
233 background-color: transparent;
234 color: @colorProgressiveHighlight;
235 }
236
237 &:active {
238 color: @colorProgressiveActive;
239 }
240
241 &:focus {
242 background-color: transparent;
243 color: @colorProgressive;
244 }
245 }
246 }
247
248 // Destructive buttons
249 //
250 // Use destructive buttons for actions that remove or limit, such as deleting a page or blocking a user.
251 // This should not be used for cancel buttons.
252 //
253 // Markup:
254 // <div>
255 // <button class="mw-ui-button mw-ui-destructive">.mw-ui-destructive</button>
256 // </div>
257 // <div>
258 // <button class="mw-ui-button mw-ui-destructive" disabled>.mw-ui-destructive</button>
259 // </div>
260 //
261 // Styleguide 2.1.3.
262 &.mw-ui-destructive {
263 .button-colors-primary( @colorDestructive, @colorDestructiveHighlight, @colorDestructiveActive );
264
265 &.mw-ui-quiet {
266 color: @colorDestructive;
267
268 &:hover {
269 background-color: transparent;
270 color: @colorDestructiveHighlight;
271 }
272
273 &:active {
274 color: @colorDestructiveActive;
275 }
276
277 &:focus {
278 background-color: transparent;
279 color: @colorDestructive;
280 }
281 }
282 }
283
284 // Big buttons
285 //
286 // Not all buttons are equal. You can emphasise certain actions over others
287 // using the mw-ui-big class.
288 //
289 // Markup:
290 // <div>
291 // <button class="mw-ui-button mw-ui-big">.mw-ui-button</button>
292 // </div>
293 // <div>
294 // <button class="mw-ui-button mw-ui-progressive mw-ui-big">.mw-ui-progressive</button>
295 // </div>
296 // <div>
297 // <button class="mw-ui-button mw-ui-destructive mw-ui-big">.mw-ui-destructive</button>
298 // </div>
299 //
300 // Styleguide 2.1.4.
301 &.mw-ui-big {
302 font-size: 1.3em;
303 }
304
305 // Block buttons
306 //
307 // Some buttons might need to be stacked.
308 //
309 // Markup:
310 // <div>
311 // <button class="mw-ui-button mw-ui-block">.mw-ui-button</button>
312 // </div>
313 // <div>
314 // <button class="mw-ui-button mw-ui-progressive mw-ui-block">.mw-ui-progressive</button>
315 // </div>
316 // <div>
317 // <button class="mw-ui-button mw-ui-destructive mw-ui-block">.mw-ui-destructive</button>
318 // </div>
319 //
320 // Styleguide 2.1.5.
321 &.mw-ui-block {
322 display: block;
323 width: 100%;
324 margin-left: auto;
325 margin-right: auto;
326 }
327 }
328
329 input.mw-ui-button,
330 button.mw-ui-button {
331 // Buttons in Firefox have extra height
332 &::-moz-focus-inner {
333 margin-top: -1px;
334 margin-bottom: -1px;
335 }
336 }
337
338 a.mw-ui-button {
339 text-decoration: none;
340
341 // This overrides an underline declaration on a:hover and a:focus in
342 // commonElements.css, which the class alone isn't specific enough to do.
343 &:hover,
344 &:focus {
345 text-decoration: none;
346 }
347 }
348
349 // Button groups
350 //
351 // Group of buttons. Make sure you clear the floating after using a mw-ui-button-group.
352 //
353 // Markup:
354 // <div class="mw-ui-button-group">
355 // <div class="mw-ui-button is-on">A</div>
356 // <div class="mw-ui-button">B</div>
357 // <div class="mw-ui-button">C</div>
358 // <div class="mw-ui-button">D</div>
359 // </div><div style="clear:both"></div>
360 //
361 // Styleguide 2.2.
362 .mw-ui-button-group {
363 & > * {
364 min-width: 48px;
365 border-radius: 0;
366 float: left;
367
368 &:first-child {
369 border-top-left-radius: @borderRadius;
370 border-bottom-left-radius: @borderRadius;
371 }
372
373 &:not( :first-child ) {
374 border-left: 0;
375 }
376
377 &:last-child {
378 border-top-right-radius: @borderRadius;
379 border-bottom-right-radius: @borderRadius;
380 }
381 }
382
383 & .is-on .button {
384 cursor: default;
385 }
386 }