Created
September 6, 2017 16:05
-
-
Save simmo/75795070e9beba74495a62f14e2edc40 to your computer and use it in GitHub Desktop.
Ideas for absolute Sass helper
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 position($position, $args: null) { | |
$offsets: bottom left right top; | |
position: $position; | |
@if (type-of($args) == 'list') { | |
@each $offset in $offsets { // 3 | |
$index: index($args, $offset); // 4 | |
@if $index { // 5 | |
@if $index == length($args) { // 6 | |
#{$offset}: 0; // 7 | |
} | |
@else { // 8 | |
$next: nth($args, $index + 1); // 9 | |
@if is-valid-length($next) { // 10 | |
#{$offset}: $next; // 11 | |
} | |
@else if index($offsets, $next) { // 12 | |
#{$offset}: 0; // 13 | |
} | |
@else { // 14 | |
@warn "Invalid value `#{$next}` for offset `#{$offset}`."; // 15 | |
} | |
} | |
} | |
} | |
} | |
@else if (type-of($args) == 'number') { | |
@each $offset in $offsets { | |
#{$offset}: $args; | |
} | |
} | |
} | |
@mixin absolute($args: null) { | |
@include position(absolute, $args); | |
} | |
.test { | |
@include absolute(left 10px bottom 0); | |
} | |
.test2 { | |
-ms-scroll-snap-type: proximity; | |
scroll-snap-type: mandatory; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment