-
-
Save nex3/805090 to your computer and use it in GitHub Desktop.
This file contains 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
body { | |
foo: bottom; | |
foo: right; | |
foo: bottom right; | |
} |
This file contains 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 opposite-position($pos) | |
@if $pos == top | |
@return bottom | |
@else if $pos == bottom | |
@return top | |
@else if pos == left | |
@return right | |
@else if pos == right | |
@return left | |
@else | |
@warn 'Invalid position ' + pos | |
@return none | |
@function opposite($positions) | |
$ret: () | |
@each $pos in $positions | |
$pos: opposite-position(pos) | |
$ret: if(length($ret) == 0, $pos, join($ret, $pos)) | |
body | |
foo: opposite(top) | |
foo: opposite(left) | |
foo: opposite(top left) |
This file contains 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
opposite-position(pos) | |
if pos == top | |
bottom | |
else if pos == bottom | |
top | |
else if pos == left | |
right | |
else if pos == right | |
left | |
else | |
error('Invalid position ' + pos) | |
opposite(positions) | |
for pos in positions | |
pos = opposite-position(pos) | |
ret = ret is defined ? ret pos : pos | |
body | |
foo opposite(top) | |
foo opposite(left) | |
foo opposite(top left) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment