configuration

variables

SCARAB

$SCARAB: ();
View source

Description

The $SCARAB configuration map where all Scarab configuration is stored.

Never modify this variable directly. Instead, use the set() mixin to set or update a value in $SCARAB.

To retrieve a value, use the get() function.

Type

Map

Used by

converters

functions

bl

@function bl($value) { ... }
View source

Description

Return a multiple of get(baseline)

Parameters

parameter Nameparameter Descriptionparameter Typeparameter Default value
$value

Baseline multiplier

Number none

Returns

Length

Unit depends on the baseline value

Example

@include set(baseline, 1rem);
 
.element {
  margin-bottom: bl(2); // 2rem
}

Requires

Used by

Author

  • Kyle Oliveiro

em

@function em($value) { ... }
View source

Description

Convert px to em

Parameters

parameter Nameparameter Descriptionparameter Typeparameter Default value
$value

Value (in px) to convert

Number none

Returns

Em

Example

.element {
  font-size: em(20); // 1.25em
}

Author

  • Kyle Oliveiro

negative

@function negative($value) { ... }
View source

Description

Convert a value, list, or map of values to negative value(s)

Parameters

parameter Nameparameter Descriptionparameter Typeparameter Default value
$value

Number, list, or map to convert

Number or List or Map none

Returns

Number or List or Map

Example

$number: 10px;
$number: negative($number); // -10px;

$list: (1, -2rem, 30px);
$list: negative($list);     // (-1, -2rem, -30px);

$map: (
  a: 1,
  b: (1, -2rem, 30px)
);
$map: negative($map);       // ( a: -1, b: (-1, -2rem, -30px) );

Author

  • Kyle Oliveiro

rem

@function rem($value) { ... }
View source

Description

Convert px to rem

Parameters

parameter Nameparameter Descriptionparameter Typeparameter Default value
$value

Value (in px) to convert

Number none

Returns

Rem

Example

.element {
  font-size: rem(32); // 2rem
}

Author

  • Kyle Oliveiro

str-replace

@function str-replace($haystack, $needle, $replacement: '') { ... }
View source

Description

Replace text within on a string

Parameters

parameter Nameparameter Descriptionparameter Typeparameter Default value
$haystack

String to search in

String none
$needle

Substring to search for

String none
$replacement

Replacement string

String''

Returns

String

Example

$string: 'Beetle';
$string: str-replace($string, 'e');      // Btl

$string: 'Beetle';
$string: str-replace($string, 'e', '3'); // B33tl3

Author

  • Kyle Oliveiro

strip-units

@function strip-units($value) { ... }
View source

Description

Convert a unit-based value to a unitless number

Parameters

parameter Nameparameter Descriptionparameter Typeparameter Default value
$value

Value with units

Number none

Returns

Number

Example

$number: 10px;
$number: strip-units(10px); // 10

Author

  • Kyle Oliveiro

getters

functions

get-keys

@function get-keys($map, $dedupe: true) { ... }
View source

Description

Return a list of keys from a configuration map in $SCARAB

Parameters

parameter Nameparameter Descriptionparameter Typeparameter Default value
$map

Name of map to retrieve keys from

String none
$dedupe

Whether to dedupe the map before getting keys

Booltrue

Returns

List

Example

@include set( breakpoints, (
  small  : 600px,
  medium : 1024px,
  large  : 1300px,
  huge   : 1600px
) );

@debug get-keys(breakpoints); // ( small, medium, large, huge )

Requires

Author

  • Kyle Oliveiro

get

@function get($keys...) { ... }
View source

Description

Return a value from the $SCARAB configuration map

Parameters

parameter Nameparameter Descriptionparameter Typeparameter Default value
$keys

Description of key to retrieve the value from

Arglist none

Returns

Any

Example

@include set( breakpoints, (
  small  : 600px,
  medium : 1024px,
  large  : 1300px,
  huge   : 1600px
) );

@debug get(breakpoints);
// (
//     small  : 600px,
//     medium : 1024px,
//     large  : 1300px,
//     huge   : 1600px
// )

@debug get(breakpoints, small); // 600px

Requires

Used by

See

Author

  • Kyle Oliveiro

palette

@function palette($color...) { ... }
View source

Description

Return a color value from the configured palettes

Parameters

parameter Nameparameter Descriptionparameter Typeparameter Default value
$color

Description of color to return

Arglist none

Returns

Color

Example

@include set( palettes, (
  grey: (
    light : #EEEEEE,
    null  : #D0D0D0,
    dark  : #404040
  ), ...
) );

.element {
  background-color: palette(light grey); // #EEEEEE
  color: palette(dark grey);             // #404040

  &:hover {
    color: palette(grey); // palette(null grey) => #D0D0D0
  }
}

Requires

Author

  • Kyle Oliveiro

helpers

functions

dedupe

@function dedupe($map, $dedupe: true) { ... }
View source

Description

Remove keys from a map which contain duplicate values

If a map contains key-value pairs with multiple values, the first key in the map is retained, and duplicates are removed.

Parameters

parameter Nameparameter Descriptionparameter Typeparameter Default value
$map

Name of map to retrieve keys from

String none
$dedupe

Whether to dedupe the map before getting keys

Booltrue

Returns

List

Example

$colors: (
  blue:  #0000ff,
  red:   #ff0000,
  green: #00ff00,
  brand: #0000ff
);

@debug dedupe($colors);
// (
//    blue:  #0000ff,
//    red:   #ff0000,
//    green: #00ff00
// );

Used by

