6 - Sass variables
Source: variables/__documentation.scss, line 1
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
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
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
Breakpoints are in the map $breakpoints
xs
: 320px, // Smartphonesm
: 600px, // Tabletsmd
: 900px, // Tablets Landscape and small desktopslg
: 1200px, // Desktopsxl
: 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 = truebp-var(sm);
=>576px;
If $use-css-var = falsebp-var(sm, true)
=>576px;
6.4 - Colors
Source: variables/_colors.scss, line 169
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 = truecolor(danger)
=>#c65556
If $use-css-var = falsecolor(success, base, true)
=>#c65556
color(success, light)
=>var(--color-success-light)
If $use-css-var = truecolor(success, light)
=>#76bd7a
If $use-css-var = falsecolor(success, light, true)
=>#76bd7a
6.4.1 - Grays
Source: variables/_colors.scss, line 196
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 = truecolor-gray(100)
=>#000000
If $use-css-var = falsecolor-gray(60)
=>#666666
If $use-css-var = false
6.5 - Container Sizes
Source: variables/_container-sizes.scss, line 42
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 = truecontainer(md);
=>720px;
If $use-css-var = falsecontainer(md, true)
=>720px;
6.6 - Font Families
Source: variables/_font-families.scss, line 48
Font Families are in the map $font-families
paragraph
: Lato,title
: Rubik,highlight
: Rubikicon
: 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 = truefont-family(title)
=>"Rubik", "Helvetica Neue", Arial, sans-serif
If $use-css-var = falsefont-family(title, true)
=>"Rubik", "Helvetica Neue", Arial, sans-serif
6.7 - Font Sizes
Source: variables/_font-sizes.scss, line 45
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 = truefont-size(2)
=>2.5rem
If $use-css-var = falsefont-size(2, true)
=>2.5rem
6.8 - Grid
Source: variables/_grid.scss, line 10
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
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 = trueicon(twitter)
=>"\f099"
If $use-css-var = falseicon(twitter, true)
=> `"\f099"
6.9.1 - Icons list
Source: vendors/icomoon/_variables.scss, line 100
(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
6.10 - Spacers
Source: variables/_spacers.scss, line 49
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 = truespacer(4)
=>1.25rem
If $use-css-var = falsespacer(4, true)
=>1.25rem
6.11 - Theme classes
Source: variables/_root-classes.scss, line 16
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
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.