-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_function.scss
34 lines (29 loc) · 1.16 KB
/
_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
@function brandcolor($name,$number:1) {
$string-name: to-string($name);
$string-name: str-replace($string-name," ","-");
$string-name: str-replace($string-name,"_","-");
$string-name: str-replace($string-name,"'","");
$brand-key: $string-name;
$brand-name: str-replace($brand-key,"-"," ");
$brand-color: ();
@if map-has-key($brandcolors, $brand-key) {
$brand-color: map-get($brandcolors, $brand-key);
$brand-color-type: type-of($brand-color);
$brand-color-length: length($brand-color);
@if $brand-color-length < $number {
$color-text: if(($brand-color-length),"color","colors");
@error "`#{$brand-name}` has only #{$brand-color-length} #{$color-text} and you're asking for number `#{$number}`";
}
@else if $brand-color-type == list {
$brand-color: nth($brand-color, $number);
}
}
@else {
@error "The brand you are looking for does not exist or is misspelled: '#{$string-name}'";
}
$brand-color-type: type-of($brand-color);
@if $brand-color-type != color {
@error "The color number `#{$number}` of `#{$brand-name}` is not a valid color: `#{$brand-color}`";
}
@return $brand-color;
}