cef36d755fed2539cc7c88cb60953fed644a7943
[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 (T72072)
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: 0.546875em 1em;
37 line-height: 1.286;
38 margin: 0;
39 border-radius: @borderRadius;
40 .box-sizing( border-box );
41
42 // Disable weird iOS styling
43 -webkit-appearance: none;
44
45 // IE 6 & 7 hack
46 // https://stackoverflow.com/a/5838575/365238
47 *display: inline; /* stylelint-disable-line declaration-block-no-duplicate-properties */
48 zoom: 1;
49
50 // Ensure that buttons and inputs are nicely aligned when they have differing heights
51 vertical-align: middle;
52
53 // Content styling
54 .button-colors( @colorGray15, #fff, #d9d9d9 );
55 text-align: center;
56 font-weight: bold;
57
58 // Interaction styling
59 cursor: pointer;
60
61 &:focus {
62 outline-width: 0;
63
64 // Remove the inner border and padding in Firefox.
65 &::-moz-focus-inner {
66 border-color: transparent;
67 padding: 0;
68 }
69 }
70
71 // `:not()` is used exclusively for `transition`s as both are not supported by IE < 9
72 &:not( :disabled ) {
73 .transition( ~'background-color 100ms, color 100ms, border-color 100ms, box-shadow 100ms' );
74 }
75
76 &:disabled {
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 //
131 // Markup:
132 // <div>
133 // <button class="mw-ui-button mw-ui-progressive">.mw-ui-progressive</button>
134 // </div>
135 // <div>
136 // <button class="mw-ui-button mw-ui-progressive" disabled>.mw-ui-progressive</button>
137 // </div>
138 //
139 // Styleguide 2.1.1.
140 &.mw-ui-progressive {
141 .button-colors-primary( @colorProgressive, @colorProgressiveHighlight, @colorProgressiveActive );
142
143 &.mw-ui-quiet {
144 .button-colors-quiet( @colorProgressive, @colorProgressiveHighlight, @colorProgressiveActive );
145 }
146 }
147
148 // Destructive buttons
149 //
150 // Use destructive buttons for actions that remove or limit, such as deleting a page or blocking a user.
151 // This should not be used for cancel buttons.
152 //
153 // Markup:
154 // <div>
155 // <button class="mw-ui-button mw-ui-destructive">.mw-ui-destructive</button>
156 // </div>
157 // <div>
158 // <button class="mw-ui-button mw-ui-destructive" disabled>.mw-ui-destructive</button>
159 // </div>
160 //
161 // Styleguide 2.1.2.
162 &.mw-ui-destructive {
163 .button-colors-primary( @colorDestructive, @colorDestructiveHighlight, @colorDestructiveActive );
164
165 &.mw-ui-quiet {
166 .button-colors-quiet( @colorDestructive, @colorDestructiveHighlight, @colorDestructiveActive );
167 }
168 }
169
170 // Quiet buttons
171 //
172 // 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.
173 // Its use is not recommended on mobile/tablet due to lack of hover state.
174 //
175 // Markup:
176 // <div>
177 // <button class="mw-ui-button mw-ui-quiet">.mw-ui-button</button>
178 // </div>
179 // <div>
180 // <button class="mw-ui-button mw-ui-destructive mw-ui-quiet">.mw-ui-destructive</button>
181 // </div>
182 // <div>
183 // <button class="mw-ui-button mw-ui-destructive mw-ui-quiet" disabled>.mw-ui-destructive</button>
184 // </div>
185 // <div>
186 // <button class="mw-ui-button mw-ui-progressive mw-ui-quiet">.mw-ui-progressive</button>
187 // </div>
188 // <div>
189 // <button class="mw-ui-button mw-ui-progressive mw-ui-quiet" disabled>.mw-ui-progressive</button>
190 // </div>
191 //
192 // Styleguide 2.1.3.
193 &.mw-ui-quiet {
194 background: transparent;
195 border: 0;
196 .button-colors-quiet( @colorButtonText, @colorButtonTextHighlight, @colorButtonTextActive );
197
198 &:hover,
199 &:focus {
200 box-shadow: none;
201 }
202
203 &:active,
204 &:disabled {
205 background: transparent;
206 }
207 }
208 }
209
210 input.mw-ui-button,
211 button.mw-ui-button {
212 // Buttons in Firefox have extra height
213 &::-moz-focus-inner {
214 margin-top: -1px;
215 margin-bottom: -1px;
216 }
217 }
218
219 a.mw-ui-button {
220 text-decoration: none;
221
222 // This overrides an underline declaration on a:hover and a:focus in
223 // commonElements.css, which the class alone isn't specific enough to do.
224 &:hover,
225 &:focus {
226 text-decoration: none;
227 }
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 }