Atomic Bulldog - UI/pattern library

6 - Sass variables

Source: variables/__documentation.scss, line 1

Open in new window

The most straightforward way to use SassScript is to use variables. Variables begin with dollar signs, and are set like CSS properties

http://sass-lang.com/documentation/file.SASS_REFERENCE.html#variables_

Maps represent an association between keys and values, where keys are used to look up values. They make it easy to collect values into named groups and access those groups dynamically. They have no direct parallel in CSS, although they're syntactically similar to media query expressions:

http://sass-lang.com/documentation/file.SASS_REFERENCE.html#maps

Sass variables helps to define patterns in the project. They are the core of this project. Most of this variables are define in maps and can be call using a function link to this map.

6.1 - Aspect ratios

Source: variables/_aspect-ratios.scss, line 32

Open in new window

Aspect ratios are sets in the map $aspect-ratios. They are use to define ratios for .aspect-ratio-container (Atom)


  • 1x1
  • 16x9
  • 4x3
  • golden
  • silver

6.2 - Box shadow

Source: variables/_box-shadow.scss, line 10

Open in new window

Standard box shadow use around the website

$box-shadow: 1px 5px 10px rgba(0,0,0,.1);

Example:

<div class="has-p-3 has-bg-grey-0 has-box-shadow"></div>

6.3 - Breakpoints

Source: variables/_breakpoints.scss, line 48

Open in new window

Breakpoints are in the map $breakpoints


  • xs: 320px, // Smartphone
  • sm: 600px, // Tablets
  • md: 900px, // Tablets Landscape and small desktops
  • lg: 1200px, // Desktops
  • xl: 1800px, // Large Desktop

Breakpoints can be called in the sass project using the functions:

bp($bp) which will output a value in em

bp-var($bp, $true-val:false) which will output the CSS variable

Usage of bp():

  • bp(sm); => 36em

Usage of bp-var():

  • bp-var(sm); => var(--bp-sm); If $use-css-var = true
  • bp-var(sm); => 576px; If $use-css-var = false
  • bp-var(sm, true) => 576px;

6.4 - Colors

Source: variables/_colors.scss, line 169

Open in new window

Colors are in the map $color-themes. Each color themes have 5 variables:

  • Base
  • Dark
  • Light
  • Transparent
  • Contrast

Colors can be called in the sass project using the functions:

color($color-name, $color-variant:null, $true-val:false) which will output by default the CSS variable

Usage of font-family():

  • color(danger) => var(--color-danger-base) If $use-css-var = true
  • color(danger) => #c65556 If $use-css-var = false
  • color(success, base, true) => #c65556
  • color(success, light) => var(--color-success-light) If $use-css-var = true
  • color(success, light) => #76bd7a If $use-css-var = false
  • color(success, light, true) => #76bd7a

6.4.1 - Grays

Source: variables/_colors.scss, line 196

Open in new window

Grays are in the map $gray-themes. This maps darken white (#ffffff) to black 10% by 10%

Grays can be called in the sass project using the functions:

color-gray($gray-theme, $true-val:false) which will output by default the CSS variable

Usage of font-family():

  • color-gray(0) => var(--color-gray-0) If $use-css-var = true
  • color-gray(100) => #000000 If $use-css-var = false
  • color-gray(60) => #666666 If $use-css-var = false
0
10
20
30
40
50
60
70
80
90
100

6.4.2 - Color Swatches

Source: variables/_colors.scss, line 228

Open in new window

6.5 - Container Sizes

Source: variables/_container-sizes.scss, line 42

Open in new window

Container sizes are in the map $container-sizes


  • sm
  • md
  • lg
  • xl

Container Sizes can be called in the sass project using the function:

container($container-size, $true-val:false).

Function examples to call the map:

  • container(md); => var(--container-size-sm); If $use-css-var = true
  • container(md); => 720px; If $use-css-var = false
  • container(md, true) => 720px;

6.6 - Font Families

Source: variables/_font-families.scss, line 48

Open in new window

Font Families are in the map $font-families


  • paragraph: Lato,
  • title: Rubik,
  • highlight: Rubik
  • icon: icomoon

Font Families can be called in the sass project using the functions:

font-family($font-family, $true-val:false) which will output by default the CSS variable

Usage of font-family():

  • font-family(title) => var(--font-family-title) If $use-css-var = true
  • font-family(title) => "Rubik", "Helvetica Neue", Arial, sans-serif If $use-css-var = false
  • font-family(title, true) => "Rubik", "Helvetica Neue", Arial, sans-serif

6.7 - Font Sizes

Source: variables/_font-sizes.scss, line 45

Open in new window

Font Sizes are in the map $font-sizes


  • root: 16px,
  • paragraph: 1rem,
  • 1: 2.8125rem,
  • 2: 2.5rem,
  • 3: 2rem,
  • 4: 1.5rem,
  • 5: 1.25rem,
  • 6: 1rem,
  • button: 1rem

Font sizes can be called in the sass project using the functions:

font-sizes($font-size, $true-val:false) which will output by default the CSS variable

Usage of font-size():

  • font-size(2) => var(--font-size-2) If $use-css-var = true
  • font-size(2) => 2.5rem If $use-css-var = false
  • font-size(2, true) => 2.5rem

6.8 - Grid

Source: variables/_grid.scss, line 10

Open in new window

This project use by default CSS grid layout display: grid for its grid with a fallback on flexbox for older browsers. $grid-columns allow setting the number of columns we want per grid.

6.9 - Icons

Source: vendors/icomoon/_variables.scss, line 66

Open in new window

Icon font are generated using https://icomoon.io/ (See vendors)

Icomoon give sass files but these ones use variables. For better maintainability and theming the vendor have been changed so it uses a map instead of variables.

Variables can be converted to a map using this tool:

See the Pen Convert Sass variables to map by Vincent Humeau (@vinceumo) on CodePen.

Icons can be called in the sass project using the functions:

icon($icon, $true-val:false) which will output by default the CSS variable, You will need to set the font family as font-family: font-family(icon)

Usage of icon():

  • icon(twitter) => var(--icon-twitter) If $use-css-var = true
  • icon(twitter) => "\f099" If $use-css-var = false
  • icon(twitter, true) => `"\f099"

6.9.1 - Icons list

Source: vendors/icomoon/_variables.scss, line 100

Open in new window

(Markup copy and paste from icomoon example)

Icons can be call in the markup using a class .icon-{target}, such as <i class="icon-star"></i> . It can be call using span or div as well.

When using an icon in css you can use the function icon(target), such as icon(star).

Grid Size: 14

icon-star
liga:
icon-star-o
liga:
icon-user
liga:
icon-check
liga:
icon-close
liga:
icon-remove
liga:
icon-times
liga:
icon-search-plus
liga:
icon-search-minus
liga:
icon-trash-o
liga:
icon-home
liga:
icon-download
liga:
icon-inbox
liga:
icon-bookmark
liga:
icon-print
liga:
icon-chevron-left
liga:
icon-chevron-right
liga:
icon-chevron-up
liga:
icon-chevron-down
liga:
icon-twitter
liga:
icon-facebook
liga:
icon-facebook-f
liga:
icon-github
liga:
icon-chain
liga:
icon-link
liga:
icon-envelope
liga:
icon-linkedin
liga:
icon-rotate-left
liga:
icon-undo
liga:
icon-angle-left
liga:
icon-angle-right
liga:
icon-angle-up
liga:
icon-angle-down
liga:

6.10 - Spacers

Source: variables/_spacers.scss, line 49

Open in new window

Spacers is use to for padding and margin grid-gap in the project. The base value is set with $spacer-reference (1rem)


  • 0: 0,
  • 1: ($spacer-reference * 0.25),
  • 2: ($spacer-reference * 0.5),
  • 3: $spacer-reference,
  • 4: ($spacer-reference * 1.25),
  • 5: ($spacer-reference * 1.5),
  • 6: ($spacer-reference * 3),
  • 7: ($spacer-reference * 6),
  • 8: ($spacer-reference * 9),
  • 9: ($spacer-reference * 12)

spacer sizes can be called in the sass project using the functions:

spacer($spacer, $true-val:false) which will output by default the CSS variable

Usage of grid-item-size():

  • spacer(4) => var(--spacer-4) If $use-css-var = true
  • spacer(4) => 1.25rem If $use-css-var = false
  • spacer(4, true) => 1.25rem

6.11 - Theme classes

Source: variables/_root-classes.scss, line 16

Open in new window

CSS Variables and theme classes are set in the variable files using this Sass variables:

  • $root-default => :root, .theme-default, .is-theme-default
  • $root-invert-theme => :root .theme-invert, :root .is-theme-invert

6.12 - z-index

Source: variables/_z-index.scss, line 27

Open in new window

z-index are in the map $z-indexes. The first entry will get the highest value and the last one the lowest. You can find an example in this pen


  • skip-navigation
  • main-navigation

z-index indexes can be called in the sass project using the functions:

z($name) which will output the reverse index of $name time 10

Usage of font-size():

  • z(main-navigation) => 10

See the Pen z-index Sass management by Vincent Humeau (@vinceumo) on CodePen.