/* Mixin */ @mixin vertical-align($position: relative) { position: $position; top: 50%; -webkit-transform: translateY(-50%); -ms-transform: translateY(-50%); transform: translateY(-50%); } @mixin border-radius($radius) { -webkit-border-radius: $radius; -moz-border-radius: $radius; border-radius: $radius; } @mixin rotate($angle) { -ms-transform: rotate($angle); -webkit-transform: rotate($angle); transform: rotate($angle); } @mixin subtle-shadow() { box-shadow: 0px 3px 6px rgba($dark-1, 0.3); } @mixin sharp-shadow() { box-shadow: 0px 1px 2px rgba($dark-1, 0.5); } @mixin gradient($from, $to,$type) { ///* fallback/image non-cover color */ background-color: $from; /* Firefox 3.6+ */ background-image: -moz-linear-gradient($from, $to); /* Safari 4+, Chrome 1+ */ background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from($from), to($to)); /* Safari 5.1+, Chrome 10+ */ background-image: -webkit-linear-gradient($from, $to); /* Opera 11.10+ */ background-image: -o-linear-gradient($from, $to); border-color: $from; } @function shift-color($color,$delta:.15){ @if(lightness($color) > 50){ @return darken($color, $delta * .4); } @else{ @return lighten($color, $delta * 1.2) } } @function set-color($color) { @if (lightness($color) > 40) { @return $dark-1; } @else { @return $light-1; } } @function color_luminance($color) { // Adapted from: https://github.com/LeaVerou/contrast-ratio/blob/gh-pages/color.js // Formula: http://www.w3.org/TR/2008/REC-WCAG20-20081211/#relativeluminancedef $rgba: red($color), green($color), blue($color); $rgba2: (); @for $i from 1 through 3 { $rgb: nth($rgba, $i); $rgb: $rgb / 255; $rgb: if($rgb < .03928, $rgb / 12.92, pow(($rgb + .055) / 1.055, 2.4)); $rgba2: append($rgba2, $rgb); } @return .2126 * nth($rgba2, 1) + .7152 * nth($rgba2, 2) + 0.0722 * nth($rgba2, 3); } @function color_contrast($color1, $color2) { // Adapted from: https://github.com/LeaVerou/contrast-ratio/blob/gh-pages/color.js // Formula: http://www.w3.org/TR/2008/REC-WCAG20-20081211/#contrast-ratiodef $luminance1: color_luminance($color1) + .05; $luminance2: color_luminance($color2) + .05; $ratio: $luminance1 / $luminance2; @if $luminance2 > $luminance1 { $ratio: 1 / $ratio; } $ratio: round($ratio * 10) / 10; @return $ratio; }