Skip to content

Instantly share code, notes, and snippets.

@alehlopeh
Created July 25, 2013 23:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alehlopeh/6084688 to your computer and use it in GitHub Desktop.
Save alehlopeh/6084688 to your computer and use it in GitHub Desktop.
long shadows scss mixins
// Drop shadows
@mixin box-shadow($shadow, $moreshadow) {
-webkit-box-shadow: $moreshadow; // iOS <4.3 & Android <4.1
box-shadow: $moreshadow;
}
// LONG SHADOW MIXIN
// from http://codepen.io/awesomephant/pen/mAxHz
// USE: @include long-shadow($type: text, $color: indigo, $length: 50, $fadeout: false, $skew: true);
// EG: @include long-shadow(text, darken($twitter-blue, 10), 55, true);
@mixin long-shadow($type, $color, $length, $fadeout: true, $skew: false){
$shadow: '';
@if $fadeout == true{
@for $i from 1 to $length - 1 {
@if type == text or $skew == false{
$shadow: $shadow + $i + 'px ' + $i + 'px 0 ' + rgba($color, 1 - $i / $length) + ',';
}
@if $type == box and $skew == true{
$shadow: $shadow + $i + 'px ' + $i + 'px 0 ' + $i * .2 + 'px ' + rgba($color, 1 - $i / $length) + ',';
}
}
$shadow: $shadow + $length + 'px ' + $length + 'px 0 ' + rgba($color, 0);
}
@if $fadeout == false{
@if $skew == true and $type == box {
@for $i from 0 to $length - 1 {
$shadow: $shadow + $i + 'px ' + $i + 'px 0 ' + $i * .1 + 'px ' + $color + ',';
}
}
@if skew == false or $type == text{
@for $i from 0 to $length - 1 {
$shadow: $shadow + $i + 'px ' + $i + 'px 0 ' + $color + ',';
}
}
$shadow: $shadow + $length + 'px ' + $length + 'px 0 ' + $color;
}
$shadow: unquote($shadow);
@if $type == 'box' {
box-shadow: $shadow;}
@if $type == 'text' {
text-shadow: $shadow;}
}
@mixin long-shadow-left($type, $color, $length, $fadeout: true, $skew: false){
$shadow: '';
@if $fadeout == true{
@for $i from 1 to $length - 1 {
@if type == text or $skew == false{
$shadow: $shadow + '-' + $i + 'px ' + '-' + $i + 'px 0 ' + rgba($color, 1 - $i / $length) + ',';
}
@if $type == box and $skew == true{
$shadow: $shadow + '-' + $i + 'px ' +'-' + $i + 'px 0 ' + '-' + $i * .2 + 'px ' + rgba($color, 1 - $i / $length) + ',';
}
}
$shadow: $shadow + $length + 'px ' + $length + 'px 0 ' + rgba($color, 0);
}
@if $fadeout == false{
@if $skew == true and $type == box {
@for $i from 0 to $length - 1 {
$shadow: $shadow + $i + '-' + 'px ' + $i + '-' + 'px 0 ' + '-' + $i * .1 + 'px ' + $color + ',';
}
}
@if skew == false or $type == text{
@for $i from 0 to $length - 1 {
$shadow: $shadow + '-' + $i + 'px ' + '-' + $i + 'px 0 ' + $color + ',';
}
}
$shadow: $shadow + '-' + $length + 'px ' + '-' + $length + 'px 0 ' + $color;
}
$shadow: unquote($shadow);
@if $type == 'box' {
box-shadow: $shadow;}
@if $type == 'text' {
text-shadow: $shadow;}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment