Created
February 15, 2020 23:52
-
-
Save tomatrow/a6de38a9e69878c77996baae734859b5 to your computer and use it in GitHub Desktop.
Braket Border SCSS Style
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
// for the headings in sidebars | |
$braket-border-opposites: ( | |
left: right, | |
right: left, | |
top: bottom, | |
bottom: top | |
); | |
@mixin braket-border-child($direction, $border-width, $length) { | |
content: ""; | |
border: $border-width solid black; | |
position: absolute; | |
$opposite: map-get($braket-border-opposites, $direction); | |
border-#{$opposite}: none; | |
#{$direction}: 0; | |
$adjusted-cross-length: calc(100% - #{$border-width}); | |
@if $direction == left or $direction == right { | |
width: $length; | |
height: $adjusted-cross-length; | |
top: 0; | |
} @else if $direction == top or $direction == bottom { | |
width: $adjusted-cross-length; | |
height: $length; | |
left: 0; | |
} @else { | |
@error "Unknown direction #{$direction}."; | |
} | |
} | |
@mixin braket-border($border-width: 2px, $length: 10%, $axis: horizontal) { | |
$first: ""; | |
@if $axis == horizontal { | |
$first: left; | |
} @else if $axis == vertical { | |
$first: top; | |
} @else { | |
@error "Unknown axis #{$axis}."; | |
} | |
$second: map-get($braket-border-opposites, $first); | |
position: relative; | |
&:before { | |
@include braket-border-child($first, $border-width, $length); | |
} | |
&:after { | |
@include braket-border-child($second, $border-width, $length); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment