| 1 |
@mixin border-image($images) { |
| 2 |
-webkit-border-image: _border-add-prefix($images, webkit); |
| 3 |
-moz-border-image: _border-add-prefix($images, moz); |
| 4 |
-o-border-image: _border-add-prefix($images, o); |
| 5 |
border-image: _border-add-prefix($images); |
| 6 |
} |
| 7 |
|
| 8 |
@function _border-add-prefix($images, $vendor: false) { |
| 9 |
$border-image: null; |
| 10 |
$images-type: type-of(nth($images, 1)); |
| 11 |
$first-var: nth(nth($images, 1), 1); // Get type of Gradient (Linear || radial) |
| 12 |
|
| 13 |
// If input is a gradient |
| 14 |
@if $images-type == string { |
| 15 |
@if ($first-var == "linear") or ($first-var == "radial") { |
| 16 |
$gradient-type: nth($images, 1); // Get type of gradient (linear || radial) |
| 17 |
$gradient-pos: nth($images, 2); // Get gradient position |
| 18 |
$gradient-args: nth($images, 3); // Get actual gradient (red, blue) |
| 19 |
$gradient-positions: _gradient-positions-parser($gradient-type, $gradient-pos); |
| 20 |
$border-image: _render-gradients($gradient-positions, $gradient-args, $gradient-type, $vendor); |
| 21 |
} |
| 22 |
// If input is a URL |
| 23 |
@else { |
| 24 |
$border-image: $images; |
| 25 |
} |
| 26 |
} |
| 27 |
// If input is gradient or url + additional args |
| 28 |
@else if $images-type == list { |
| 29 |
$type: type-of(nth($images, 1)); // Get type of variable - List or String |
| 30 |
|
| 31 |
// If variable is a list - Gradient |
| 32 |
@if $type == list { |
| 33 |
$gradient: nth($images, 1); |
| 34 |
$gradient-type: nth($gradient, 1); // Get type of gradient (linear || radial) |
| 35 |
$gradient-pos: nth($gradient, 2); // Get gradient position |
| 36 |
$gradient-args: nth($gradient, 3); // Get actual gradient (red, blue) |
| 37 |
$gradient-positions: _gradient-positions-parser($gradient-type, $gradient-pos); |
| 38 |
$border-image: _render-gradients($gradient-positions, $gradient-args, $gradient-type, $vendor); |
| 39 |
|
| 40 |
@for $i from 2 through length($images) { |
| 41 |
$border-image: append($border-image, nth($images, $i)); |
| 42 |
} |
| 43 |
} |
| 44 |
} |
| 45 |
@return $border-image; |
| 46 |
} |
| 47 |
|
| 48 |
//Examples: |
| 49 |
// @include border-image(url("image.png")); |
| 50 |
// @include border-image(url("image.png") 20 stretch); |
| 51 |
// @include border-image(linear-gradient(45deg, orange, yellow)); |
| 52 |
// @include border-image(linear-gradient(45deg, orange, yellow) stretch); |
| 53 |
// @include border-image(linear-gradient(45deg, orange, yellow) 20 30 40 50 stretch round); |
| 54 |
// @include border-image(radial-gradient(top, cover, orange, yellow, orange)); |
| 55 |
|