-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
_name.replace.function.scss
45 lines (38 loc) · 1.32 KB
/
_name.replace.function.scss
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Sass.
@use 'sass:list';
@use 'sass:map';
// Variables.
@use '../../var/var.variables' as variables;
// Modules.
@use 'adjustment/adjustment.has.function';
// Module functions.
@use 'name.create.function' as *;
// Status: DONE
// The `color.name-replace()` function updates color name with `color` indicator and `$shade`.
// @param `$name`
// @param `$replace`
// @param `$type`
// @param `$delimiter`
// @param `$shade` (dark, light)
// @returns
@function replace(
$name,
$replace,
$type: null,
$delimiter: map.get(variables.$var, delimiter),
$shade: (dark, light),
) {
@return if(
adjustment.has($name),
list.set-nth($name, 1, create($replace, $type, $delimiter, $shade)),
create($replace, $type, $delimiter, $shade)
);
}
// Examples.
// @debug replace(primary, secondary light, lightness); // secondary color light lightness
// @debug replace(primary dark, secondary light, lightness); // secondary color light lightness
// adjustment
// @debug replace((primary,) 15% 0.1, secondary light, lightness); // (secondary color light lightness) 15% 0.1
// comma adjustment
// @debug replace((primary dark) 15% 0.1, secondary light, lightness); // (secondary color light lightness) 15% 0.1
// @debug replace((primary dark, 15deg, 15%, 0.1), secondary light, lightness); // secondary color light lightness, 15deg, 15%, 0.1