Skip to content

Instantly share code, notes, and snippets.

@ribeiroevandro
Last active March 27, 2017 09:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ribeiroevandro/ded46a6952faea01add3ec9cf17be36f to your computer and use it in GitHub Desktop.
Save ribeiroevandro/ded46a6952faea01add3ec9cf17be36f to your computer and use it in GitHub Desktop.
//
// Default
// Usage: $triangle(width, height, direction, color)
// ------------------------------------------------------------
$triangle($width = 10px, $height = 10px, $direction = 'bottom', $color = $gray-darker)
background none
border-style solid
height 0
width 0
// Styles for each direction
// @stylint off
directions = {
top: {
border-width: 0 ($width * .5) $height ($width * .5),
border-color: transparent transparent $color transparent
},
topRight: {
border-width: 0 $width $height 0,
border-color: transparent $color transparent transparent
},
right: {
border-width: ($height * .5) 0 ($height *.5) $width,
border-color: transparent transparent transparent $color
},
bottomRight: {
border-width: 0 0 $height $width,
border-color: transparent transparent $color transparent
},
bottom: {
border-width: $height ($width * .5) 0 ($width * .5),
border-color: $color transparent transparent transparent
},
bottomLeft: {
border-width: $width 0 0 $height,
border-color: transparent transparent transparent $color
},
left: {
border-width: ($height * .5) $width ($height * .5) 0,
border-color: transparent $color transparent transparent
},
topLeft: {
border-width: $height $width 0 0,
border-color: $color transparent transparent transparent
}
}
// Mixin styles for passed direction
styles = directions[$direction]
{styles}
// @stylint on
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment