UNPKG

6.38 kBtext/lessView Raw
1@import (reference) './imports/global';
2@import (reference) './imports/mixins/focus';
3
4/*! AUI Button */
5
6// Basic layout
7.aui-button {
8 #aui.focus-visible(#aui.with-focus-ring());
9 #aui.box-sizing();
10 #aui-buttons.aui-button-base();
11
12 display: inline-block;
13 height: @aui-button-height; // 30px - using ems so the fields increase in line with user specified font-sizes
14 line-height: @aui-button-line-height;
15 margin: 0;
16 padding: @aui-button-padding-y @aui-button-padding-x;
17 vertical-align: baseline;
18 white-space: nowrap;
19}
20
21// Basic button type
22.aui-button {
23 #aui-buttons.aui-button-style(normal);
24}
25
26// Ensure base link styles do not take precedence over button styles
27a.aui-button,
28.aui-button:link,
29.aui-button:visited {
30 #aui-buttons.aui-button-style();
31 text-decoration: none;
32}
33
34// Subtle button type
35.aui-button-subtle {
36 #aui-buttons.aui-subtle-button-style(normal);
37}
38
39// Light button type
40.aui-button-light {
41 --aui-btn-bg: var(--aui-button-light-bg-color);
42}
43
44//
45// Button pseudo-state styles.
46// NOTE:
47// Because of the cascade, subtle & light button types receive these styles, too.
48// This is deliberate! ;)
49//
50.aui-button {
51 &:focus,
52 &:hover {
53 #aui-buttons.aui-button-style(hover);
54 }
55
56 &:active {
57 #aui-buttons.aui-button-style(active);
58 }
59
60 &.active:not(.aui-button-link) {
61 #aui-buttons.aui-button-style(selected);
62 }
63}
64
65// Primary button type
66.aui-button-primary {
67 #aui-buttons.aui-primary-button-style(normal);
68
69 &:hover,
70 &:focus {
71 #aui-buttons.aui-primary-button-style(hover);
72 }
73
74 &:active {
75 #aui-buttons.aui-primary-button-style(active);
76 }
77
78 &.active {
79 #aui-buttons.aui-button-style(selected);
80 }
81}
82
83// Link + Text button types
84.aui-button-link,
85.aui-button-text {
86 #aui-buttons.aui-link-button-style(normal);
87
88 &:focus,
89 &:hover {
90 #aui-buttons.aui-link-button-style(hover);
91 }
92
93 &:active {
94 #aui-buttons.aui-link-button-style(active);
95 }
96}
97
98.aui-button {
99 // Selected button state - NOT supported for free-standing primary buttons
100 // ARIA usage from http://www.paciellogroup.com/blog/misc/ARIA/togglebutton.html
101 &[aria-pressed="true"] {
102 #aui-buttons.aui-button-style(selected);
103 }
104
105 &[aria-pressed="true"]:active {
106 #aui-buttons.aui-button-style(active);
107 }
108
109 // Disabled button states
110 // NOTE: these must be placed after all button types + states
111 // in order to avoid excessive selector weight.
112 &[disabled], &[aria-disabled="true"] {
113 & {
114 #aui-buttons.aui-button-style(disabled);
115 }
116
117 &.aui-button-subtle {
118 --aui-btn-bg: var(--aui-button-subtle-bg-color);
119 }
120
121 &.aui-button-primary {
122 #aui-buttons.aui-primary-button-style(disabled);
123 }
124
125 &.aui-button-link,
126 &.aui-button-text {
127 #aui-buttons.aui-link-button-style(disabled);
128 }
129 }
130}
131
132// Button variants
133// -------------
134// Where 'types' are stylistic, 'variants' affect the button layout.
135
136// Link buttons
137.aui-button.aui-button-link {
138 padding-left: 0;
139 padding-right: 0;
140}
141
142// Text buttons
143.aui-button.aui-button-text {
144 border: none;
145 font-size: inherit;
146 height: inherit;
147 line-height: normal;
148 padding: 0;
149}
150
151// Split buttons
152.aui-button.aui-button-split-main {
153 + .aui-button-split-more {
154 margin-left: @aui-grouped-button-spacing;
155 }
156}
157
158// Icon buttons - when a button label is present next to an aui-icon (eg sidebar config)
159.aui-button {
160 > .aui-icon {
161 + .aui-button-label {
162 margin-left: (@aui-grid / 2)-1;
163 }
164 }
165}
166
167// Compact buttons
168.aui-button.aui-button-compact {
169 font-size: @aui-font-size-small;
170 height: unit(26px / @aui-font-size-small, em); // 26px with 12px font-size
171 padding: (@aui-button-padding-y / 2) (@aui-button-padding-x * .8);
172 line-height: unit(20 / @aui-font-size-small);
173}
174
175//
176// Button groupings
177// -------------
178.aui-button ~ .aui-button {
179 margin-left: @aui-grid;
180}
181
182// aui-buttons groups buttons together into one button lozenge.
183.aui-buttons {
184 display: inline-flex;
185}
186
187.aui-buttons::after {
188 clear: both;
189 content: "";
190 display: table;
191}
192
193.aui-buttons .aui-button {
194 border-radius: 0;
195 margin: 0;
196}
197
198.aui-buttons .aui-button:first-child {
199 border-top-left-radius: @aui-button-border-radius;
200 border-bottom-left-radius: @aui-button-border-radius;
201}
202
203.aui-buttons .aui-button:last-child {
204 border-top-right-radius: @aui-button-border-radius;
205 border-bottom-right-radius: @aui-button-border-radius;
206}
207
208.aui-buttons + .aui-buttons {
209 margin-left: @aui-grid;
210}
211
212// Grouped Primary Buttons
213.aui-buttons .aui-button ~ .aui-button {
214 border-left-width: 0;
215 margin-left: @aui-grouped-button-spacing;
216}
217
218.aui-buttons .aui-button {
219 &:hover,
220 &:focus,
221 &:active {
222 position: relative;
223 }
224
225 &:focus {
226 z-index: 1;
227 }
228}
229
230// Cross-component integration
231// ----------------------------------------------------------------------
232// Icons Integration
233// ---------------------
234
235.aui-button.aui-button-compact .aui-icon {
236 margin-top: -1px; // icon is 1px off, adjust it so it is centered
237 vertical-align: middle;
238}
239
240// Button link - icon and text
241.aui-button.aui-button-link.aui-button-link-icon-text {
242 &:hover,
243 &:focus {
244 text-underline-position: under;
245
246 .aui-icon {
247 // Align icon with underline from parent (button)
248 text-underline-position: from-font;
249 // Safari works without above (but other browsers need it)
250 // It lowers underline on icon, but not on text (Safari)
251 text-underline-offset: 1px;
252 }
253 }
254}
255
256// Icon Colours
257// ----------
258.aui-button .aui-icon {
259 color: inherit;
260}
261
262// Busy buttons
263.aui-button[busy] {
264 position: relative;
265 // make the text 'disappear' while the spinner is visible
266 color: transparent !important;
267 // make the text unselectable while the spinner is visible,
268 // so it doesn't accidentally become visible again in a ctrl+a scenario
269 user-select: none;
270
271 aui-spinner {
272 position: absolute;
273 left: 0;
274 right: 0;
275 top: 0;
276 bottom: 0;
277 margin: auto;
278 color: var(--aui-btn-text);
279 }
280}