Skip to content

Commit

Permalink
refactor(var.name()): retrieve dictionary from $dictionary if var
Browse files Browse the repository at this point in the history
… is found.
  • Loading branch information
sciborrudnicki committed Aug 30, 2023
1 parent ae518d4 commit f3e5c83
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions var/functions/_var.name.function.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,22 @@
// @returns The return value is CSS variable of `$name`.
@function name(
$name,
$dictionary: (),
$dictionary: null,
$delimiter: null,
$prefix: null,
$suffix: null
) {
@return --#{functions.name(
$name,
$dictionary,
if($dictionary and map.has-key($dictionary, var), map.get($dictionary, var), $dictionary) or (),
$delimiter or map.get(var.$var, delimiter),
$prefix or map.get(var.$var, prefix),
$suffix or map.get(var.$var, suffix)
)};
}

// Examples.
// @debug name(layout spacing, null, '-', s); // --s-layout-spacing
// @debug name(layout spacing, (), '-', s); // --s-layout-spacing

// dictionary
Expand All @@ -44,6 +45,7 @@
// dictionary passed in the name
// @debug name(layout spacing (layout: lay, spacing: spa), (), '-', s); // --s-lay-spa
// @debug name(layout spacing (layout: lay, spacing: spa), (prefix: spectre), '-'); // --spectre-lay-spa
// @debug name(layout spacing (layout: lay, spacing: spa), (var: (prefix: spectre)), '-'); // --spectre-lay-spa

// dictionary with the var key
// @debug name(layout spacing, (prefix: spectre, suffix: end), '-'); // --spectre-layout-spacing-end

0 comments on commit f3e5c83

Please sign in to comment.