Author

  • Kyle Oliveiro

random-color

@function random-color() { ... }
View source

Description

Return a random color

Parameters

None.

Returns

Color

Example

body {
    background-color: random-color();
}

Used by

Author

  • Kyle Oliveiro

stringify-keys

@function stringify-keys($map) { ... }
View source

Description

Return a map with stringified keys

Parameters

parameter Nameparameter Descriptionparameter Typeparameter Default value
$map

The map to stringify

Map none

Example

$map: (
    0:   0,
    one: 1,
    tw0: two
);

@each $key, $val in $map {
    @debug type-of($key);
}

// DEBUG: number
// DEBUG: string
// DEBUG: string

$stringified-map: stringify-keys($map);

@each $key, $val in $stringified-map {
    @debug type-of($key);
}

// DEBUG: string
// DEBUG: string
// DEBUG: string

Used by

Author

  • Kyle Oliveiro

mixins

query

@mixin query($query...) { ... }
View source

Description

Declare properties within a @media query block

Parameters

parameter Nameparameter Descriptionparameter Typeparameter Default value
$query

Description of the media query

Arglist none

Content

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

Example

@include query( small ) {
    body {
        background-color: grey;
    }
}

@include query( below medium ) {
    .navigation {
        display: none;
    }
}

@include query( medium to huge ) {
    .page-title {
        font-size: 3rem;
    }
}

// The above code compiles to the following CSS:

@media (min-width: 600px) {
    body {
        background-color: grey
    }
}
@media (max-width: 1024px) {
    .navigation {
        display: none
    }
}
@media all and (min-width: 1024px) and (max-width: 1600px) {
    .page-title {
        font-size: 3rem
    }
}

Requires

Used by

Author

  • Kyle Oliveiro

responsive

@mixin responsive($properties, $query-map) { ... }
View source

Description

Declare properties at multiple breakpoints

Parameters

parameter Nameparameter Descriptionparameter Typeparameter Default value
$properties

Properties to declare

List none
$query-map

Map of queries-to-values

Map none

Example

.button {
    @include responsive(( padding-left, padding-right ), (
        base:   14px,
        medium: 18px,
        large:  22px
    ));
}

// The above code will output:

.button {
    padding-left: 14px;
    padding-right: 14px;
}

// 'medium' breakpoint
@media (min-width: 1024px) {
    .button {
        padding-left: 18px;
        padding-right: 18px;
    }
}

// 'large' breakpoint
@media (min-width: 1300px) {
    .button {
        padding-left: 22px;
        padding-right: 22px;
    }
}

Requires

Author

  • Kyle Oliveiro

set-default

@mixin set-default($definition...) { ... }
View source

Description

Set a default value for a key in the $SCARAB configuration map

Parameters

parameter Nameparameter Descriptionparameter Typeparameter Default value
$definition

Definition of the default value

Arglist none

Example

@include set-default( baseline, 1rem );
@debug get(baseline) // 1rem

@include set( baseline, 1.25rem );
@debug get(baseline) // 1.25rem

// This will not work, since a value already exists
@include set-default( baseline, 1rem ); 
@debug get(baseline) // 1.25rem

Requires

Author

  • Kyle Oliveiro

set

@mixin set($definition...) { ... }
View source

Description

Set a new value for a key in $SCARAB

Parameters

parameter Nameparameter Descriptionparameter Typeparameter Default value
$definition

Definition of the new value

Arglist none

Example

@include set( baseline, 1.25rem );

@debug get(baseline); // 1.25rem

@include set( breakpoints, (
    small  : 600px,
    medium : 1024px,
    large  : 1300px,
    huge   : 1600px
 ) );

@debug get(breakpoints);
// (
//     small  : 600px,
//     medium : 1024px,
//     large  : 1300px,
//     huge   : 1600px
// )

@debug get(breakpoints, small); // 600px

Requires

Used by

See

Author

  • Kyle Oliveiro

type-scale

@mixin type-scale($size) { ... }
View source

Description

Generate declarations for font-size and line-height

Parameters

parameter Nameparameter Descriptionparameter Typeparameter Default value
$size

Name of size in get(font-sizes) and get(line-heights)

String none

Requires

Author

  • Kyle Oliveiro

utilities

mixins

baseline-grid

@mixin baseline-grid($is-active: true, $disable-vertical-borders: true, $disable-vertical-align: true, $grid-color: rgba(125, 255, 255, 0.5)) { ... }
View source

Description

Overlay a vertical baseline grid on the :root element

Parameters

parameter Nameparameter Descriptionparameter Typeparameter Default value
$is-active

Whether to activate the baseline grid

Booltrue
$disable-vertical-borders

Whether to remove vertical borders from elements

Booltrue
$disable-vertical-align

Whether to disable vertical-align on elements

Booltrue
$grid-color

The color of the baseline grid's guides

Colorrgba(125, 255, 255, 0.5)

Requires

  • [function] bl

Author

  • Kyle Oliveiro

element-overlay

@mixin element-overlay($is-active: true, $base-color: random-color(), $transition-duration: 0.5s, $levels: 20) { ... }
View source

Description

Add an element overlay to the :root element

Parameters

parameter Nameparameter Descriptionparameter Typeparameter Default value
$is-active

Whether to activate the element overlay

Booltrue
$base-color

Base color of the element overlay

Colorrandom-color()
$transition-duration

Delay for overlay transitions

Duration0.5s
$levels

Number of levels deep in the DOM to overlay

Number20

Requires

Author

  • Kyle Oliveiro