Skip to content

Commit

Permalink
feat(color/name): add color.name-create() function to create color …
Browse files Browse the repository at this point in the history
…name with `color` indicator.
  • Loading branch information
sciborrudnicki committed Dec 2, 2023
1 parent 653b1b5 commit 2897f63
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions color/functions/name/_name.create.function.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// Variables.
@use '../../../var/var.variables' as variables;

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

// Functions.
@use 'name.add-indicator.function' as *;

// Status: DONE
// The `color.name-create()` function creates color name with `color` indicator and `$shade`.
// @param `$name`
// @param `$type`
// @param `$delimiter`
// @param `$shade` (dark, light)
// @returns
@function create(
$name,
$type,
$delimiter: map.get(variables.$var, delimiter),
$shade: (dark, light),
) {
// Remove `$delimiter` if `$name` is `string` type.
@if type-of($name) == string {
$name: if($delimiter and string.length($delimiter) > 0, string.split($name, $delimiter), ($name,));
$name: list.join((), $name, space);
}
@if type-of($type) == string {
$type: if($delimiter and string.length($delimiter) > 0, string.split($type, $delimiter), ($type,));
}

// Add color indicator to `$name`.
$name: add-indicator($name, $shade);

// Add type to `$name`.
$name: if($type, list.join($name, $type, space), list.join((), $name, space));

// Returns.
@return $name;
}

// Examples.
// @debug create(primary dark, hue); // primary color dark hue

// @debug create(secondary light dark, saturation); // secondary light color dark saturation
// @debug create(secondary dark light, saturation); // secondary dark color light saturation

// @debug create(primary-dark, hue, '-'); // primary color dark hue
// @debug create(secondary-dark-light, saturation, '-'); // secondary dark color light saturation

// @debug create(primary-dark, hue, '-');

0 comments on commit 2897f63

Please sign in to comment.