1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 | $button-font-family: inherit !default;
|
12 |
|
13 |
|
14 |
|
15 | $button-padding: 0.85em 1em !default;
|
16 |
|
17 |
|
18 |
|
19 | $button-margin: 0 0 $global-margin 0 !default;
|
20 |
|
21 |
|
22 |
|
23 | $button-fill: solid !default;
|
24 |
|
25 |
|
26 |
|
27 | $button-background: $primary-color !default;
|
28 |
|
29 |
|
30 |
|
31 | $button-background-hover: scale-color($button-background, $lightness: -15%) !default;
|
32 |
|
33 |
|
34 |
|
35 | $button-color: $white !default;
|
36 |
|
37 |
|
38 |
|
39 | $button-color-alt: $black !default;
|
40 |
|
41 |
|
42 |
|
43 | $button-radius: $global-radius !default;
|
44 |
|
45 |
|
46 |
|
47 | $button-hollow-border-width: 1px !default;
|
48 |
|
49 |
|
50 |
|
51 | $button-sizes: (
|
52 | tiny: 0.6rem,
|
53 | small: 0.75rem,
|
54 | default: 0.9rem,
|
55 | large: 1.25rem,
|
56 | ) !default;
|
57 |
|
58 |
|
59 |
|
60 | $button-palette: $foundation-palette !default;
|
61 |
|
62 |
|
63 |
|
64 | $button-opacity-disabled: 0.25 !default;
|
65 |
|
66 |
|
67 |
|
68 | $button-background-hover-lightness: -20% !default;
|
69 |
|
70 |
|
71 |
|
72 | $button-hollow-hover-lightness: -50% !default;
|
73 |
|
74 |
|
75 | @if $global-text-direction == 'rtl' {
|
76 | $button-margin: 0 0 $global-margin $global-margin !default;
|
77 | }
|
78 |
|
79 |
|
80 |
|
81 | $button-transition: background-color 0.25s ease-out, color 0.25s ease-out !default;
|
82 |
|
83 |
|
84 | @mixin button-base {
|
85 | @include disable-mouse-outline;
|
86 | display: inline-block;
|
87 | vertical-align: middle;
|
88 | margin: $button-margin;
|
89 | font-family: $button-font-family;
|
90 |
|
91 | @if (type-of($button-padding) == 'map') {
|
92 | @each $size, $padding in $button-padding {
|
93 | @include breakpoint($size) {
|
94 | padding: $padding;
|
95 | }
|
96 | }
|
97 | }
|
98 | @else {
|
99 | padding: $button-padding;
|
100 | }
|
101 |
|
102 | -webkit-appearance: none;
|
103 | border: 1px solid transparent;
|
104 | border-radius: $button-radius;
|
105 | transition: $button-transition;
|
106 |
|
107 | font-size: map-get($button-sizes, default);
|
108 | line-height: 1;
|
109 | text-align: center;
|
110 | cursor: pointer;
|
111 | }
|
112 |
|
113 |
|
114 |
|
115 | @mixin button-expand($expand: true) {
|
116 | @if $expand {
|
117 | display: block;
|
118 | width: 100%;
|
119 | margin-right: 0;
|
120 | margin-left: 0;
|
121 | }
|
122 | @else {
|
123 | display: inline-block;
|
124 | width: auto;
|
125 | margin: $button-margin;
|
126 | }
|
127 | }
|
128 |
|
129 |
|
130 |
|
131 |
|
132 |
|
133 | @mixin button-style(
|
134 | $background: $button-background,
|
135 | $background-hover: $button-background-hover,
|
136 | $color: $button-color,
|
137 | $background-hover-lightness: $button-background-hover-lightness
|
138 | ) {
|
139 | @if $color == auto {
|
140 | $color: color-pick-contrast($background, ($button-color, $button-color-alt));
|
141 | }
|
142 |
|
143 | @if $background-hover == auto {
|
144 | $background-hover: scale-color($background, $lightness: $background-hover-lightness);
|
145 | }
|
146 |
|
147 | background-color: $background;
|
148 | color: $color;
|
149 |
|
150 | &:hover, &:focus {
|
151 | background-color: $background-hover;
|
152 | color: $color;
|
153 | }
|
154 | }
|
155 |
|
156 |
|
157 | @mixin button-hollow {
|
158 | &,
|
159 | &:hover, &:focus {
|
160 | background-color: transparent;
|
161 | }
|
162 |
|
163 | &.disabled,
|
164 | &[disabled] {
|
165 | &,
|
166 | &:hover, &:focus {
|
167 | background-color: transparent;
|
168 | }
|
169 | }
|
170 | }
|
171 |
|
172 | @mixin button-hollow-style(
|
173 | $color: $button-background,
|
174 | $hover-lightness: $button-hollow-hover-lightness,
|
175 | $border-width: $button-hollow-border-width
|
176 | ) {
|
177 | $color-hover: scale-color($color, $lightness: $hover-lightness);
|
178 |
|
179 | border: $border-width solid $color;
|
180 | color: $color;
|
181 |
|
182 | &:hover, &:focus {
|
183 | border-color: $color-hover;
|
184 | color: $color-hover;
|
185 | &.disabled,
|
186 | &[disabled] {
|
187 | border: $border-width solid $color;
|
188 | color: $color;
|
189 | }
|
190 | }
|
191 | }
|
192 |
|
193 |
|
194 |
|
195 |
|
196 | @mixin button-disabled(
|
197 | $background: $button-background,
|
198 | $color: $button-color
|
199 | ) {
|
200 | @if $color == auto {
|
201 | $color: color-pick-contrast($background, ($button-color, $button-color-alt));
|
202 | }
|
203 |
|
204 | opacity: $button-opacity-disabled;
|
205 | cursor: not-allowed;
|
206 |
|
207 | &, &:hover, &:focus {
|
208 | background-color: $background;
|
209 | color: $color;
|
210 | }
|
211 | }
|
212 |
|
213 |
|
214 |
|
215 |
|
216 |
|
217 | @mixin button-dropdown(
|
218 | $size: 0.4em,
|
219 | $color: $white,
|
220 | $offset: get-side($button-padding, right)
|
221 | ) {
|
222 | &::after {
|
223 | @include css-triangle($size, $color, down);
|
224 | position: relative;
|
225 | top: 0.4em;
|
226 |
|
227 | display: inline-block;
|
228 | float: #{$global-right};
|
229 | margin-#{$global-left}: $offset;
|
230 | }
|
231 | }
|
232 |
|
233 |
|
234 |
|
235 |
|
236 |
|
237 |
|
238 |
|
239 | @mixin button(
|
240 | $expand: false,
|
241 | $background: $button-background,
|
242 | $background-hover: $button-background-hover,
|
243 | $color: $button-color,
|
244 | $style: $button-fill
|
245 | ) {
|
246 | @include button-base;
|
247 |
|
248 | @if $style == solid {
|
249 | @include button-style($background, $background-hover, $color);
|
250 | }
|
251 | @else if $style == hollow {
|
252 | @include button-hollow;
|
253 | @include button-hollow-style($background);
|
254 | }
|
255 |
|
256 | @if $expand {
|
257 | @include button-expand;
|
258 | }
|
259 | }
|
260 |
|
261 | @mixin foundation-button {
|
262 | .button {
|
263 | @include button;
|
264 |
|
265 |
|
266 | @each $size, $value in map-remove($button-sizes, default) {
|
267 | &.#{$size} {
|
268 | font-size: $value;
|
269 | }
|
270 | }
|
271 |
|
272 | &.expanded { @include button-expand; }
|
273 |
|
274 |
|
275 | @each $name, $color in $button-palette {
|
276 | @if $button-fill != hollow {
|
277 | &.#{$name} {
|
278 | @include button-style($color, auto, auto);
|
279 | }
|
280 | }
|
281 | @else {
|
282 | &.#{$name} {
|
283 | @include button-hollow-style($color);
|
284 | }
|
285 |
|
286 | &.#{$name}.dropdown::after {
|
287 | border-top-color: $color;
|
288 | }
|
289 | }
|
290 | }
|
291 |
|
292 |
|
293 | &.disabled,
|
294 | &[disabled] {
|
295 | @include button-disabled;
|
296 |
|
297 | @each $name, $color in $button-palette {
|
298 | &.#{$name} {
|
299 | @include button-disabled($color, auto);
|
300 | }
|
301 | }
|
302 | }
|
303 |
|
304 |
|
305 | @if $button-fill != hollow {
|
306 | &.hollow {
|
307 | @include button-hollow;
|
308 | @include button-hollow-style;
|
309 |
|
310 | @each $name, $color in $button-palette {
|
311 | &.#{$name} {
|
312 | @include button-hollow-style($color);
|
313 | }
|
314 | }
|
315 | }
|
316 | }
|
317 |
|
318 |
|
319 | @if $button-fill != clear {
|
320 | &.clear {
|
321 | @include button-hollow;
|
322 | @include button-hollow-style;
|
323 |
|
324 | &, &:hover, &:focus {
|
325 | &, &.disabled, &[disabled] {
|
326 | border-color: transparent;
|
327 | }
|
328 | }
|
329 |
|
330 | @each $name, $color in $button-palette {
|
331 | &.#{$name} {
|
332 | @include button-hollow-style($color);
|
333 |
|
334 | &, &:hover,
|
335 | &:focus {
|
336 | &,
|
337 | &.disabled,
|
338 | &[disabled] {
|
339 | border-color: transparent;
|
340 | }
|
341 | }
|
342 | }
|
343 | }
|
344 | }
|
345 | }
|
346 |
|
347 |
|
348 | &.dropdown {
|
349 | @include button-dropdown;
|
350 |
|
351 | @if $button-fill == hollow {
|
352 | &::after {
|
353 | border-top-color: $button-background;
|
354 | }
|
355 | }
|
356 |
|
357 | &.hollow {
|
358 | &::after {
|
359 | border-top-color: $button-background;
|
360 | }
|
361 |
|
362 | @each $name, $color in $button-palette {
|
363 | &.#{$name} {
|
364 | &::after {
|
365 | border-top-color: $color;
|
366 | }
|
367 | }
|
368 | }
|
369 | }
|
370 | }
|
371 |
|
372 |
|
373 | &.arrow-only::after {
|
374 | top: -0.1em;
|
375 | float: none;
|
376 | margin-#{$global-left}: 0;
|
377 | }
|
378 | }
|
379 | a.button {
|
380 | &:hover,
|
381 | &:focus {
|
382 | text-decoration: none;
|
383 | }
|
384 | }
|
385 | }
|