summaryrefslogtreecommitdiff
path: root/resources/src/mediawiki.ui/components/buttons.less
blob: f88f3ee6b9635f66f29e7e72c50533d118f2b924 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
@import "mediawiki.mixins";
@import "mediawiki.ui/variables";
@import "mediawiki.ui/mixins";

// Buttons
//
// All buttons start with mw-ui-button class, modified by other classes.
// It can be any element.  Due to a lack of a CSS reset, the exact styling of
// the button depends on what type of element is used.
// There are two kinds of buttons, the default is a "Call to Action" with an obvious border
// and there is a quiet kind without a border.
//
// Styleguide 2.

@transitionDuration: .1s;
@transitionFunction: ease-in-out;

// Neutral button styling
//
// 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.
//
// Markup:
// <div>
//   <button class="mw-ui-button">.mw-ui-button</button>
// </div>
// <div>
//   <button class="mw-ui-button" disabled>.mw-ui-button</button>
// </div>
//
// Styleguide 2.1.
.mw-ui-button {
	// Inherit the font rather than apply user agent stylesheet (bug 70072)
	font-family: inherit;
	font-size: 1em;
	// Container layout
	display: inline-block;
	padding: .5em 1em;
	margin: 0;
	.box-sizing(border-box);

	// Disable weird iOS styling
	-webkit-appearance: none;

	// IE6/IE7 hack
	// http://stackoverflow.com/a/5838575/365238
	*display: inline;
	zoom: 1;

	// Container styling
	.button-colors(#FFF);
	border-radius: @borderRadius;
	min-width: 4em;

	// Ensure that buttons and inputs are nicely aligned when they have differing heights
	vertical-align: middle;

	// Content styling
	text-align: center;
	font-weight: bold;

	// Interaction styling
	cursor: pointer;

	&:disabled {
		text-shadow: none;
		cursor: default;
	}

	.transition(background @transitionDuration @transitionFunction, color @transitionDuration @transitionFunction, box-shadow @transitionDuration @transitionFunction;);

	// Styling for specific button types
	// -----------------------------------------

	// Big buttons
	//
	// Not all buttons are equal. You can emphasise certain actions over others
	// using the mw-ui-big class.
	//
	// Markup:
	// <div>
	//   <button class="mw-ui-button mw-ui-big">.mw-ui-button</button>
	// </div>
	// <div>
	//   <button class="mw-ui-button mw-ui-progressive mw-ui-big">.mw-ui-progressive</button>
	// </div>
	// <div>
	//   <button class="mw-ui-button mw-ui-constructive mw-ui-big">.mw-ui-constructive</button>
	// </div>
	// <div>
	//   <button class="mw-ui-button mw-ui-destructive mw-ui-big">.mw-ui-destructive</button>
	// </div>
	//
	// Styleguide 2.1.6.
	&.mw-ui-big {
		font-size: 1.3em;
	}

	// Block buttons
	//
	// Some buttons might need to be stacked.
	//
	// Markup:
	// <div>
	//   <button class="mw-ui-button mw-ui-block">.mw-ui-button</button>
	// </div>
	// <div>
	//   <button class="mw-ui-button mw-ui-progressive mw-ui-block">.mw-ui-progressive</button>
	// </div>
	// <div>
	//   <button class="mw-ui-button mw-ui-constructive mw-ui-block">.mw-ui-constructive</button>
	// </div>
	// <div>
	//   <button class="mw-ui-button mw-ui-destructive mw-ui-block">.mw-ui-destructive</button>
	// </div>
	//
	// Styleguide 2.1.5.
	&.mw-ui-block {
		display: block;
		width: 100%;
	}

	// Progressive buttons
	//
	// Use progressive buttons for actions which lead to a next step in the process.
	// .mw-ui-primary is deprecated, kept for compatibility.
	//
	// Markup:
	// <div>
	//   <button class="mw-ui-button mw-ui-progressive">.mw-ui-progressive</button>
	// </div>
	// <div>
	//   <button class="mw-ui-button mw-ui-progressive" disabled>.mw-ui-progressive</button>
	// </div>
	//
	// Styleguide 2.1.1.
	&.mw-ui-progressive,
	&.mw-ui-primary {
		.button-colors(@colorProgressive);

		&.mw-ui-quiet {
			.button-colors-quiet(@colorProgressive);
		}
	}

	// Constructive buttons
	//
	// Use constructive buttons for actions which result in a final action in the process that results
	// in a change of state.
	// e.g. save changes button
	//
	// Markup:
	// <div>
	//   <button class="mw-ui-button mw-ui-constructive">.mw-ui-constructive</button>
	// </div>
	// <div>
	//   <button class="mw-ui-button mw-ui-constructive" disabled>.mw-ui-constructive</button>
	// </div>
	//
	// Styleguide 2.1.2.
	&.mw-ui-constructive {
		.button-colors(@colorConstructive);

		&.mw-ui-quiet {
			.button-colors-quiet(@colorConstructive);
		}
	}

	// Destructive buttons
	//
	// Use destructive buttons for actions that remove or limit, such as deleting a page or blocking a user.
	// This should not be used for cancel buttons.
	//
	// Markup:
	// <div>
	//   <button class="mw-ui-button mw-ui-destructive">.mw-ui-destructive</button>
	// </div>
	// <div>
	//   <button class="mw-ui-button mw-ui-destructive" disabled>.mw-ui-destructive</button>
	// </div>
	//
	// Styleguide 2.1.3.
	&.mw-ui-destructive {
		.button-colors(@colorDestructive);

		&.mw-ui-quiet {
			.button-colors-quiet(@colorDestructive);
		}
	}

	// Quiet buttons
	//
	// 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.
	// Its use is  not recommended on mobile/tablet due to lack of hover state.
	//
	// Markup:
	// <div>
	//   <button class="mw-ui-button mw-ui-quiet">.mw-ui-button</button>
	// </div>
	// <div>
	//   <button class="mw-ui-button mw-ui-constructive mw-ui-quiet">.mw-ui-constructive</button>
	// </div>
	// <div>
	//   <button class="mw-ui-button mw-ui-constructive mw-ui-quiet" disabled>.mw-ui-constructive</button>
	// </div>
	// <div>
	//   <button class="mw-ui-button mw-ui-destructive mw-ui-quiet">.mw-ui-destructive</button>
	// </div>
	// <div>
	//   <button class="mw-ui-button mw-ui-destructive mw-ui-quiet" disabled>.mw-ui-destructive</button>
	// </div>
	// <div>
	//   <button class="mw-ui-button mw-ui-progressive mw-ui-quiet">.mw-ui-progressive</button>
	// </div>
	// <div>
	//   <button class="mw-ui-button mw-ui-progressive mw-ui-quiet" disabled>.mw-ui-progressive</button>
	// </div>
	//
	// Styleguide 2.1.4.
	&.mw-ui-quiet {
		background: transparent;
		border: none;
		text-shadow: none;
		.button-colors-quiet(@colorButtonText);

		&:hover,
		&:focus {
			box-shadow: none;
		}

		&:active,
		&:disabled {
			background: transparent;
		}
	}
}

a.mw-ui-button {
	text-decoration: none;

	// This overrides an underline declaration on a:hover and a:focus in
	// commonElements.css, which the class alone isn't specific enough to do.
	&:hover,
	&:focus {
		text-decoration: none;
	}
}

// Button groups
//
// Group of buttons. Make sure you clear the floating after using a mw-ui-button-group.
//
// Markup:
// <div class="mw-ui-button-group">
//   <div class="mw-ui-button">A</div>
//   <div class="mw-ui-button">B</div>
//   <div class="mw-ui-button">C</div>
//   <div class="mw-ui-button">D</div>
// </div><div style="clear:both"></div>
//
// Styleguide 2.2.
.mw-ui-button-group > * {
	min-width: 48px;
	border-radius: 0;
	float: left;

	&:first-child {
		border-top-left-radius: @borderRadius;
		border-bottom-left-radius: @borderRadius;
	}

	&:not(:first-child) {
		border-left: none;
	}

	&:last-child{
		border-top-right-radius: @borderRadius;
		border-bottom-right-radius: @borderRadius;
	}
}