dictionary.pick()

The dictionary.pick() function returns the dictionary from a global dictionary(if in use) and multiple $dictionary associated with $key.

Global dictionary is in use on $dictionary-global set to true, or by setting $global argument to true.

// Sass.
@use 'sass:list';
@use 'sass:meta';

// Variables.
@use 'dictionary.variables' as variables;

// Modules.
@use '../../map';

// Functions.
@use 'dictionary.is-global.function';

// The `translator.dictionary-pick()` or `dictionary.pick()` function.
@function pick($key, $dictionary: (), $global: null) {
  $dictionary: if(
    meta.type-of($dictionary) == list and list.length($dictionary) > 0,
    map.retrieve(pick, $dictionary...),
    $dictionary
  );
  @if dictionary.is-global($global) {
    $dictionary: if(
      $key,
      map.deep-merge(
        map.pick(variables.$dictionary, $key...),
        if(meta.type-of($dictionary) == map, map.pick($dictionary, $key...), ())
      ),
      map.deep-merge(variables.$dictionary, $dictionary)
    );
  } @else if $key {
    $dictionary: map.pick($dictionary, $key...);
  }
  @return $dictionary;
}
https://github.com/angular-package/sass/blob/main/translator/dictionary/_dictionary.pick.function.scss

Parameters

$key

A required key to pick the dictionary from the global dictionary(if in use) and $dictionary.

$dictionary: ()

Additional dictionaries along with a global dictionary(if in use) from which to pick dictionary associated with $key.

Dictionary as list indicates picking the dictionary of key, e.g. $dictionary class indicates to pick class key of $dictionary.

$global: null

A bool value indicates whether to use a global dictionary. Default, null, then $dictionary-global is checked.

Return

The return value is a dictionary consisting of the global dictionary(if in use) and given $dictionary from the associated $key.

Examples

Last updated

Was this helpful?