Last active
January 6, 2016 18:02
-
-
Save erin-dot-io/9012208 to your computer and use it in GitHub Desktop.
This is the SCSS partial I use to initialize all of my newly created Bourbon/Neat projects. Requires http://bourbon.io/ and http://neat.bourbon.io/
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
///////////////////////////////////////////////////////////////////// | |
// // | |
// INITIALIZE ················································ // | |
// // | |
// put all non-directly compiled, globally required CSS here // | |
// (variables, mixins, librabry includes like bourbon/neat, etc) // | |
// // | |
// add "@import 'init';" to the top of every scss partial // | |
// // | |
///////////////////////////////////////////////////////////////////// | |
@import "bourbon"; | |
@import "neat"; | |
//// VARIABLES //// | |
// colors | |
// typography | |
//// MIXINS //// | |
// css-arrow mixin | |
// use: | |
// @include css-arrow(right, center, 20px, 0, #ddd, #aaa, flag); | |
@mixin css-arrow($box-edge : bottom, | |
$edge-side : center, | |
$arrow-size : 10px, | |
$edge-side-offset : 0, | |
$fill-color : black, | |
$border-color : none, | |
$border-style : border) { | |
// initiate internal variables | |
$box-edge-inverse: bottom; | |
$edge-side-pos: $edge-side; | |
$edge-side-pos-value: 0; | |
// establish inverse variables | |
@if $box-edge == top { $box-edge-inverse: bottom; } | |
@else if $box-edge == right { $box-edge-inverse: left; } | |
@else if $box-edge == bottom { $box-edge-inverse: top; } | |
@else if $box-edge == left { $box-edge-inverse: right; } | |
// calculate remaining internal variables | |
@if ($box-edge == 'top' or | |
$box-edge == 'bottom') { | |
@if $edge-side == center { | |
$edge-side-pos: left; | |
$edge-side-pos-value: 50%; | |
$edge-side-offset: (-$arrow-size); | |
} | |
} | |
@if ($box-edge == 'left' or | |
$box-edge == 'right') { | |
@if $edge-side == center { | |
$edge-side-pos: top; | |
$edge-side-pos-value: 50%; | |
$edge-side-offset: (-$arrow-size); | |
} | |
} | |
&:after, &:before { | |
content: " "; | |
height: 0; | |
width: 0; | |
position: absolute; | |
pointer-events: none; | |
border: solid rgba(#fff, 0); | |
} | |
&:after { | |
border-color: rgba(#fff, 0); | |
border-width: $arrow-size - 1; | |
#{$box-edge}: (-$arrow-size) - $arrow-size + 2; | |
border-#{$box-edge-inverse}-color: $fill-color; | |
#{$edge-side-pos}: $edge-side-pos-value; | |
margin-#{$edge-side-pos}: $edge-side-offset + 1; | |
} | |
@if $border-style == flag { | |
@include border-radius(2px); | |
&:before { | |
border-color: rgba(#fff, 0); | |
border-width: $arrow-size - 1; | |
#{$box-edge}: (-$arrow-size) - $arrow-size + 2; | |
border-#{$box-edge-inverse}-color: $border-color; | |
#{$edge-side-pos}: $edge-side-pos-value; | |
margin-#{$edge-side-pos}: $edge-side-offset + 2; | |
} | |
} @else { | |
&:before { | |
border-color: rgba(#fff, 0); | |
border-width: $arrow-size; | |
#{$box-edge}: (-$arrow-size) - $arrow-size; | |
border-#{$box-edge-inverse}-color: $border-color; | |
#{$edge-side-pos}: $edge-side-pos-value; | |
margin-#{$edge-side-pos}: $edge-side-offset; | |
} | |
} | |
} | |
@mixin fill($width: 100%) { | |
@include box-sizing(border-box); | |
width: $width; | |
} | |
@mixin font-smoothing($value: on) { | |
@if $value == on { | |
-webkit-font-smoothing: antialiased; | |
-moz-osx-font-smoothing: grayscale; | |
} | |
@else { | |
-webkit-font-smoothing: subpixel-antialiased; | |
-moz-osx-font-smoothing: auto; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment