Accoutrement 4.0.1

Inspecting Tokens

Tools for inspecting Accoutrement map token meta-data, useful for building more complicated logic for automation and integrations.

@function is-private-token()

Check if a token key is marked as private with _ or - as the starting character

Since 2.0.0:

  • NEW: Initial release

Parameters & Return

$key: (*)

The token key to check for private prefix (only string and list keys can be marked as private)

@return (boolean)

True if the key is private, otherwise false

Example

scss
/*! #{tools.is-private-token('_private-token')} */
/*! #{tools.is-private-token('public-token')} */
css compiled
/*! true */
/*! false */

Used By

@function var-contrast()

@function is-alias-for()

@mixin tokens--()

@function font-name() [private]

@function is-alias-for()

Find if a token is simply an alias, and (if so) what token it represents – either directly, or following the thread to it’s origin.

Since 2.0.0:

  • NEW: Initial release

Parameters & Return

$map: (map)

A map of terms to reference against

$token: (*)

The token name to be traced

$origin: false (*)

False to trace the alias one step back, or true to trace an alias thread back to the original source token

@return (*)

false for non-alias tokens, or the name of an alias source (either one step back, or the full origin of multiple aliases)

Example

scss
$colors: (
  '_brand': hsl(120, 50%, 50%),
  'text': '#_brand',
  'border': '#text',
  'outline': '#border',
);
/*! _brand: #{tools.is-alias-for($colors, '_brand')} */
/*! text: #{tools.is-alias-for($colors, 'text')} (_brand is private) */
/*! border: #{tools.is-alias-for($colors, 'border')} */
/*! outline: #{tools.is-alias-for($colors, 'outline', $origin: true)} */
css compiled
/*! _brand: false */
/*! text: false (_brand is private) */
/*! border: text */
/*! outline: text */

Requires

@function get() [private]

@function is-private-token()

Used By

@mixin token--()

@function font-name() [private]

@function font-values() [private]

@function has-token()

Find if a token exists in a given map.

Since 4.0.0:

  • NEW: Provides a token-syntax-aware alternative to the Sass internal map.has-key() function.

Parameters & Return

$map: (map)

A map of terms to reference against

$token: (*)

The token name or path (using ->) to lookup

$nested...: (*)

Optionally provide a nested token path as an arglist, rather than using the -> syntax.

@return (boolean)

Returns true if the requested token exists, or false if there is no token at the given path.

Example

scss
$colors: (
  'brand': hsl(120, 50%, 50%),
  'button': (
    'background': '#brand',
  )
);
/*! brand: #{tools.has-token($colors, 'brand')} */
/*! text: #{tools.has-token($colors, 'text')} */
/*! button->background: #{tools.has-token($colors, 'button->background')} */
/*! (button, background): #{tools.has-token($colors, 'button', 'background')} */
css compiled
/*! brand: true */
/*! text: false */
/*! button->background: true */
/*! (button, background): true */

Requires

@function lookup-alias() [private]

$handle-missing-keys (string | null)

Used By

@function default-contrast() [private]