mediawiki.ui: Buttons should receive `max-width`
[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, constructive and desctructive 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( #fff, @colorGray12, @colorGray7 );
54 text-align: center;
55 font-weight: bold;
56
57 // Interaction styling
58 cursor: pointer;
59
60 &:disabled {
61 text-shadow: none;
62 cursor: default;
63 }
64
65 // Styling for specific button types
66 // -----------------------------------------
67
68 // Big buttons
69 //
70 // Not all buttons are equal. You can emphasise certain actions over others
71 // using the mw-ui-big class.
72 //
73 // Markup:
74 // <div>
75 // <button class="mw-ui-button mw-ui-big">.mw-ui-button</button>
76 // </div>
77 // <div>
78 // <button class="mw-ui-button mw-ui-progressive mw-ui-big">.mw-ui-progressive</button>
79 // </div>
80 // <div>
81 // <button class="mw-ui-button mw-ui-constructive mw-ui-big">.mw-ui-constructive</button>
82 // </div>
83 // <div>
84 // <button class="mw-ui-button mw-ui-destructive mw-ui-big">.mw-ui-destructive</button>
85 // </div>
86 //
87 // Styleguide 2.1.6.
88 &.mw-ui-big {
89 font-size: 1.3em;
90 }
91
92 // Block buttons
93 //
94 // Some buttons might need to be stacked.
95 //
96 // Markup:
97 // <div>
98 // <button class="mw-ui-button mw-ui-block">.mw-ui-button</button>
99 // </div>
100 // <div>
101 // <button class="mw-ui-button mw-ui-progressive mw-ui-block">.mw-ui-progressive</button>
102 // </div>
103 // <div>
104 // <button class="mw-ui-button mw-ui-constructive mw-ui-block">.mw-ui-constructive</button>
105 // </div>
106 // <div>
107 // <button class="mw-ui-button mw-ui-destructive mw-ui-block">.mw-ui-destructive</button>
108 // </div>
109 //
110 // Styleguide 2.1.5.
111 &.mw-ui-block {
112 display: block;
113 width: 100%;
114 margin-left: auto;
115 margin-right: auto;
116 }
117
118 // Progressive buttons
119 //
120 // Use progressive buttons for actions which lead to a next step in the process.
121 // .mw-ui-primary is deprecated, kept for compatibility.
122 //
123 // Markup:
124 // <div>
125 // <button class="mw-ui-button mw-ui-progressive">.mw-ui-progressive</button>
126 // </div>
127 // <div>
128 // <button class="mw-ui-button mw-ui-progressive" disabled>.mw-ui-progressive</button>
129 // </div>
130 //
131 // Styleguide 2.1.1.
132 &.mw-ui-progressive,
133 &.mw-ui-primary {
134 .button-colors( @colorProgressive, @colorProgressiveHighlight, @colorProgressiveActive );
135
136 &.mw-ui-quiet {
137 .button-colors-quiet( @colorProgressive, @colorProgressiveHighlight, @colorProgressiveActive );
138 }
139 }
140
141 // Constructive buttons
142 //
143 // Use constructive buttons for actions which result in a final action in the process that results
144 // in a change of state.
145 // e.g. save changes button
146 //
147 // Markup:
148 // <div>
149 // <button class="mw-ui-button mw-ui-constructive">.mw-ui-constructive</button>
150 // </div>
151 // <div>
152 // <button class="mw-ui-button mw-ui-constructive" disabled>.mw-ui-constructive</button>
153 // </div>
154 //
155 // Styleguide 2.1.2.
156 &.mw-ui-constructive {
157 .button-colors( @colorConstructive, @colorConstructiveHighlight, @colorConstructiveActive );
158
159 &.mw-ui-quiet {
160 .button-colors-quiet( @colorConstructive, @colorConstructiveHighlight, @colorConstructiveActive );
161 }
162 }
163
164 // Destructive buttons
165 //
166 // Use destructive buttons for actions that remove or limit, such as deleting a page or blocking a user.
167 // This should not be used for cancel buttons.
168 //
169 // Markup:
170 // <div>
171 // <button class="mw-ui-button mw-ui-destructive">.mw-ui-destructive</button>
172 // </div>
173 // <div>
174 // <button class="mw-ui-button mw-ui-destructive" disabled>.mw-ui-destructive</button>
175 // </div>
176 //
177 // Styleguide 2.1.3.
178 &.mw-ui-destructive {
179 .button-colors( @colorDestructive, @colorDestructiveHighlight, @colorDestructiveActive );
180
181 &.mw-ui-quiet {
182 .button-colors-quiet( @colorDestructive, @colorDestructiveHighlight, @colorDestructiveActive );
183 }
184 }
185
186 // Quiet buttons
187 //
188 // Use quiet buttons when they are less important and alongside other constructive, progressive or destructive buttons. It should be used for an action that exits the user from the current view/workflow.
189 // Its use is not recommended on mobile/tablet due to lack of hover state.
190 //
191 // Markup:
192 // <div>
193 // <button class="mw-ui-button mw-ui-quiet">.mw-ui-button</button>
194 // </div>
195 // <div>
196 // <button class="mw-ui-button mw-ui-constructive mw-ui-quiet">.mw-ui-constructive</button>
197 // </div>
198 // <div>
199 // <button class="mw-ui-button mw-ui-constructive mw-ui-quiet" disabled>.mw-ui-constructive</button>
200 // </div>
201 // <div>
202 // <button class="mw-ui-button mw-ui-destructive mw-ui-quiet">.mw-ui-destructive</button>
203 // </div>
204 // <div>
205 // <button class="mw-ui-button mw-ui-destructive mw-ui-quiet" disabled>.mw-ui-destructive</button>
206 // </div>
207 // <div>
208 // <button class="mw-ui-button mw-ui-progressive mw-ui-quiet">.mw-ui-progressive</button>
209 // </div>
210 // <div>
211 // <button class="mw-ui-button mw-ui-progressive mw-ui-quiet" disabled>.mw-ui-progressive</button>
212 // </div>
213 //
214 // Styleguide 2.1.4.
215 &.mw-ui-quiet {
216 background: transparent;
217 border: 0;
218 text-shadow: none;
219 .button-colors-quiet( @colorButtonText, @colorButtonTextHighlight, @colorButtonTextActive );
220
221 &:hover,
222 &:focus {
223 box-shadow: none;
224 }
225
226 &:active,
227 &:disabled {
228 background: transparent;
229 }
230 }
231 }
232
233 a.mw-ui-button {
234 text-decoration: none;
235
236 // This overrides an underline declaration on a:hover and a:focus in
237 // commonElements.css, which the class alone isn't specific enough to do.
238 &:hover,
239 &:focus {
240 text-decoration: none;
241 }
242
243 // a-tags behave different to inputs if the line-height attribute is inherited
244 // from another element (e.g. mw-body-content). They appear bigger as input
245 // tags. See Bug T116427. To fix that, apply the correct line-height (used
246 // for inputs) to a-tags, too.
247 line-height: normal;
248 }
249
250 // Button groups
251 //
252 // Group of buttons. Make sure you clear the floating after using a mw-ui-button-group.
253 //
254 // Markup:
255 // <div class="mw-ui-button-group">
256 // <div class="mw-ui-button">A</div>
257 // <div class="mw-ui-button">B</div>
258 // <div class="mw-ui-button">C</div>
259 // <div class="mw-ui-button">D</div>
260 // </div><div style="clear:both"></div>
261 //
262 // Styleguide 2.2.
263 .mw-ui-button-group > * {
264 min-width: 48px;
265 border-radius: 0;
266 float: left;
267
268 &:first-child {
269 border-top-left-radius: @borderRadius;
270 border-bottom-left-radius: @borderRadius;
271 }
272
273 &:not( :first-child ) {
274 border-left: 0;
275 }
276
277 &:last-child{
278 border-top-right-radius: @borderRadius;
279 border-bottom-right-radius: @borderRadius;
280 }
281 }