forked from Financial-Times/o-colors
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_functions.scss
42 lines (40 loc) · 1.27 KB
/
_functions.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
@function _oColorsGetPaletteColor($name) {
@each $color in $o-colors-palette-list {
@if nth($color,1) == $name {
@return nth($color,2);
}
}
@warn "Undefined color '" + $name + "' used";
@return black;
}
@function _oColorsGetUseCase($name, $property) {
@each $usecase in $o-colors-usecase-list {
@if (($property and $name == nth($usecase, 1) and $property == nth($usecase, 3)) or (not $property and $name == nth($usecase, 1) + '-' + nth($usecase, 3))) {
@if (length($usecase) == 4 and nth($usecase,4) == DEPRECATED) {
@warn "Deprecated use-case name '" + $name + "', variant '" + inspect($property) + "' used";
}
@return _oColorsGetPaletteColor(nth($usecase,2));
}
}
@return undefined;
}
@function oColorsGetColorFor($namelist, $property: null) {
$color: undefined;
@each $name in $namelist {
@if ($color == undefined) {
$color: _oColorsGetUseCase($name, $property);
}
@if ($color == undefined and $property != null) {
$color: _oColorsGetUseCase($name, all);
}
}
@if ($color == undefined) {
$error: "Undefined use-case: can\'t resolve '" + $namelist + "' to a colour";
@if ($property) {
$error: $error + " for property '" + $property;
}
@warn $error;
$color: black;
}
@return $color;
}