Last active
July 19, 2019 21:38
-
-
Save yoSteve/fa4ded2798f66bdbe9dd4c431407beab to your computer and use it in GitHub Desktop.
Shadow: A Sassy Mixin for Material-style shadows
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@mixin shadow($height: 'lowest', $color: #000, $darkness: 1, $inset: false) { | |
@if $height == 'lowest' { | |
box-shadow: 0 1px 3px rgba($color, 0.12 * $darkness), | |
0 1px 2px rgba($color, 0.24 * $darkness); | |
@if $inset { | |
box-shadow: inset 0 1px 3px rgba($color, 0.12 * $darkness), | |
inset 0 1px 2px rgba($color, 0.24 * $darkness); | |
} | |
} | |
@if $height == 'low' { | |
box-shadow: 0 3px 6px rgba($color, 0.16 * $darkness), | |
0 3px 3px rgba($color, 0.23 * $darkness); | |
@if $inset { | |
box-shadow: inset 0 3px 6px rgba($color, 0.16 * $darkness), | |
inset 0 3px 3px rgba($color, 0.23 * $darkness); | |
} | |
} | |
@if $height == 'medium' { | |
box-shadow: 0 10px 20px rgba($color, 0.19 * $darkness), | |
0 8px 14px rgba($color, 0.21 * $darkness), | |
0 6px 6px rgba($color, 0.23 * $darkness); | |
@if $inset { | |
box-shadow: inset 0 10px 20px rgba($color, 0.19 * $darkness), | |
inset 0 8px 14px rgba($color, 0.21 * $darkness), | |
inset 0 6px 6px rgba($color, 0.23 * $darkness); | |
} | |
} | |
@if $height == 'high' { | |
box-shadow: 0 14px 28px rgba($color, 0.25 * $darkness), | |
0 10px 10px rgba($color, 0.22 * $darkness); | |
@if $inset { | |
box-shadow: inset 0 14px 28px rgba($color, 0.25 * $darkness), | |
inset 0 10px 10px rgba($color, 0.22 * $darkness); | |
} | |
} | |
@if $height == 'highest' { | |
box-shadow: 0 19px 38px rgba($color, 0.30 * $darkness), | |
0 17px 20px rgba($color, 0.26 * $darkness), | |
0 15px 12px rgba($color, 0.22 * $darkness); | |
@if $inset { | |
box-shadow: inset 0 19px 38px rgba($color, 0.30 * $darkness), | |
inset 0 17px 20px rgba($color, 0.26 * $darkness), | |
inset 0 15px 12px rgba($color, 0.22 * $darkness); | |
} | |
} | |
@if $height == 'none' { | |
box-shadow: none; | |
} | |
} |
Now with $inset variable to turn that shadow inside out!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Now with adjustable Darkness!