85795f44db4d9ec81c8f53d3777288b9de12b951
[lhc/web/wiklou.git] / resources / src / mediawiki.ui / components / buttons.less
1 @import "mediawiki.mixins";
2 @import "mediawiki.ui/variables";
3 @import "mediawiki.ui/mixins";
4
5 // Buttons
6 //
7 // All buttons start with mw-ui-button class, modified by other classes.
8 // It can be any element. Due to a lack of a CSS reset, the exact styling of
9 // the button depends on what type of element is used.
10 // There are two kinds of buttons, the default is a "Call to Action" with an obvious border
11 // and there is a quiet kind without a border.
12 //
13 // Styleguide 2.
14
15 // Neutral button styling
16 //
17 // These are the main actions on the page/workflow. The page should have only one of progressive and destructive buttons, the rest being quiet.
18 //
19 // Markup:
20 // <div>
21 // <button class="mw-ui-button">.mw-ui-button</button>
22 // </div>
23 // <div>
24 // <button class="mw-ui-button" disabled>.mw-ui-button</button>
25 // </div>
26 //
27 // Styleguide 2.1.
28 .mw-ui-button {
29 // Inherit the font rather than apply user agent stylesheet (bug 70072)
30 font-family: inherit;
31 font-size: 1em;
32 // Container layout
33 display: inline-block;
34 min-width: 4em;
35 max-width: 28.75em; // equivalent to 460px, @see T95367
36 padding: .5em 1em;
37 margin: 0;
38 border-radius: @borderRadius;
39 .box-sizing( border-box );
40
41 // Disable weird iOS styling
42 -webkit-appearance: none;
43
44 // IE 6 & 7 hack
45 // https://stackoverflow.com/a/5838575/365238
46 *display: inline;
47 zoom: 1;
48
49 // Ensure that buttons and inputs are nicely aligned when they have differing heights
50 vertical-align: middle;
51
52 // Content styling
53 .button-colors( @colorGray15, #fff, #d9d9d9 );
54 text-align: center;
55 font-weight: bold;
56
57 // Interaction styling
58 cursor: pointer;
59
60 &:focus {
61 outline-width: 0;
62
63 // Remove the inner border and padding in Firefox.
64 &::-moz-focus-inner {
65 border-color: transparent;
66 padding: 0;
67 }
68 }
69
70 // `:not()` is used exclusively for `transition`s as both are not supported by IE < 9
71 &:not( :disabled ) {
72 .transition( ~'background-color 100ms, color 100ms, border-color 100ms, box-shadow 100ms' );
73 }
74
75 &:disabled {
76 text-shadow: none;
77 cursor: default;
78 }
79
80 // Styling for specific button types
81 // -----------------------------------------
82
83 // Big buttons
84 //
85 // Not all buttons are equal. You can emphasise certain actions over others
86 // using the mw-ui-big class.
87 //
88 // Markup:
89 // <div>
90 // <button class="mw-ui-button mw-ui-big">.mw-ui-button</button>
91 // </div>
92 // <div>
93 // <button class="mw-ui-button mw-ui-progressive mw-ui-big">.mw-ui-progressive</button>
94 // </div>
95 // <div>
96 // <button class="mw-ui-button mw-ui-destructive mw-ui-big">.mw-ui-destructive</button>
97 // </div>
98 //
99 // Styleguide 2.1.6.
100 &.mw-ui-big {
101 font-size: 1.3em;
102 }
103
104 // Block buttons
105 //
106 // Some buttons might need to be stacked.
107 //
108 // Markup:
109 // <div>
110 // <button class="mw-ui-button mw-ui-block">.mw-ui-button</button>
111 // </div>
112 // <div>
113 // <button class="mw-ui-button mw-ui-progressive mw-ui-block">.mw-ui-progressive</button>
114 // </div>
115 // <div>
116 // <button class="mw-ui-button mw-ui-destructive mw-ui-block">.mw-ui-destructive</button>
117 // </div>
118 //
119 // Styleguide 2.1.5.
120 &.mw-ui-block {
121 display: block;
122 width: 100%;
123 margin-left: auto;
124 margin-right: auto;
125 }
126
127 // Progressive buttons
128 //
129 // Use progressive buttons for actions which lead to a next step in the process.
130 // .mw-ui-constructive is deprecated; consolidated with `progressive`, see T110555
131 //
132 // Markup:
133 // <div>
134 // <button class="mw-ui-button mw-ui-progressive">.mw-ui-progressive</button>
135 // </div>
136 // <div>
137 // <button class="mw-ui-button mw-ui-progressive" disabled>.mw-ui-progressive</button>
138 // </div>
139 //
140 // Styleguide 2.1.1.
141 &.mw-ui-progressive,
142 &.mw-ui-constructive {
143 .button-colors-primary( @colorProgressive, @colorProgressiveHighlight, @colorProgressiveActive );
144
145 &.mw-ui-quiet {
146 .button-colors-quiet( @colorProgressive, @colorProgressiveHighlight, @colorProgressiveActive );
147 }
148 }
149
150 // Destructive buttons
151 //
152 // Use destructive buttons for actions that remove or limit, such as deleting a page or blocking a user.
153 // This should not be used for cancel buttons.
154 //
155 // Markup:
156 // <div>
157 // <button class="mw-ui-button mw-ui-destructive">.mw-ui-destructive</button>
158 // </div>
159 // <div>
160 // <button class="mw-ui-button mw-ui-destructive" disabled>.mw-ui-destructive</button>
161 // </div>
162 //
163 // Styleguide 2.1.2.
164 &.mw-ui-destructive {
165 .button-colors-primary( @colorDestructive, @colorDestructiveHighlight, @colorDestructiveActive );
166
167 &.mw-ui-quiet {
168 .button-colors-quiet( @colorDestructive, @colorDestructiveHighlight, @colorDestructiveActive );
169 }
170 }
171
172 // Quiet buttons
173 //
174 // 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.
175 // Its use is not recommended on mobile/tablet due to lack of hover state.
176 //
177 // Markup:
178 // <div>
179 // <button class="mw-ui-button mw-ui-quiet">.mw-ui-button</button>
180 // </div>
181 // <div>
182 // <button class="mw-ui-button mw-ui-destructive mw-ui-quiet">.mw-ui-destructive</button>
183 // </div>
184 // <div>
185 // <button class="mw-ui-button mw-ui-destructive mw-ui-quiet" disabled>.mw-ui-destructive</button>
186 // </div>
187 // <div>
188 // <button class="mw-ui-button mw-ui-progressive mw-ui-quiet">.mw-ui-progressive</button>
189 // </div>
190 // <div>
191 // <button class="mw-ui-button mw-ui-progressive mw-ui-quiet" disabled>.mw-ui-progressive</button>
192 // </div>
193 //
194 // Styleguide 2.1.3.
195 &.mw-ui-quiet {
196 background: transparent;
197 border: 0;
198 text-shadow: none;
199 .button-colors-quiet( @colorButtonText, @colorButtonTextHighlight, @colorButtonTextActive );
200
201 &:hover,
202 &:focus {
203 box-shadow: none;
204 }
205
206 &:active,
207 &:disabled {
208 background: transparent;
209 }
210 }
211 }
212
213 a.mw-ui-button {
214 text-decoration: none;
215
216 // This overrides an underline declaration on a:hover and a:focus in
217 // commonElements.css, which the class alone isn't specific enough to do.
218 &:hover,
219 &:focus {
220 text-decoration: none;
221 }
222
223 // a-tags behave different to inputs if the line-height attribute is inherited
224 // from another element (e.g. mw-body-content). They appear bigger as input
225 // tags. See Bug T116427. To fix that, apply the correct line-height (used
226 // for inputs) to a-tags, too.
227 line-height: normal;
228 }
229
230 // Button groups
231 //
232 // Group of buttons. Make sure you clear the floating after using a mw-ui-button-group.
233 //
234 // Markup:
235 // <div class="mw-ui-button-group">
236 // <div class="mw-ui-button is-on">A</div>
237 // <div class="mw-ui-button">B</div>
238 // <div class="mw-ui-button">C</div>
239 // <div class="mw-ui-button">D</div>
240 // </div><div style="clear:both"></div>
241 //
242 // Styleguide 2.2.
243 .mw-ui-button-group {
244 & > * {
245 min-width: 48px;
246 border-radius: 0;
247 float: left;
248
249 &:first-child {
250 border-top-left-radius: @borderRadius;
251 border-bottom-left-radius: @borderRadius;
252 }
253
254 &:not( :first-child ) {
255 border-left: 0;
256 }
257
258 &:last-child {
259 border-top-right-radius: @borderRadius;
260 border-bottom-right-radius: @borderRadius;
261 }
262 }
263
264 & .is-on .button {
265 cursor: default;
266 }
267 }