Mixins

Shortcuts to save you time and make your code more readable

absolute

@mixin absolute($top: false, $right: false, $bottom: false, $left: false)
@include absolute();
position: absolute;
@include absolute(4rem, 3rem, 2rem, 1rem);
position: absolute;
top: 4rem;
right: 3rem;
bottom: 2rem;
left: 1rem;
@include absolute(4rem, 3rem);
position: absolute;
top: 4rem;
left: 3rem;

block

@mixin block($width, $height)
@include block();
display: block;
@include block(40rem, 100px);
display: block;
width: 40rem;
height: 100px;

bookends

@mixin bookends($value: '-', $margin: .5em, $font: false, $color: false)
@include bookends('-', .5em)
&:before {
    content: '-';
    margin-right: .5em;
}
&:after {
    content: '-';
    margin-left: .5em;
}
@include bookends('~', 1, $color: red);
&:before {
    content: '~';
    margin-right: 1rem;
    color: red;
}
&:after {
    content: '~';
    margin-left: 1rem;
    color: red;
}

centeredBlock

@mixin centeredBlock($maxWidth: false, $margin: false)
@include centeredBlock();
display: block;
margin-left: auto;
margin-right: auto;
@include centeredBlock(80rem, 2rem);
display: block;
margin-left: auto;
margin-right: auto;
width: 80rem;
margin-bottom: 2rem;

circle

@mixin circle($diameter, $crop: false, $display: block)
@include circle(.5);
background-clip: border-box;
border-radius: 0.25rem;
height: 0.5rem;
width: 0.5rem;
display: block;
@include circle(.5, true);
background-clip: border-box;
border-radius: 0.25rem;
height: 0.5rem;
width: 0.5rem;
overflow: hidden;
display: block;
@include circle(.5, $display: inline);
background-clip: border-box;
border-radius: 0.25rem;
height: 0.5rem;
width: 0.5rem;
display: inline-block;

clearfix

@include clearfix();
&:after {
    clear: both;
    content: '';
    display: block;
}

column

@mixin column($keyword: false, $share: false, $columns: $gridColumns, $margin: $gridMargin)
@include column();
float: left;
width: 100%;
@include column(40%);
float: left;
width: 40%;
@include column(spaced, 1, 4, 2%);
float: left;
margin-left: 2%;
width: 23%;
@include column(1, 2);
float: left;
width: 50%;

columnModify

@mixin columnModify($keyword: false, $share: false, $columns: $gridColumns, $margin: $gridMargin)
@include columnModify(60%);
width: 60%;
@include columnModify(spaced, 1, 4, 5%);
margin-left: 5%;
width: -20%;
@include columnModify(1, 5);
width: 20%;

columnOffset

@mixin columnOffset($keyword: false, $share: false, $columns: $gridColumns, $margin: ($gridMargin / 2))
@include columnOffset(spaced, 3, 4, 5%);
margin-left: 85%;
@include columnOffset(2, 5);
margin-left: 40%;

columnPull

@mixin columnPull($share, $columns: $gridColumns)
@include columnPull(1, 2);
position: relative;
right: 50%;

columnPush

@mixin columnPush($share, $columns: $gridColumns)
@include columnPush(1, 2);
left: 50%;
position: relative;

columnReset

@mixin columnReset($resetMargin: false)
@include columnReset();
float: none;
width: auto;
@include columnReset(true);
float: none;
width: auto;
margin-left: 0;

ellipsis

@mixin ellipsis(maxWidth = false)
@include ellipsis();
overflow-x: hidden;
text-overflow: ellipsis;
white-space: nowrap;
@include ellipsis(10);
overflow-x: hidden;
text-overflow: ellipsis;
white-space: nowrap;
max-width: 10rem;

fixed

@mixin fixed($top: false, $right: false, $bottom: false, $left: false);
@include fixed();
position: fixed;
@include fixed($bottom: 3rem, $top: 4rem);
position: fixed;
top: 4rem;
bottom: 3rem;

flex

@mixin flex($grow: 0, $shrink: 0, $basis: auto)
@include flex();
flex-grow: 0;
flex-shrink: 0;
flex-basis: auto;
@include flex(1, 2);
flex-grow: 1;
flex-shrink: 2;
flex-basis: auto;

flexContainer

@mixin flexContainer($direction: row, $wrap: nowrap, $justify: flex-start, $align: stretch, $alignContent: stretch)
@include flexContainer();
display: flex;
flex-direction: row;
flex-wrap: nowrap;
justify-content: flex-start;
align-items: stretch;
align-content: stretch;
@include flexContainer(column, wrap, $alignContent: start);
display: flex;
flex-direction: column;
flex-wrap: wrap;
justify-content: flex-start;
align-items: stretch;
align-content: start;

font

@mixin font($family: $baseFont, $size, $weight, $lineHeight, $style, $spacing)
@include font('Times New Roman', 1.4, bold, 1.5, italic, 0.1);
font-family: 'Times New Roman';
font-size: 1.4rem;
font-weight: bold;
line-height: 1.5em;
letter-spacing: 0.1rem;

heading

@mixin heading($fontSize: false)
@include heading();
color: inherit;
font-family: 'Tahoma, Geneva, sans-serif';
font-weight: bold;
line-height: 1.4em;
margin-bottom: 2rem;
small {
    font-weight: normal;
}

hideText

@include hideText();
overflow: hidden;
text-indent: 110%;
white-space: nowrap;

icon

Output font icon

