_background.scss 1.72 KB
Newer Older
1 2 3 4 5
//************************************************************************//
// Background property for adding multiple backgrounds using shorthand
// notation.
//************************************************************************//

6 7 8
@mixin background($backgrounds...) {
  $webkit-backgrounds: ();
  $spec-backgrounds: ();
9

10 11 12 13
  @each $background in $backgrounds {
    $webkit-background: ();
    $spec-background: ();
    $background-type: type-of($background);
14

15 16
    @if $background-type == string or list {
      $background-str: if($background-type == list, nth($background, 1), $background);
17

18 19
      $url-str:       str-slice($background-str, 0, 3);
      $gradient-type: str-slice($background-str, 0, 6);
20

21 22 23 24
      @if $url-str == "url" {
        $webkit-background: $background;
          $spec-background: $background;
      }
25

26 27 28 29 30
      @else if $gradient-type == "linear" {
        $gradients: _linear-gradient-parser("#{$background}");
        $webkit-background: map-get($gradients, webkit-image);
        $spec-background:   map-get($gradients, spec-image);
      }
31

32 33 34 35
      @else if $gradient-type == "radial" {
        $gradients: _radial-gradient-parser("#{$background}");
        $webkit-background: map-get($gradients, webkit-image);
        $spec-background:   map-get($gradients, spec-image);
36
      }
37

38
      @else {
39 40
        $webkit-background: $background;
          $spec-background: $background;
41 42
      }
    }
43 44 45 46

    @else {
      $webkit-background: $background;
        $spec-background: $background;
47
    }
48 49 50

    $webkit-backgrounds: append($webkit-backgrounds, $webkit-background, comma);
    $spec-backgrounds:   append($spec-backgrounds,   $spec-background,   comma);
51 52
  }

53 54 55
  background: $webkit-backgrounds;
  background: $spec-backgrounds;
}