Skip to content

Instantly share code, notes, and snippets.

@ralphcrisostomo
Created July 3, 2016 15:42
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 ralphcrisostomo/0a934f894cff9eda3ed31fb7c56a5656 to your computer and use it in GitHub Desktop.
Save ralphcrisostomo/0a934f894cff9eda3ed31fb7c56a5656 to your computer and use it in GitHub Desktop.
Google Material Design Shadow SASS
//
// Google Material Design Shadow
// Ref: http://stackoverflow.com/questions/30533055/calculating-shadow-values-for-all-material-design-elevations
//
=shadow($dp)
@if $dp == 0
box-shadow : none
@else
$ambientY : $dp
$ambientBlur : if($dp == 1, 3, $dp * 2)
$ambientAlpha : ($dp + 10 + ($dp / 9.38)) / 100
$ambient : 0 $ambientY+px $ambientBlur+px rgba(0, 0, 0, $ambientAlpha)
$directY : if($dp < 10, if($dp % 2 == 0 , $dp - (($dp / 2) - 1) , ($dp - (($dp - 1) / 2))) , $dp - 4)
$directBlur : if($dp == 1, 3, $dp * 2)
$directAlpha : (24 - round($dp / 10)) / 100
$direct : 0 $directY+px $directBlur+px rgba(0, 0, 0, $directAlpha)
box-shadow : $ambient, $direct
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment