code

mixins

code-base

@mixin code-base($font-family: sourcecodepro-medium-webfont, $bgcolor: #666, $color: white, $padding: 20px, $whitespace: pre) { ... }

Description

Provides the basis for other code-related mixins. All The attributes are parameterized to make them easier to chage.

Parameters

parameterNameparameterDescriptionparameterTypeparameterDefault value
$font-family

font family to use as primary.

Stringsourcecodepro-medium-webfont
$bgcolor

background color

String#666
$color

text-color

Stringwhite
$padding

padding amount

String20px
$whitespace

how to handle white space

Stringpre

Example

div .code-example {
  @include code-block();
}

Used by

Author

code-block

@mixin code-block($font-family: sourcecodepro-medium-webfont, $bgcolor: #666, $color: white, $padding: 20px, $whitespace: pre) { ... }

Description

Using the code-base mixin it adds display-block to create Github style fenced code blocks

Parameters

parameterNameparameterDescriptionparameterTypeparameterDefault value
$font-family

font family to use as primary.

Stringsourcecodepro-medium-webfont
$bgcolor

background color

String#666
$color

text-color

Stringwhite
$padding

padding amount

String20px
$whitespace

how to handle white space

Stringpre

Example

code {
  @include code-inline();
}

Requires

Author

code-inline

@mixin code-inline($font-family: sourcecodepro-medium-webfont, $bgcolor: #666, $color: white, $padding: 20px, $whitespace: pre) { ... }

Description

Uses code-base to generate inline code snippets, like GFM's backtick inline code

Parameters

parameterNameparameterDescriptionparameterTypeparameterDefault value
$font-family

font family to use as primary.

Stringsourcecodepro-medium-webfont
$bgcolor

background color

String#666
$color

text-color

Stringwhite
$padding

padding amount

String20px
$whitespace

how to handle white space

Stringpre

Example

code {
  @include code-inline();
}

Requires

Author

code-editable

@mixin code-editable($font-family: sourcecodepro-medium-webfont, $bgcolor: #666, $color: white, $padding: 20px, $whitespace: pre) { ... }

Description

TO be used when create contentEditable regions. It'll change the background color add clear:both and a small margin to the bottom of the element.

Parameters

parameterNameparameterDescriptionparameterTypeparameterDefault value
$font-family

font family to use as primary.

Stringsourcecodepro-medium-webfont
$bgcolor

background color

String#666
$color

text-color

Stringwhite
$padding

padding amount

String20px
$whitespace

how to handle white space

Stringpre

Example

style {
 @include code-editable();
}

Requires

Author

columns

mixins

column-attribs

@mixin column-attribs($cols: 2, $gap: 20px, $fill: balance, $span: none, $moz: true, $webkit: true) { ... }

Description

This mixin will create column attributes for the element it's called in

It uses default attributes to make life easier.

We use number of columns rather than width for convenience. Counting width means we have to do percentages or be very strict in the width of our content.

We could simplify the mixin by just using the unprefixed version and let tools like prefixfree or autoprefixer add prefixes where needed but this mixin was designed to work without needing additional tools or script to work...

It can also conditionally remove Mozilla or Webkit prefixed attributes by passing $moz or webkit as false in the mixin include instruction

if you want to change it then go ahead.

Parameters

parameterNameparameterDescriptionparameterTypeparameterDefault value
$cols

How many columns.

String2
$gap

Gap between columns

String20px
$fill

How to fill column space

Stringbalance
$span

Do we span accross columns

Stringnone
$moz

Do we include -moz prefixed declarations

Stringtrue
$webkit

Do we include -webkit prefixed declarations

Stringtrue

Example

.col2 {
  width: 100%;
  @include column-attribs (2, 20px, $moz: false, $webkit:false);
}
.col3 {
  width: 100%;
  @include column-attribs (3, 10px);
}

Links

Author

images

mixins

image-2x

@mixin image-2x($image, $width, $height) { ... }

Description

This mixin automates the use of 2x retina images for devices that can handle them

Parameters

parameterNameparameterDescriptionparameterTypeparameterDefault value
$image

What image to use

Stringnone
$width

Image width

Stringnone
$height

Image height

Stringnone

Example

Usage

div.logo {
  background: url("logo.png") no-repeat;
  @include image-2x("logo2x.png", 100px, 25px);
 }

Result

div.logo {
  background: url("logo.png") no-repeat;
}
@media
  (min--moz-device-pixel-ratio: 1.3),
  (-o-min-device-pixel-ratio: 2.6 / 2),
  (-webkit-min-device-pixel-ratio: 1.3),
  (min-device-pixel-ratio: 1.3),
  (min-resolution: 1.3dppx) {
    div.logo {
      /* on retina, use image that's scaled by 2 */
      background-image: url("logo2x.png");
      background-size: 100px 25px;
    }
  }

Links

Author

maps

variables

breakpoints

$breakpoints: (
  small : 480px,
  medium: 700px,
  large : 1024px
);

Description

Defines the break points

Author

p-font-sizes

$p-font-sizes: (
  null  : (15px, 1.3),
  small : 16px,
  medium: (17px, 1.4),
  900px : 18px,
  large : (19px, 1.45),
  1440px: 20px,
);

Description

Defines the different sizes for p elements

Author

sm-profiles

$sm-profiles: (
  facebook: #3b5998,
  flickr: #0063db,
  github: #4183c4,
  googleplus: #dd4b39,
  linkedin: #007bb6,
  twitter: #00aced,
  vimeo: #aad450,
  youtube: #b00
);

Description

Defines the social media profiles and associated colors

Author

mixins

font-size

@mixin font-size($fs-map, $fs-breakpoints: $breakpoints) { ... }

Description

Creates the mediaqueries for the combination of $breakpoints and p-font-sizes. It also takes into account if we have line height attributes for a given breakpoint and adds any value present in p-font-sizes but not in ~breakpoints by using the key from p-font-sizes as the value for the media query.

Parameters

parameterNameparameterDescriptionparameterTypeparameterDefault value
$fs-map

map of sizes and breakpoints

Stringnone
$fs-breakpoints

pre defined breakpoints

String$breakpoints

Example

Defining the font sizes for p elements

p {
   @include font-size($p-font-sizes);
}

Result from example above

 p {
   font-size: 15px;
   line-height: 1.3;
 }

 @media screen and (min-width: 480px) {
   p {
     font-size: 16px; }
 }

 @media screen and (min-width: 700px) {
   p {
     font-size: 17px;
     line-height: 1.4; }
 }

@media screen and (min-width: 900px) {
  p {
    font-size: 18px; }
}

@media screen and (min-width: 1024px) {
  p {
    font-size: 19px;
    line-height: 1.45; }
}

@media screen and (min-width: 1440px) {
  p {
    font-size: 20px; }
}

Requires

Author

make-font-size

@mixin make-font-size($fs-font-size) { ... }

Description

Mixin that actually creates the media queries

Parameters

parameterNameparameterDescriptionparameterTypeparameterDefault value
$fs-font-size

pre defined font-sizes

Stringnone

Used by

Author

media queries

mixins

hdpi

@mixin hdpi($ratio: 1.3) { ... }

Description

Generic HDPI query to handle devices. We could treat this as an extension of the generic-mq but I like to be explicit and there special prefixes to deal with when working with hdpi screens

Parameters

parameterNameparameterDescriptionparameterTypeparameterDefault value
$ratio

hdpi value.

String1.3

Content

This mixin allows extra content to be passed (through the @content directive).

Author

iphone3

@mixin iphone3($orientation: all, $deviceMinWidth: 320px, $deviceMaxWidth: 480px, $devicePixelRatio: 1) { ... }

Description

Media query to handle iPhone 3 and other non-retina devices

Parameters

parameterNameparameterDescriptionparameterTypeparameterDefault value
$orientation

is the device in portrait or landscape mode or do we use this query for both?

Stringall
$deviceMinWidth

minimum device size

String320px
$deviceMaxWidth

maximum device size

String480px
$devicePixelRatio

pixels by physical pixel

String1

Content

This mixin allows extra content to be passed (through the @content directive).

Author

generic-mq

@mixin generic-mq($orientation: all, $deviceMinWidth: 320px, $deviceMaxWidth: 480px, $devicePixelRatio: 1) { ... }

Description

Generic media query to handle devices

Parameters

parameterNameparameterDescriptionparameterTypeparameterDefault value
$orientation

device orientation.

Stringall
$deviceMinWidth

no smaller than

String320px
$deviceMaxWidth

no bigger than

String480px
$devicePixelRatio

pixel density (retina or not)

String1

Content

This mixin allows extra content to be passed (through the @content directive).

Author

programming utilities

functions

missing-dependencies

@function missing-dependencies($dependencies) { ... }

Description

This function checks if the parameters (function names) are available in the given context

Parameters

parameterNameparameterDescriptionparameterTypeparameterDefault value
$dependencies

Name of the functions to test

Stringnone

Example

Usage

@function dummy() {
  @if missing-dependencies(my-function, my-other-function) {
      @warn "Oops! Missing some functions for `dummy`!";
      @return null;
  }

  // `dummy` function's core,
  // obviously needing `my-function` and `my-other-function` to work.
}

Links

Author

typography

functions

conditional_font_load

@function conditional_font_load() { ... }

Description

Generates Google Font links only if a given variable is available

Parameters

None.

Example

styles

body {
  font-family: $stack-lato;
}

h1 {
  font-family: $stack-pt-serif;
}

Author

calculateRem

@function calculateRem($size) { ... }

Description

Auxiliary function that does the actual conversion from pixel to rem

Parameters

parameterNameparameterDescriptionparameterTypeparameterDefault value
$size

Font size

Integernone

Used by

Author

calculateEm

@function calculateEm($size, $context: 16) { ... }

Description

Auxiliary function that does the actual conversion from pixel to rem

Parameters

parameterNameparameterDescriptionparameterTypeparameterDefault value
$size

Font size

Integernone
$context

Base value for calculation

Integer16

Used by

Author

get-vw

@function get-vw($target) { ... }

Parameters

parameterNameparameterDescriptionparameterTypeparameterDefault value
$target

Target size for conversion

Stringnone

Example

.headline {
  font-size: 4.5em; // Fallback
  @include vw(72px);
}

Links

Author

font-size

@function font-size($size) { ... }

Parameters

parameterNameparameterDescriptionparameterTypeparameterDefault value
$size

Target size for conversion

Stringnone

Links

Author

mixins

font-ligature

@mixin font-ligature() { ... }

Description

Handles font ligatures for different browsers. Since different browsers have adopted different ways to handle the attribute we have to make it a mixin.

Parameters

None.

Author

font-kerning

@mixin font-kerning() { ... }

Description

We also need to handle font kerning different for different browsers.

Parameters

None.

Author

font-declaration

@mixin font-declaration($font-family, $font-file-name, $weight: normal, $style: normal) { ... }

Description

Generates the necessary font-face declarations to handle most, if not all modern browsers. The only browsers not supported by the mixin are those that require eot lite

Parameters

parameterNameparameterDescriptionparameterTypeparameterDefault value
$font-family

Font-family name to use.

Stringnone
$font-file-name

File name for the font we are loading

Stringnone
$weight

Bold or normal

Stringnormal
$style

Italic or normal

Stringnormal

Example

Using font-declaration mixin to load fonts

@include font-declaration('Roboto Slab', '../fonts/robotoslab-regular-webfont');
@include font-declaration('sourcecodepro-medium-webfont', '../fonts/sourcecodepro-medium-webfont');

Result from example above

@font-face {
  font-family: 'Roboto Slab';
    src: url('../fonts/robotoslab-regular-webfont.eot');
    src: url('../fonts/robotoslab-regular-webfont.eot?#iefix') format('embedded-opentype'),
    url('../fonts/robotoslab-regular-webfont.woff2') format('woff2'),
    url('../fonts/robotoslab-regular-webfont.woff') format('woff'),
    url('../fonts/robotoslab-regular-webfont.ttf') format('truetype'),
    url('../fonts/robotoslab-regular-webfont.svg#Roboto Slab') format('svg');
  font-weight: normal;
  font-style: normal;
}

@font-face {
  font-family: 'sourcecodepro-medium-webfont';
    src: url('../fonts/sourcecodepro-medium-webfont.eot');
    src: url('../fonts/sourcecodepro-medium-webfont.eot?#iefix') format('embedded-opentype'),
    url('../fonts/sourcecodepro-medium-webfont.woff2') format('woff2'),
    url('../fonts/sourcecodepro-medium-webfont.woff') format('woff'),
    url('../fonts/sourcecodepro-medium-webfont.ttf') format('truetype'),
    url('../fonts/sourcecodepro-medium-webfont.svg#sourcecodepro-medium-webfont') format('svg');
  font-weight: normal;
  font-style: normal;
}

Author

ebook-font-declaration

@mixin ebook-font-declaration($font-family, $font-file-name, $weight: normal, $padding: style) { ... }

Parameters

parameterNameparameterDescriptionparameterTypeparameterDefault value
$font-family

Font-family name to use.

Stringnone
$font-file-name

File name for the font we are loading

Stringnone
$weight

Bold or normal

Stringnormal
$padding

Italic or normal

Stringstyle

Author

fontSizeRem

@mixin fontSizeRem($size: 16px) { ... }

Description

Sets font size in rem with px fallback

Parameters

parameterNameparameterDescriptionparameterTypeparameterDefault value
$size

Font size in pixels

String16px

Example

Usage

body {
  @include fontSize(16px);
}

Result

body {
  font-size: 16px;
  font-size: 1rem;
}

Requires

See

Links

Author

fontSizeEm

@mixin fontSizeEm($size: 16) { ... }

Description

Sets font size in em with px fallback

Parameters

parameterNameparameterDescriptionparameterTypeparameterDefault value
$size

Font size in pixels

Integer16

Example

Usage

body {
  @include fontSizeEm(48);
}

Result

body {
  font-size: 48px;
  font-size: 3em;
}

Requires

See

Links

Author

utilities

mixins

phone-rendering

@mixin phone-rendering() { ... }

Description

Eliminates ligatures and kearnings in devices with width of less than 480 pixels and smaller form factors

Parameters

None.

Author

solid-thin

@mixin solid-thin() { ... }

Description

Creates a 1 pixel solid border

Parameters

None.

Author

cf

@mixin cf() { ... }

Description

Basic clearfix. Might change to a placeholder to be extended rather than a mixin to be included

Parameters

None.

Example

Usage

.article {
  font-size: 1em;
  @include cf();
}

Result

.article {
  font-size: 1em; }
.article:after {
  content: " ";
  display: block;
  clear: both;
}

Links

Author

border-radius

@mixin border-radius($radius: 5px) { ... }

Description

Border radius mixin to keep your code DRY

Parameters

parameterNameparameterDescriptionparameterTypeparameterDefault value
$radius

how much radius

String5px

Links

Author

size

@mixin size($width: null, $height: $width) { ... }

Description

Clever way to provide width and height for an element

Parameters

parameterNameparameterDescriptionparameterTypeparameterDefault value
$width

How wide

null
$height

How hight. Defaults to the width

$width

Links

Author

box-sizing

@mixin box-sizing() { ... }

Description

This mixin automates the use of 2x retina images for devices that can handle them.

We could also do this as an unprefixed version and just use Autoprefixer, I leave that up to you

Parameters

None.

Example

Usage

div.logo {
  background: url("logo.png") no-repeat;
  @include image-2x("logo2x.png", 100px, 25px);
 }

Result

div.logo {
  background: url("logo.png") no-repeat;
}
@media
  (min--moz-device-pixel-ratio: 1.3),
  (-o-min-device-pixel-ratio: 2.6 / 2),
  (-webkit-min-device-pixel-ratio: 1.3),
  (min-device-pixel-ratio: 1.3),
  (min-resolution: 1.3dppx) {
    div.logo {
      /* on retina, use image that's scaled by 2 */
      background-image: url("logo2x.png");
      background-size: 100px 25px;
    }
  }

Links

Author

placeholders

center-block

%center-block { ... }

Description

Centers a block element

Links

Author

vfx

mixins

blendy

@mixin blendy($img, $color: null, $grad: null, $blend: multiply) { ... }

Description

Provides a basic css blend between an image and the background color

Parameters

parameterNameparameterDescriptionparameterTypeparameterDefault value
$img

image to blend.

Stringnone
$color

color to blend with

Stringnull
$grad

gradient to use

Stringnull
$blend

what blending mode to use

Stringmultiply

Example

  .blend {
 @include blendy("http://sassbreak.com/assets/mountains.jpg", $grad: $cool-grad);
 width: 200px;
 height: 200px;
 border-radius: 50%;
 background-size: cover;
 margin: 1.5em auto;
}

Links

Author