Created
January 23, 2017 16:05
-
-
Save koenverburg/acb0c6111d18f8a0097d36726072605c to your computer and use it in GitHub Desktop.
cool sass mixins
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
/** Computes a top-shadow for a card effect. | |
* @param {Number} $depth - depth level | |
*/ @return {List} | |
@function top-shadow($depth) { | |
$primary-offset: nth(1.5 3 10 14 19, $depth) * 1px; | |
$blur: nth(1.5 3 10 14 19, $depth) * 4px; | |
$color: rgba(black, nth(.12 .16 .19 .25 .30, $depth)); | |
@return 0 $primary-offset $blur $color; | |
} | |
/** Computes a bottom-shadow for a card effect. | |
* @param {Number} $depth - depth level | |
*/ @return {List} | |
@function bottom-shadow($depth) { | |
$primary-offset: nth(1.5 3 6 10 15, $depth) * 1px; | |
$blur: nth(1 3 3 5 6, $depth) * 4px; | |
$color: rgba(black, nth(.24 .23 .23 .22 .22, $depth)); | |
@return 0 $primary-offset $blur $color; | |
} | |
@mixin card($depth) { | |
@if $depth < 1 { | |
box-shadow: none; | |
} @else if $depth > 5 { | |
@warn "Invalid $depth `#{$depth}` for mixin `card`."; | |
} @else { | |
box-shadow: bottom-shadow($depth), top-shadow($depth); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment