_mixin.scss 5.63 KB
@mixin clearfix {
  &:after {
    content: "";
    display: table;
    clear: both;
  }
}

// Rem
@mixin rem($property, $values...) {
  $n: length($values);
  $i: 1;
  $pxlist: ();
  $remlist: ();
  @while $i <= $n {
    $itemVal: (nth($values, $i));
    @if $itemVal != "auto" {
      $pxlist: append($pxlist, $itemVal + px);
      $remlist: append($remlist, ($itemVal / 10) + rem);
    } @else {
      $pxlist: append($pxlist, auto);
      $remlist: append($remlist, auto);
    }
    $i: $i + 1;
  }
  #{$property}: $pxlist;
  #{$property}: $remlist;
}

// Border Radius
@mixin border-radius($radius) {
  -webkit-border-radius: $radius;
  -moz-border-radius: $radius;
  -ms-border-radius: $radius;
  border-radius: $radius;
}

// User Select
@mixin user-select($value) {
  -moz-user-select: $value;
  -webkit-user-select: $value;
  -ms-user-select: $value;
  user-select: $value;
}

// Background Opacity
@mixin background-opacity($red, $green, $blue, $opacity) {
  background: rgb($red, $green, $blue);
  background: rgba($red, $green, $blue, $opacity);
}

// Opacity
@mixin opacity($opacity) {
  opacity: $opacity;
  $opacity-ie: $opacity * 100;
  filter: alpha(opacity=$opacity-ie);
}

// Text Shadow
@mixin text-shadow($x: 0px, $y: 1px, $blur: 2px, $color: #000) {
  text-shadow: $x $y $blur $color;
}

@mixin linear-gradient-rgba($red_start, $green_start, $blue_start, $opacity_start, $point_start, $red_end, $green_end, $blue_end, $opacity_end, $point_end ) {
  background: -moz-linear-gradient(top, rgba($red_start, $green_start, $blue_start, $opacity_start) $point_start, rgba($red_end, $green_end, $blue_end, $opacity_end) $point_end);
  background: -webkit-gradient(linear, left top, left bottom, color-stop($point_start, rgba($red_start, $green_start, $blue_start, $opacity_start)), color-stop($point_end, rgba($red_end, $green_end, $blue_end, $opacity_end)));
  background: -webkit-linear-gradient(top, rgba($red_start, $green_start, $blue_start, $opacity_start) $point_start, rgba($red_end, $green_end, $blue_end, $opacity_end) $point_end);
  background: -o-linear-gradient(top, rgba($red_start, $green_start, $blue_start, $opacity_start) $point_start, rgba($red_end, $green_end, $blue_end, $opacity_end) $point_end);
  background: -ms-linear-gradient(top, rgba($red_start, $green_start, $blue_start, $opacity_start) $point_start, rgba($red_end, $green_end, $blue_end, $opacity_end) $point_end);
  background: linear-gradient(to bottom, rgba($red_start, $green_start, $blue_start, $opacity_start) $point_start, rgba($red_end, $green_end, $blue_end, $opacity_end) $point_end);
}

@mixin box-shadow($x: 2px, $y: 2px, $blur: 5px, $box-shadow-red: 255, $box-shadow-green: 255, $box-shadow-blue: 255, $box-shadow-opacity: 0.75, $inset: "") {
  @if ($inset != "") {
    -webkit-box-shadow: $inset $x $y $blur rgba($box-shadow-red, $box-shadow-green, $box-shadow-blue, $box-shadow-opacity);
    -moz-box-shadow: $inset $x $y $blur rgba($box-shadow-red, $box-shadow-green, $box-shadow-blue, $box-shadow-opacity);
    box-shadow: $inset $x $y $blur rgba($box-shadow-red, $box-shadow-green, $box-shadow-blue, $box-shadow-opacity);
  } @else {
    -webkit-box-shadow: $x $y $blur rgba($box-shadow-red, $box-shadow-green, $box-shadow-blue, $box-shadow-opacity);
    -moz-box-shadow: $x $y $blur rgba($box-shadow-red, $box-shadow-green, $box-shadow-blue, $box-shadow-opacity);
    box-shadow: $x $y $blur rgba($box-shadow-red, $box-shadow-green, $box-shadow-blue, $box-shadow-opacity);
  }
}

//Animation
@mixin transition($transition-property, $transition-time, $method) {
  -webkit-transition: $transition-property $transition-time $method;
  -moz-transition: $transition-property $transition-time $method;
  -ms-transition: $transition-property $transition-time $method;
  -o-transition: $transition-property $transition-time $method;
  transition: $transition-property $transition-time $method;
}

@mixin transform($transforms) {
  -webkit-transform: $transforms;
  -moz-transform: $transforms;
  -ms-transform: $transforms;
  -o-transform: $transforms;
  transform: $transforms;
}

@mixin animation($str) {
  -webkit-animation: #{$str};
  -moz-animation: #{$str};
  -ms-animation: #{$str};
  -o-animation: #{$str};
  animation: #{$str};
}

@mixin translate3d($x, $y, $z) {
  -webkit-transform: translate3d($x, $y, $z);
  -moz-transform: translate3d($x, $y, $z);
  -ms-transform: translate3d($x, $y, $z);
  -o-transform: translate3d($x, $y, $z);
  transform: translate3d($x, $y, $z);
}

@mixin keyframes($animation-name) {
  @-webkit-keyframes #{$animation-name} {
    @content;
  }
  @-moz-keyframes #{$animation-name} {
    @content;
  }
  @-ms-keyframes #{$animation-name} {
    @content;
  }
  @-o-keyframes #{$animation-name} {
    @content;
  }
  @keyframes #{$animation-name} {
    @content;
  }
}

// Viewport
@mixin bp-wide {
  @media only screen and (min-width: 90em) { //1440px
    @content;
  }
}

@mixin bp-full {
  @media only screen and (min-width: 77.5em) { //1240px
    @content;
  }
}

@mixin bp-large-full {
  @media only screen and (min-width: 74.5em) { //1192px
    @content;
  }
}

@mixin bp-large {
  @media only screen and (min-width: 64em) { //1024px
    @content;
  }
}
@mixin bp-medium-large {
  @media only screen and (min-width: 991px) { //991px
    @content;

  }
}

@mixin bp-medium {
  @media only screen and (min-width: 48em) { //768px
    @content;
  }
}

@mixin bp-small {
  @media only screen and (min-width: 30em) { //480px
    @content;
  }
}

@mixin bp-mini {
  @media only screen and (min-width: 22.5em) { //360px
    @content;
  }
}