forked from drublic/Sass-Mixins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
_linear-gradient.scss
43 lines (40 loc) · 1.56 KB
/
_linear-gradient.scss
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
///
/// Generates a linear gradient for a given element with a fallback color.
///
/// Note: By default this linear-gradient-mixin encourages people to use the
/// latest CSS-syntax for gradients.
///
/// @author drublic
///
/// @link http://caniuse.com/#feat=css-gradients caniuse
/// @link https://drafts.csswg.org/css-images-3/#linear-gradients spec
///
/// @require helper-gradient-angle
///
/// @param {String | Angle} $direction [to bottom] - Either an angle value or any of `to bottom`, `to right`, `to top` or `to left`
/// @param {Color} $fallback [#ccc]
/// @param {Color} $from [#ccc]
/// @param {Color} $to [#aaa]
///
/// @output
/// ```css
/// background-color: <fallback>;
/// background-image: -webkit-gradient(linear, <direction - old converted>, from(<from>), to(<to>));
/// background-image: -webkit-linear-gradient(<direction - converted>, <from>, <to>);
/// background-image: linear-gradient(<direction>, <from>, <to>);
/// ```
///
/// @example
/// .selector {
/// @include x-linear-gradient('to bottom', #ccc, #ddd, #bbb);
/// }
///
@mixin x-linear-gradient ($direction: 'to bottom', $fallback: #ccc, $from: #ccc, $to: #aaa) {
$directions: helper-gradient-angle($direction);
// Provide a fallback-color
background-color: $fallback;
// Cross-browser linear-gradients
background-image: -webkit-gradient(linear, unquote(nth($directions, 2)), from($from), to($to)); // Android 2.1-3.0
background-image: -webkit-linear-gradient(unquote(nth($directions, 1)), $from, $to);
background-image: linear-gradient(unquote($direction), $from, $to);
}