@mixin icon(icon, size = 'inherit', rotate = false, weight = 'normal', height = 0, sharpen = true, font = vars.icon.family)
.block {
    &::after {
        @include icon(\e901);
    }
}
.block::after {
    content: '\e901';
    font-family: 'Open Sans' sans-serif;
    font-size: inherit;
    font-weight: normal;
    line-height: 0;
    font-style: normal;
    display: inline-block;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

iconModify

Modify font icon

@mixin iconModify(icon = false, size = false, rotate = false, weight = false, sharpen = false)
.block {
    &::after {
        @include iconModify(\e901);
    }
}
.block::after {
    content: '\e901';
}

inlineBlock

@mixin inlineBlock(width, height)
@include inlineBlock();
display: inline-block;
@include inlineBlock(40rem, 30rem);
display: inline-block;
width: 40rem;
height: 30rem;
@include inlineBlock($height: 100px);
display: inline-block;
height: 100px;

inlineColumn

@mixin inlineColumn(keyword, share, columns = vars.grid.columns, margin = vars.grid.margin, spaceless = vars.grid.spaceless)
@include inlineColumn(spaced, 1, 4, 4%);
display: inline-block;
vertical-align: top;
margin-left: 4%;
width: 21%;
letter-spacing: normal;
@include inlineColumn(1, 5);
display: inline-block;
vertical-align: top;
width: 20%;

inlineRow

@mixin inlineRow(margin = vars.grid.margin, spaceless = vars.grid.spaceless)
@include inlineRow(4%, false);
margin-left: -4%;
max-width: 104%;
letter-spacing: -.32em;
@include inlineRow(4%, true);
margin-left: -4%;
max-width: 104%;

loadFont

@mixin loadFont(name, $file: $name, $weight: normal, $style: normal)
@include loadFont(icomoon, $weight: 500);
@font-face {
    font-family: icomoon;
    font-weight: 500;
    font-style: normal;
    src: url('../fonts/icomoon.woff2'),
        url('../fonts/icomoon.woff'),
        url('../fonts/icomoon.ttf');
}

noClear

@mixin noClear();
&::-ms-clear {
    display: none
}
&::-webkit-search-cancel-button {
    -webkit-appearance: none
}

placeholder

@mixin placeholder($color: $inputPlaceholderColor)
@include placeholder();
&:-moz-placeholder {
    color: #bfbfbf
}
&::-moz-placeholder {
    color: #bfbfbf
}
&:-ms-input-placeholder {
    color: #bfbfbf
}
&::-webkit-input-placeholder {
    color: #bfbfbf
}
@include placeholder(#fff);
&:-moz-placeholder {
    color: #fff
}
&::-moz-placeholder {
    color: #fff
}
&:-ms-input-placeholder {
    color: #fff
}
&::-webkit-input-placeholder {
    color: #fff
}

prefix

@mixin prefix($value: '-', $margin: .5em, $font: false, $color: false)
@include prefix();
&:before {
    content: '-';
    margin-right: .5em;
}
prefix('~', 1rem, $color: blue);
&:before {
    content: '~';
    margin-right: 1rem;
    color: blue;
}

ratio

@mixin ratio($keyword: false, $ratio: 16 / 9)
@include ratio(embed, 4/3);
display: block;
height: 0;
padding-top: 75%;
@include ratio(embed, 4/3);
overflow: hidden;
position: relative;
&:before {
    content: '';
    display: block;
    height: 0;
    padding-top: 75%
}

resizable

@mixin resizable($value: both)
@include resizable();
overflow: hidden;
resize: both;
@include resizable(vertical);
overflow: hidden;
resize: vertical;

rounded

@mixin rounded($keyword: '', $value: $defaultRadius)
@include rounded(5px);
border-radius: 5px;
@include rounded(top, 4px);
border-top-left-radius: 4px;
border-top-right-radius: 4px;
@include rounded(left, 2px);
border-top-left-radius: 2px;
border-bottom-left-radius: 2px;

row

@mixin row($margin: $gridMargin)
@include row();
margin-left: -5%;
max-width: 105%;
&:after {
    clear: both;
    content: '';
    display: block;
}
@include row(10%);
margin-left: -10%;
max-width: 110%;
&:after {
    clear: both;
    content: '';
    display: block;
}

rowModify

@mixin rowModify($margin: $gridMargin)
@include rowModify(4%);
margin-left: -4%;
max-width: 104%;

rowReset

@include rowReset();
margin-left: 0;
max-width: none;

selection

@mixin selection($color: $selectionColor, $background: $selectionBackground)
@include selection();
&::selection {
    background: #349bb9;
    color: #fff;
    text-shadow: none
}
@include selection(#000, #fff);
&::selection {
    background: #fff;
    color: #000;
    text-shadow: none
}

size

@mixin size($width, $height: false)
@include size(4rem);
width: 4rem;
height: 4rem;
@include size(4rem, 250px);
width: 4rem;
height: 250px;

spacedBlock

@mixin spacedBlock($margin: $blockMarginBottom, $width: false, $height: false)
@include spacedBlock($margin-bottom: 4);
display: block;
margin-bottom: 4rem;
@includes spacedBlock(4rem, 20rem, 100px);
display: block;
margin-bottom: 4rem;
width: 20rem;
height: 100px

suffix

@mixin suffix($value: '-', $margin: .5em, $font: false, $color: false)
@include suffix();
&:before {
    content: '-';
    margin-left: .5em;
}
@include suffix('~', 1em, $color: blue);
&:before {
    content: '~';
    margin-left: em;
    color: blue;
}

textSharpen

@mixin textSharpen()
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;

triangle

@mixin triangle($keyword, $color: $darkGray, $size: 5px, $width: $size)
@include triangle(up);
content: '';
height: 0;
width: 0;
border-left: 5px solid transparent;
border-right: 5px solid transparent;
border-bottom: 5px solid #737373;
@include triangle(right, $color: blue, $size: 3px);
content: '';
height: 0;
width: 0;
border-top: 3px solid transparent;
border-bottom: 3px solid transparent;
border-left: 3px solid blue;
@include triangle(left, red, $width: 10px);
content: '';
height: 0;
width: 0;
border-top: 10px solid transparent;
border-bottom: 10px solid transparent;
border-right: 5px solid red;