Last active
December 20, 2015 04:28
-
-
Save cahnory/6070682 to your computer and use it in GitHub Desktop.
Next PlastiCSS pin mixin
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 pin($top: false, $right: false, $bottom: false, $left: false, $position: absolute, $all: false, $x: false, $y: false) { | |
// All the same value | |
@if relevant($all) { | |
bottom: $all; | |
left: $all; | |
right: $all; | |
top: $all; | |
} | |
@else { | |
// Left == right | |
@if relevant($x) { | |
left: $x; | |
right: $x; | |
} | |
// Left != right | |
@else { | |
@if relevant($left) { | |
left: $left; | |
} | |
@if relevant($right) { | |
right: $right; | |
} | |
} | |
// Top == bottom | |
@if relevant($y) { | |
bottom: $y; | |
top: $y; | |
} | |
@else { | |
@if relevant($bottom) { | |
bottom: $bottom; | |
} | |
@if relevant($top) { | |
top: $top; | |
} | |
} | |
} | |
@if relevant($position) { | |
position: $position; | |
} | |
} |
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
@function relevant($value, $ignore...) { | |
@if length($value) == 0 or $value == false or $value == null { | |
@return false; | |
} | |
@each $ignored in $ignore { | |
@if $value == $ignored | |
or type-of($value) == color and type-of($ignored) == color and same-color($value, $ignored) { | |
@return false | |
} | |
} | |
@return true; | |
} |
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
@function same-color($a, $b, $alpha: true) { | |
@if $alpha and alpha($a) != alpha($b) { | |
@return false; | |
} | |
@return rgb(red($a), green($a), blue($a)) == rgb(red($b), green($b), blue($b)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment