Core

mixins

pal

@mixin pal($map) { ... }

Description

The entry point of the whole Sass Pal system. Utility maps have builder mixin names as keys and actual instructions as values (whose type depends on the builder). You can provide a more complex map to scope utility maps on specific devices, so that keys are device queries and values are request maps

Parameters

parameter Nameparameter Descriptionparameter Typeparameter Default value
$map

Can be a request map or a map of device-scoped request maps

Map none

Example

.test {
  @include pal((
    space: 'm^t3' 'mb4' 'py2' 'px4',
    size: 'w-1/3' 'h-1/2',
    position: absolute (2 4),
    border: 2 #ccc,
    flex: (
      main-align: end,
      cross-align: center,
    ),
  ));
}
// .test {
//   margin-right: 1.5rem;
//   margin-bottom: 1.5rem;
//   margin-left: 1.5rem;
//   margin-bottom: 2rem;
//   padding-top: 1rem;
//   padding-bottom: 1rem;
//   padding-right: 2rem;
//   padding-left: 2rem;
//   width: 33.33333%;
//   height: 50%;
//   position: absolute;
//   top: 1rem;
//   bottom: 1rem;
//   left: 2rem;
//   right: 2rem;
//   border: 1rem solid #ccc;
//   display: flex;
//   justify-content: flex-end;
//   align-items: center;
// }

Output

A set of rules as described by the passed request map(s)

Requires

Author

Core Builders

mixins

[private] _pal-builder

@mixin _pal-builder($builder, $value) { ... }

Description

Chooses the right builder mixin based on its name and calls it

Parameters

parameter Nameparameter Descriptionparameter Typeparameter Default value
$builder

Name of the builder mixin

String none
$value noneString or Number or Bool or Color or List or Map none

Output

Rules defined by called builder mixins

Requires

Used by

Author

pal-border

@mixin pal-border($border) { ... }

Description

Sass Pal builder for border-* rules. Any 'default' or missing value is replaced by its default. Any null value is explicitly not set instead.

Parameters

parameter Nameparameter Descriptionparameter Typeparameter Default value
$border noneList or Map or Number or String none

Example

With 1 value

pal-border(#aaa);
// border-width: 1px;
// border-style: solid;
// border-color: #aaa;

With 2 values

pal-border(2px #bbb);
// border-width: 2px;
// border-style: solid;
// border-color: #bbb;

With 3 values

pal-border(3px dashed #ccc);
// border-width: 3px;
// border-style: dashed:
// border-color: #ccc;

With 4 values

pal-border(4px double #ddd (1rem 2rem));
// border-width: 4px;
// border-style: double;
// border-color: #ddd;
// border-radius: 1rem 2 rem;

With null values (do not set them)

pal-border(null dotted #eee null);
// border-style: dotted;
// border-color: #eee;

With default values

pal-border('default' dashed null);
// border-width: 1px;
// border-style: dashed;

Scoped by side

pal-border(('t': 1px red, 'b': 2px dashed black));
// border-top: 1px solid red;      
// border-bottom: 2px dashed black;

Output

Border related rules

Requires

Used by

Author

pal-color

@mixin pal-color($_input) { ... }

Description

Sass Pal builder for color rules. It accepts either a map or a list. If given strings instead of native colors, Sass Pal converts the strings into native colors based on values stored into the 'colors' key of the store.

Parameters

parameter Nameparameter Descriptionparameter Typeparameter Default value
$_input noneList or Map or Number or String none

Example

Set the background color

.test {
  @include pal-color(#aaa);
}
// .test {
//   background-color: #aaa;
// }

Set all colors

.test {
  @include pal-color(#aaa #bbb #ccc);
}
// .test {
//   background-color: #aaa;
//   color: #bbb;
//   border-color: #ccc;
// }

Use Pal colors (pass strings)

.test {
  @include pal-color('pink-light' blue 'red');
}
// .test {
//   background-color: #fed7e2;
//   color: blue;
//   border-color: #e53e3e;
// }

Use a map

.test {
  @include pal-color((
    background: #aaa,
    text: #bbb,
    border: #ccc,
  ));
}
// .test {
//   background-color: #aaa;
//   color: #bbb;
//   border-color: #ccc;
// }

Pass any number of map keys

.test {
  @include pal-color((
    border: #ccc,
  ));
}
// .test {
//   border-color: #ccc;
// }

Set all colors

.test {
  @include pal-color(#aaa null #ccc);
}
// .test {
//   background-color: #aaa;
//   border-color: #ccc;
// }

Output

Color related rules

Requires

Used by

Author

pal-css

@mixin pal-css($input) { ... }

Description

Sass Pal builder to output CSS directly, it's just a bypass. Useful for readability. It accepts a map where key is CSS rule and value is whatever that rule accepts

Parameters

parameter Nameparameter Descriptionparameter Typeparameter Default value
$input noneMap none

Example

Use builders and "native" css together

.test {
  @include pal((
    color: 'red' 'teal',
    space: px3,
    css: (
      cursor: pointer,
      transform-origin: center,
    ),
  ));
}
// .test {
//   background-color: #e53e3e;
//   color: #38b2ac;
//   padding-right: 1.5rem;
//   padding-left: 1.5rem;
//   cursor: pointer;
//   transform-origin: center;
// }

Output

Native css declaration

Used by

Author

pal-flex

@mixin pal-flex($map) { ... }

Description

Sass Pal builder for Flexbox rules. All properties are optional. All passed values can be either a custom value (ex.: grow: 'more'), an alias (ex.: 'start' for 'flex-start') or any native value for that CSS rule

Shortcut

If input is 'center', output the rules for centering content (see Shortcut with 'center' example)

Aliases

  • start for flex-start
  • end for flex-end
  • between for space-between
  • around for space-around
  • evenly for space-evenly

Properties for flex containers

  • dir
    • type: String
    • note: Also accepts anything flex-direction accepts
  • inline
    • type: Bool
    • note: Outputs display: inline-flex
  • wrap
    • type: Bool
    • values: true|false
  • main-axis
    • type: String
    • aliases: start|end|between|around
    • note: Also accepts anything justify-content accepts
  • cross-axis
    • type: String
    • aliases: start|end
    • note: Also accepts anything align-items accepts
  • cross-lines
    • type: String
    • aliases: start|center|end|between|around
    • note: Also accepts anything align-content accepts

Properties for flex items

  • self-align
    • type: String
    • alias: start|end
    • note: Also accepts anything align-self accepts
  • basis
    • type: Number|String
    • values: Any of the defined relative-units (ex.: 'third')
    • note: Also accepts anything flex-basis accepts
  • grow
    • type: Number|String
    • values: 'no'|'normal'|'more' or custom Number
    • note: Also accepts anything flex-grow accepts
  • shrink
    • type: Number|String
    • values: 'least'|'less'|'normal'|'more'|'most' or custom Number
    • note: Also accepts anything flex-shrink accepts
  • order
    • type: Number|String
    • values: 'first'|'last' or custom Number
    • note: Also accepts anything order accepts
  • flex
    • type: List
    • values: Any valid List for native flex CSS rule

Parameters

parameter Nameparameter Descriptionparameter Typeparameter Default value
$map noneMap or String none

Example

Shortcut with 'center'

.shortcut {
  @include pal-flex('center');
}
// .shortcut {
//   display: flex;
//   justify-content: center;
//   align-items: center;
// }

A flex container

.container {
  @include pal-flex((
    main-axis: end,
    cross-axis: stretch
  ));
}
// .container {
//   display: flex;
//   justify-content: flex-end;
//   align-items: stretch;
// }

A flex item

.item {
  @include pal-flex((basis: '1/3'));
}
.item-big {
  @include pal-flex((grow: more));
}
// .item {
//   flex-basis: 33.33333%;
// }
// .item-big {
//   flex-grow: 2;
// }

Output

Flexbox rules

Requires

Used by

Author

pal-position

@mixin pal-position($list) { ... }

Description

Sass Pal builder for position rules. Accepts a list where the first value is a string for 'position' CSS rule and the second value is a list of 1, 2 or 4 numbers, which are interpreted as

  • 4 values: top, right, bottom, left (clockwise convention)
  • 2 values: top and bottom, right and left
  • 1 value: the same for every side

If instead of any number a null is passed, no rule is defined accordingly. If unitless values are used, they are treated as Sass Pal absolute units

Parameters

parameter Nameparameter Descriptionparameter Typeparameter Default value
$list noneList none

Example

With 4 numbers

pal-position(absolute (0 2rem auto 2rem)));
// position: absolute;
// top: 0;
// right: 2rem;
// bottom: auto;
// left: 2rem;

With 2 numbers (alternate list syntax without comma)

pal-position(relative (10px 20px));
// position: relative;
// top: 10px;
// bottom: 10px;
// right: 20px;
// left: 20px;

With 1 number

pal-position(fixed 30px);
// position: fixed;
// top: 30px;
// bottom: 30px;
// right: 30px;
// left: 30px;

With null values

pal-position(absolute (null 40px));
// position: absolute;
// right: 40px;
// left: 40px;

With unitless values (convert to Sass Pal absolute units)

pal-position(absolute (0 1 2 3));
// position: absolute;
// top: 0;
// right: 0.5rem;
// bottom: 1rem;
// left: 1.5rem;

Using Sass Pal's absolute and relative values

pal-position(fixed (0 '1/2u' '5/12%' '2/5%'));
// position: fixed;
// top: 0;
// right: 0.25rem;
// bottom: 41.66%;
// left: 40%;

Passing only one string

pal-position(relative);
// position: relative;

Output

Position-related rules

Requires

Used by

Author

pal-size

@mixin pal-size($sizes) { ... }

Description

Sass Pal builder for size rules (width, height, min-* and max-*). Sizes follow the syntax

{RULE_ABBREVIATION}-{RELATIVE_UNIT}

Where

  • RULE_ABBREVIATION is any of w, w-min, w-max, h, h-min, h-max
  • RELATIVE_UNIT is one of the labels from the relative-units stored value, ex.: '1/2', 'full'

Parameters

parameter Nameparameter Descriptionparameter Typeparameter Default value
$sizes noneMap none

Example

Set width and height with word aliases as size

pal-size(w-half h-full);
// width: 50%;
// height: 100%;

Set width and height with fractions

pal-size(w-1/2 h-3/4);
// width: 50%:
// height: 75%;

Use absolute units

pal-size(w-3u h-4u);
// width: 1.5rem;
// height: 2rem;

Output

Size related rules

Requires

Used by

Author

pal-space

@mixin pal-space($spacings) { ... }

Description

Sass Pal builder for spacing rules (margins, paddings). Each spacing is a string with the pattern

{RULE_KEY}{SIDE_KEY}{UNIT_KEY}

  • RULE_KEY is a rule key ('m' for margin or 'p' for padding)
  • SIDE_KEY is any side key (@see $_PAL_STORE.pal.sides)
  • UNIT_KEY is any of declared units (@see $_PAL_STORE.units)

Parameters

parameter Nameparameter Descriptionparameter Typeparameter Default value
$spacings noneList or String none

Example

Set margins of 1rem on all sides

pal-space(m2);
// margin: 1rem;

Set padding of 2rem on all sides expect bottom

pal-space(p^b4);
// padding-top: 2rem;
// padding-right: 2rem;
// padding-left: 2rem;

Set horizontal margin

pal-space(mx3);
// margin-right: 1.5rem;
// margin-left: 1.5rem;

Set some margin and padding

pal-space(p2 pt0 mx2 mb1)
// padding: 1rem;
// padding-top: 0;
// margin-right: 1rem;
// margin-left: 1rem;
// margin-bottom: 0.5rem;

Output

Margin and/or padding rules

Throws

  • Spacing

Requires

Used by

Author

Core Functions

functions

pal-color-get

@function pal-color-get($The) { ... }

Description

Extracts a color from the defined palette. It's just an alias for pal-get('color.xxx')

Parameters

parameter Nameparameter Descriptionparameter Typeparameter Default value
$The

color name

String none

Returns

Color

Example

Get the blue

pal-color-get('blue'); // #4299e1

Requires

Author

[private] _pal-group-by-device-query

@function _pal-group-by-device-query($map) { ... }

Description

Groups request maps by the same device query so that Sass Pal will output less @media queries. Device queries differing only in pseudo-classes are grouped together

Parameters

parameter Nameparameter Descriptionparameter Typeparameter Default value
$map

A multi-request map

Map none

Returns

List

List of device-scoped request maps

Example

Numbers replace real request maps for readability

$map: (
  'mobile+': 111,
  'mobile+:hover': 222,
  'mobile+:focus': 333,
  'tablet+': 444,
  'tablet:hover': 555,
  'desktop': 666,
);

$grouped: _pal-group-by-device-query($map);

@debug($grouped);
// (
//   (
//     'query': (
//       'device': 'mobile',
//       'operator': 'up',
//     ),
//     'request-maps': (
//       'any': 111,
//       'hover': 222,
//       'focus': 333,
//     ),
//   ),
//   (
//     'query': (
//       'device': 'tablet',
//       'operator': 'up',
//     ),
//     'request-maps': (
//       'any': 444,
//     ),
//   ),
//   (
//     'query': (
//       'device': 'tablet',
//       'operator': 'in',
//     ),
//     'request-maps': (
//       'hover': 555
//     ),
//   ),
//   (
//     'query': (
//       'device': 'desktop',
//       'operator': 'in',
//     ),
//     'request-maps': (
//       'any': 666,
//     )
//   ),
// );

Requires

Used by

Author

[private] _pal-has-any-device-query

@function _pal-has-any-device-query($map) { ... }

Description

Checks if map is a collection of device-scoped request maps or not

Parameters

parameter Nameparameter Descriptionparameter Typeparameter Default value
$map noneMap none

Returns

Bool

Example

Against a map of device-scoped request maps

_pal-has-any-device-query(
  (
    'tablet': 111,
  )
);
// true

Against a simple request map

_pal-has-any-device-query(
  (
    'position': 111,
    'flex': 222,
  )
);
// false

Requires

Used by

Author

[private] _pal-parse-device-query

@function _pal-parse-device-query($query) { ... }

Description

Breaks down an input device query into a map with properties. A device query is a string following this syntax

{DEVICE}{OPERATOR}{PSEUDO_CLASS}

Where

  • DEVICE can be any allowed device or * wildcard for 'all devices'
  • OPERATOR can be
    • '+' meaning 'from DEVICE min resolution upward'
    • '-' meaning 'from DEVICE max resolution downward'
    • '' or '=' means 'between DEVICE min and max resolution only'
  • PSEUDO_CLASS can be any pseudo-class (see pseudo-classes stored value for more), ex.:
    • ':hover'
    • ':focus'
    • ':active'

Parameters

parameter Nameparameter Descriptionparameter Typeparameter Default value
$query

Device query to parse

String none

Returns

Map

Parsed query into separate properties of this map

Example

Parse device query from tablet downward for hover state

_pal-parse-device-query('tablet-:hover')
// (
//   device: 'tablet',
//   operator: 'down'
//   pseudo-class: 'hover'
// )

Requires

Used by

Author

pal-parse-sides

@function pal-parse-sides($input) { ... }

Description

Parses any sides combination as a string to the proper list of sides. Always returns a list even for one side. Input strings are words composed of the letters

  • t (top)
  • r (right)
  • b (bottom)
  • l (left)

Special modifiers are

  • * is a bypass for all sides
  • ^ or - negates a side, ex.: ^t: (right, bottom, left)

Parameters

parameter Nameparameter Descriptionparameter Typeparameter Default value
$input noneString none

Returns

List

List of sides

Example

pal-parse-sides('b') // ('bottom')
pal-parse-sides('tr') // ('top', 'right')
pal-parse-sides('*') // ('top', 'right', 'bottom', 'left')
pal-parse-sides('-t') // ('right', 'bottom', 'left')
pal-parse-sides('^t') // ('right', 'bottom', 'left')

Requires

Used by

Author

pal-parse-unit

@function pal-parse-unit($input) { ... }

Description

Transforms a string with a suffix via Sass Pal's stored values (units or relative-units), otherwise it just returns the number as it is. If given an unitless integer it treats it as units.

Parameters

parameter Nameparameter Descriptionparameter Typeparameter Default value
$input noneNumber or String none

Returns

Number

Example

Parse numbers

pal-parse-number('3/4u'); // 0.375rem
pal-parse-number('1/2%'); // 50%
pal-parse-number(1/2); // 0.5
pal-parse-number(2); // 1rem

Requires

Used by

Author

pal-parse-value

@function pal-parse-value($input, $from) { ... }

Description

If given a string, it's used as key and it returns a Sass Pal's stored value using the given $from prefix. Any other value is returned as it is

Parameters

parameter Nameparameter Descriptionparameter Typeparameter Default value
$input noneNull or Bool or Number or Color or String or List or Map none
$from noneString none

Returns

Null</code> or <code>Bool</code> or <code>Number</code> or <code>Color</code> or <code>String</code> or <code>List</code> or <code>Map

Example

Return values as is

pal-parse-value(#aaa, 'color'); // #aaa
pal-parse-value(16px, 'units');

Parse the value using Sass Pal's stored values

pal-parse-value('indigo', 'color'); // #667eea
pal-parse-value('3/4', 'units'); // 0.375rem
pal-parse-value('3/4', 'relative-units'); // 75%

Requires

Used by

Author

pal-get

@function pal-get($query) { ... }

Description

Extracts a stored value by its key. Accepts a dot-separated nested query

Parameters

parameter Nameparameter Descriptionparameter Typeparameter Default value
$query noneString none

Returns

Null</code> or <code>Bool</code> or <code>Number</code> or <code>Color</code> or <code>String</code> or <code>List</code> or <code>Map

Example

Get default media query operator

pal-get('pal.media-query.operator'); // '='

Get the base unit

pal-get('unit'); // 0.5rem

Requires

Used by

Author

pal-set-merge

@function pal-set-merge($key, $payload) { ... }

Description

Merges a given map (the merge map) into an existing map (the stored map) inside the store, key by key

  • If stored map does not exist, store merge map as a new item of the store
  • If stored map does exist into the store
    • Keys existing only into the stored map are preserved
    • Keys existing in both maps are chosen from the merge map (overwrite)
    • Keys existing only into the merge map are added to the stored map
  • Works only when adding a map to an existing map in the store*

Parameters

parameter Nameparameter Descriptionparameter Typeparameter Default value
$key noneString none
$payload noneMap none

Returns

Null

Example

Add a new device

$_: pal-set-merge('devices', (
  'desktop-small': (1024px, 1280px),
  'desktop': (1280px, 1440px),
));
pal-get('devices');
// 'devices': (
//   'mobile':  (320px,  768px),        // Preserved
//   'tablet':  (768px,  1024px),       // Preserved
//   'desktop': (1280, 1440px),         // Overwritten
//   'wider':    (1440px, 9999px),      // Preserved
//   'desktop-small': (1024px, 1280px), // Added
// )

Requires

Author

pal-set

@function pal-set($key, $value) { ... }

Description

Sets a new key-value into the Sass Pal store by dispatching an action. If the action has a reducer, some logic is performed, otherwise the value is set or overwritten as it is.

Parameters

parameter Nameparameter Descriptionparameter Typeparameter Default value
$key noneString none
$value noneNull or Bool or Number or Color or String or List or Map none

Returns

Null

Example

Set base unit

pal-set('unit', 1rem); // null

Throws

  • You cannot override the

Requires

Used by

Author

Core Initializers

mixins

pal-init-normalize

Since 0.8.0
@mixin pal-init-normalize() { ... }

Description

This outputs the normalize.css v8.0.1 from github.com/necolas/normalize.css

Parameters

None.

Output

normalize.css v8.0.1

Links

Author

  • Nicolas Gallagher

pal-init-reset

Since 0.8.0
@mixin pal-init-reset() { ... }

Description

This outputs the reset v2.0 20110126 from http://meyerweb.com/eric/tools/css/reset/

Parameters

None.

Output

reset v2.0 20110126

Links

Author

  • Nicolas Gallagher

Core Reducers

functions

[private] _pal-reducers

@function _pal-reducers($state, $action) { ... }

Description

Runs all the reducers. By default, reducers must create

Parameters

parameter Nameparameter Descriptionparameter Typeparameter Default value
$state

The current state

Map none
$action

Contains the type (store key) and the payload (new value)

Map none

Returns

Map

The new state

Requires

Used by

Author

[private] _pal-devices-reducer

@function _pal-devices-reducer($store, $old-value) { ... }

Description

Updates the 'devices' key of the store Substracts a tiny length to the upper end resolutions so that @media queries do not overlap Stores 'devices'

Parameters

parameter Nameparameter Descriptionparameter Typeparameter Default value
$store noneMap none
$old-value noneMap none

Used by

Author

[private] _pal-relative-units-reducer

@function _pal-relative-units-reducer($state, $action) { ... }

Description

Transforms all relative units of the payload to percentages before storing Stores 'relative-units'

Parameters

parameter Nameparameter Descriptionparameter Typeparameter Default value
$state noneMap none
$action noneMap none

Returns

Map

Requires

Used by

Author

[private] _pal-unit-reducer

@function _pal-unit-reducer($state, $action) { ... }

Description

Adjusts all existing units with the new base unit Stores 'unit' and 'units'

Parameters

parameter Nameparameter Descriptionparameter Typeparameter Default value
$state noneMap none
$action noneMap none

Returns

Map

Requires

Used by

Author

[private] _pal-units-reducer

@function _pal-units-reducer($state, $action) { ... }

Description

Multiplies all units by the base unit Stores 'units'

Parameters

parameter Nameparameter Descriptionparameter Typeparameter Default value
$state noneMap none
$action noneMap none

Returns

Map

Requires

Used by

Author

Core Stored Values

variables

pal-colors

$pal-colors: pal-set('colors', (
  'black':        #333333,
  'white':        #f8f8f8,
  'gray-dark':    #2d3748,
  'gray':         #a0aec0,
  'gray-light':   #edf2f7,
  'red-dark':     #9b2c2c,
  'red':          #e53e3e,
  'red-light':    #fc8181,
  'orange-dark':  #9c4221,
  'orange':       #ed8936,
  'orange-light': #fbd38d,
  'yellow-dark':  #b7791f,
  'yellow':       #f6e05e,
  'yellow-light': #fefcbf,
  'green-dark':   #276749,
  'green':        #48bb78,
  'green-light':  #9ae6b4,
  'teal-dark':    #285e61,
  'teal':         #38b2ac,
  'teal-light':   #b2f5ea,
  'blue-dark':    #2c5282,
  'blue':         #4299e1,
  'blue-light':   #bee3f8,
  'indigo-dark':  #434190,
  'indigo':       #667eea,
  'indigo-light': #c3dafe,
  'purple-dark':  #553c9a,
  'purple':       #9f7aea,
  'purple-light': #e9d8fd,
  'pink-dark':    #97266d,
  'pink':         #ed64a6,
  'pink-light':   #fed7e2,
));

Description

Map of default colors. Key: color name, value: color as RGB

Type

Map

pal-devices

$pal-devices: pal-set('devices', (
  'mobile':  (320px,  768px),
  'tablet':  (768px,  1024px),
  'desktop': (1024px, 1440px),
  'wider':    (1440px, 9999px),
));

Description

Map of default devices. Key: device name, value: list with min and max resolution

Type

Map

pal-devices

$pal-devices: pal-set('pseudo-classes', (
  ':hover',
  ':focus',
  ':active',
  ':first-child',
  ':last-child',
  ':disabled',
  ':enabled',
  ':checked',
  ':empty',
));

Description

List of default pseudo-classes. Avoid adding pseudo-class functions like :host() (:host is fine)

Type

List

pal-devices

$pal-devices: pal-set('relative-units', (
  '0':       0,
  '1/12':    1/12,
  '2/12':    2/12,
  '3/12':    3/12,
  '4/12':    4/12,
  '5/12':    5/12,
  '6/12':    6/12,
  '7/12':    7/12,
  '8/12':    8/12,
  '9/12':    9/12,
  '10/12':   10/12,
  '11/12':   11/12,
  '12/12':   12/12,
  '1/8':     1/8,
  '1/4':     1/4,
  '1/3':     1/3,
  '2/5':     2/5,
  '1/2':     1/2,
  '2/3':     2/3,
  '3/4':     3/4,
  'quarter': 1/4,
  'third':   1/3,
  'half':    1/2,
  'full':    1,
));

Description

Default relative units. Key: label, value: number. The reducer turns them into percentages

Type

Map

_PAL_STORE

$_PAL_STORE: (

  // Unmodifiable values
  'pal': (

    'decimals': 5,

    'media-query': (

      // Default media query operator
      'operator': 'in',

      // Media query operators
      'operators': (
        '=': 'in',
        '-': 'down',
        '+': 'up',
      ),
    ),

    // All sides combination of a rectangle
    'sides': (

      // One side
      't': ('top'),
      'r': ('right'),
      'b': ('bottom'),
      'l': ('left'),

      // Two opposite sides
      'x': ('right', 'left'),
      'y': ('top', 'bottom'),

      // Two adjacent sides (corners)
      'tr': ('top', 'right'),
      'rb': ('right', 'bottom'),
      'bl': ('bottom', 'left'),
      'lt': ('left', 'top'),
      'rt': ('top', 'right'), // Alias of 'tr'
      'br': ('bottom', 'right'), // Alias of 'rb'
      'lb': ('bottom', 'left'), // Alias of 'bl'
      'tl': ('left', 'top'), // Alias of 'tl'

      // Three sides
      '-t': ('right', 'bottom', 'left'),
      '-r': ('top', 'bottom', 'left'),
      '-b': ('top', 'right', 'left'),
      '-l': ('top', 'right', 'bottom'),
      '^t': ('right', 'bottom', 'left'), // Alias of -t
      '^r': ('top', 'bottom', 'left'), // Alias of -r
      '^b': ('top', 'right', 'left'), // Alias of -b
      '^l': ('top', 'right', 'bottom'), // Alias of -l

      // All sides
      '*': ('top', 'right', 'bottom', 'left'),
    ),

  ),
);

Description

All Sass Pal stored values are stored here. Unmodifiable values are already set inside the 'pal' key

Type

Map

Map structure

Map key NameMap key DescriptionMap key TypeMap key Value
pal

Contains Unmodifiable values used by Sass Pal

Map none
pal.decimals

Number of decimal digits to round to

Number none
pal.media-query

Map of all @media query related data

Map none
pal.media-query.operator

Default @media query operator

String none
pal.media-query.operators

Map of all @media query operators. Key: symbol, value: operator name

Map none
pal.sides

Map of all sides of a rectangle. Key: abbreviation, value: list of sides

Map none

Used by

pal-unit

$pal-unit: pal-set('unit', 0.5rem);

Description

Default base unit, multiplies all other units

Type

Number

pal-units

$pal-units: pal-set('units', (
  '0':   0,
  '1/8': 1/8,
  '1/4': 1/4,
  '1/3': 1/3,
  '1/2': 1/2,
  '3/5': 3/5,
  '2/3': 2/3,
  '3/4': 3/4,
  '1':   1,
  '2':   2,
  '3':   3,
  '4':   4,
  '5':   5,
  '6':   6,
  '7':   7,
  '8':   8,
  '9':   9,
  '10':  10,
  '11':  11,
  '12':  12,
  '13':  13,
  '14':  14,
  '15':  15,
  '16':  16,
));

Description

Default absolute units. Key: label, value: number. The reducer multiplies them by the base unit

Type

Map

Helper Functions for any type

functions

pal-compare

@function pal-compare($a, $b) { ... }

Description

Compares any two Sass values and returns true if they contain the same data. They don't have to be the same reference

Parameters

parameter Nameparameter Descriptionparameter Typeparameter Default value
$a noneNull or Bool or Number or Color or String or List or Map none
$b noneNull or Bool or Number or Color or String or List or Map none

Returns

Bool

Example

Compare some values

pal-compare(null, null); // true
pal-compare(1 2 3, 1 2 3); // true
pal-compare((a:1,b:2), (a:1,b:2)); // true

Used by

Author

Helper Functions for Lists

functions

pal-list-get

@function pal-list-get($list, $index) { ... }

Description

Returns an element from the list by its index. Returns null if index doesn't exist

Parameters

parameter Nameparameter Descriptionparameter Typeparameter Default value
$list noneList none
$index noneNumber none

Returns

Null</code> or <code>Bool</code> or <code>Number</code> or <code>Color</code> or <code>String</code> or <code>List</code> or <code>Map

Example

Get elements from a list

pal-list-get(a b c, 2); // b
pal-list-get(a b c, 42); // null

Used by

Author

pal-list-join

@function pal-list-join($list, $glue) { ... }

Description

Transforms a plain list into a string

Parameters

parameter Nameparameter Descriptionparameter Typeparameter Default value
$list noneList none
$glue

The separator to use between elements of the list

String none

Returns

String

Example

Join all devices in a string

pal-list-join(('mobile', 'tablet', 'desktop'), '_')
// 'mobile_tablet_desktop'

Author

pal-list-sort-by-length

@function pal-list-sort-by-length($words) { ... }

Description

Sorts a list of strings by descending string length

Parameters

parameter Nameparameter Descriptionparameter Typeparameter Default value
$words

List of strings

List none

Returns

List

Example

Sort strings by decending length

pal-list-sort-by-length(aa bbbb ccc);
// bbbb ccc aa

Used by

Author

Helper Functions for Maps

functions

pal-map-are-keys

@function pal-map-are-keys($map, $keys) { ... }

Description

Checks if all given keys in a map are set and have non-null values

Parameters

parameter Nameparameter Descriptionparameter Typeparameter Default value
$map noneMap none
$keys noneList none

Returns

Bool

Example

Check if all keys are set to non-null values

pal-map-are-keys((a: 12, b: 34), (a, b)); // true
pal-map-are-keys((a: 12, b: 34), (a, b, c)); // false

Used by

Author

pal-map-get-all

@function pal-map-get-all($map, $queries) { ... }

Description

Extracts values from a map, given a list of keys (also nested keys, see pal-map-get())

Parameters

parameter Nameparameter Descriptionparameter Typeparameter Default value
$map noneMap none
$queries noneList none

Returns

List

Example

Get 'foo' and 'bar' as a list

$map: ('foo': 12, 'bar': 34, 'baz': 56);
$list: pal-map-get-all($map, ('bar', 'baz')); // (34, 56)

Requires

Used by

Author

pal-map-get

@function pal-map-get($map, $query) { ... }

Description

Extends the Sass built-in map-get() by allowing to get nested values like you would do in JavaScript, ex.: pal-map-get($map, 'foo.bar.baz');

You can pass it dot-separated queries to access nested values

Parameters

parameter Nameparameter Descriptionparameter Typeparameter Default value
$map noneMap none
$query noneString none

Returns

Null</code> or <code>Bool</code> or <code>Number</code> or <code>Color</code> or <code>String</code> or <code>List</code> or <code>Map

Example

Get nested value

$foo: ('bar': ('baz': ('qez': 123)));
pal-map-get($foo, 'bar.baz.qez');
// 123

Requires

Used by

Author

pal-map-is-any-key

@function pal-map-is-any-key($map, $keys) { ... }

Description

Checks if input map has any of the given keys (with non-null values)

Parameters

parameter Nameparameter Descriptionparameter Typeparameter Default value
$map noneMap none
$keys noneList none

Returns

Bool

Example

Check if map has any of given keys

pal-map-is-any-key((a: 1), (a, b, c)); // true
pal-map-are-keys((a: 1), (b, c, d, e)); // false

Used by

Author

pal-map-set

@function pal-map-set($map, $key, $value) { ... }

Description

Updates a map with a new value for a given key. Overwrites existing keys

Parameters

parameter Nameparameter Descriptionparameter Typeparameter Default value
$map

The input map

Map none
$key

The new/existing key

String none
$value

The new value

Null or Bool or Number or Color or String or List or Map none

Returns

Map

The updated input map

Example

Set a new value

$a: ('a': 111);
$a: pal-map-set($a, 'b', 222);
// ('a': 111, 'b': 222)

Overwrite an existing value

$b: ('a': 111);
$b: pal-map-set($b, 'a', 222);
// ('a': 222)

Used by

Author

Helper Functions for Numbers

functions

pal-number-decimals

@function pal-number-decimals($input) { ... }

Description

Returns the length unit of the passed number as a string (ex.: 'px', 'rem'). If input has no unit, an empty string is returned

Parameters

parameter Nameparameter Descriptionparameter Typeparameter Default value
$input noneNumber none

Returns

String

The number's unit

Example

pal-number-get-unit(24px) // 'px'
pal-number-get-unit(3rem) // 'rem'
pal-number-get-unit(75%) // '%'
pal-number-get-unit(4) // ''

Used by

Author

pal-number-get-unit

@function pal-number-get-unit($input) { ... }

Description

Returns the length unit of the passed number as a string (ex.: 'px', 'rem'). If input has no unit, an empty string is returned

Parameters

parameter Nameparameter Descriptionparameter Typeparameter Default value
$input noneNumber none

Returns

String

The number's unit

Example

pal-number-get-unit(24px) // 'px'
pal-number-get-unit(3rem) // 'rem'
pal-number-get-unit(75%) // '%'
pal-number-get-unit(4) // ''

Used by

Author

pal-number-half-plus-one

@function pal-number-half-plus-one($input) { ... }

Description

Always returns the half + 1 as an integer of any integer input. Input number should be unitless

Parameters

parameter Nameparameter Descriptionparameter Typeparameter Default value
$input noneNumber none

Returns

Number

Example

pal-number-half-plus-one(13) // 7
pal-number-half-plus-one(30) // 16

Author

pal-number-has-unit

@function pal-number-has-unit($input) { ... }

Description

Returns whether the input number has a length unit or not

Parameters

parameter Nameparameter Descriptionparameter Typeparameter Default value
$input noneNumber none

Returns

Bool

Has it a unit?

Example

pal-number-has-unit('24px') // true
pal-number-has-unit('12') // false

Requires

Used by

Author

pal-number-is-integer

@function pal-number-is-integer($input) { ... }

Description

Returns whether the input number is an integer or not

Parameters

parameter Nameparameter Descriptionparameter Typeparameter Default value
$input noneNumber none

Returns

Bool

Is it an integer?

Example

Check if numbers are integers

pal-number-is-integer(1); // true
pal-number-is-integer(2rem); // true
pal-number-is-integer(42%); // true
pal-number-is-integer(0.5); // false
pal-number-is-integer(0.75rem); // false
pal-number-is-integer(12.34%); // false

Used by

Author

pal-number-to-string

@function pal-number-to-string($input) { ... }

Description

Casts a number to string

Parameters

parameter Nameparameter Descriptionparameter Typeparameter Default value
$input noneNumber none

Returns

String

Example

pal-number-to-string(123) // '123'

Author

Helper Functions for Strings

functions

pal-string-alphabet

@function pal-string-alphabet($lowercase, $uppercase) { ... }

Description

Returns the alphabet both lowercase and uppercase, optionally

Parameters

parameter Nameparameter Descriptionparameter Typeparameter Default value
$lowercase

Include lowercase letters?

Bool none
$uppercase

Include uppercase letters?

Number none

Returns

List

Example

Every letter of the alphabet (lowercase and uppercase)

pal-string-alphabet();

Every letter of the alphabet, only uppercase

pal-string-alphabet($lowercase: false);

Every letter of the alphabet, only lowercase

pal-string-alphabet($uppercase: false);

Used by

Author

pal-string-get

@function pal-string-get($string, $index) { ... }

Description

Extract a single character from a string given its 1-based index (see examples). Accepts negative integers as it's an alias of the native str-slice.

Parameters

parameter Nameparameter Descriptionparameter Typeparameter Default value
$string

The string to extract the character from

String none
$index

The character index to be extracted

Number none

Returns

String

Example

Get a character from a string

pal-string-get('Hello world', 1); // 'H'
pal-string-get('Hello world', -3); // 'r'

Author

pal-string-is-css-class

@function pal-string-is-css-class($class) { ... }

Description

Parameters

parameter Nameparameter Descriptionparameter Typeparameter Default value
$class

The CSS class to check

String none

Returns

Bool

Example

Check if given string is a valid CSS class

pal-string-is-css-class('valid') // true
pal-string-is-css-class('-valid') // true
pal-string-is-css-class('42invalid') // false
pal-string-is-css-class('_valid') // true
pal-string-is-css-class('_42invalid') // false
pal-string-is-css-class('-42invalid') // false
pal-string-is-css-class('x') // false
pal-string-is-css-class('') // false
pal-string-is-css-class('valid42') // true

Requires

Author

pal-string-split

@function pal-string-split($string, $seperator) { ... }

Description

Splits given string by the given separator into a plain list

Parameters

parameter Nameparameter Descriptionparameter Typeparameter Default value
$string

The string to split

String none
$seperator

The separator to split into

String none

Returns

List

Example

Split a phrase into words

pal-string-split('how are you?', ' ')
// ('how', 'are', 'you?')

Used by

Author

pal-string-starts-with

@function pal-string-starts-with($haystack, $needle) { ... }

Description

Checks if a given string starts with a given substring

Parameters

parameter Nameparameter Descriptionparameter Typeparameter Default value
$haystack

The string to search into

String none
$needle

The substring

String none

Returns

Bool

Example

Check if a string starts with given substring

pal-string-starts-with('hello world', 'hell'); // true
pal-string-starts-with('hello world', 'world'); // false

Used by

Author

Helper Mixins

mixins

pal-media-query

@mixin pal-media-query($device: '*', $operator: null) { ... }

Description

Wrap all its content into a media query based on given arguments

Parameters

parameter Nameparameter Descriptionparameter Typeparameter Default value
$device

The device name

String'*'
$operator

The device operator (like 'in' or 'up')

String or Nullnull

Example

Wrap @content into a @media query for tablets only

@include pal-media-query('tablet', 'in') { .foo { color: red } }
// @media screen and (min-width: 768px) { .foo { color: red } }

Output

Input rules wrapped in a custom @media query

Requires

Used by

Author

pal-pseudo-class

@mixin pal-pseudo-class($pseudo-class: '*', $parent: null) { ... }

Description

Wraps given content into a pseudo-selector. It uses the parent selector & so make sure to use this inside a class. You can optionally provide a custom parent selector to use. It has no effect if you pass a bypass, like '*' or 'any'

Parameters

parameter Nameparameter Descriptionparameter Typeparameter Default value
$pseudo-class

Pseudo-class name (no :) or '*' or 'any' for bypass

String'*'
$parent

Custom parent selector name

String or Nullnull

Example

Scope rules for :focus state only

@include pal-pseudo('focus') { .foo { color: red } }
// &:focus { .foo { color: red } }

Output

Input rules wrapped in chosen pseudo class

Used by

Author