-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_color.scss
executable file
·85 lines (74 loc) · 2.36 KB
/
_color.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
//===============================================================
// Color
//===============================================================
/*
Utility that automatically generates all of the color styles
for a project. Relies on a $colors map variable existing in the following format:
*/
$colors: (
black: #222,
white: #fff,
gray: #aaa
) !default;
//---------------------------------------------------------------
// Variables
//---------------------------------------------------------------
$tint-mix: #fff !default;
$shade-mix: #000 !default;
//---------------------------------------------------------------
// Color
//---------------------------------------------------------------
/*
Function for getting a specific color from within the $colors map
@param $key (string) - Key color you want
@param $map (map) - Map to search for $key [$colors]
*/
@function color($key, $map: $colors) {
@if map-has-key($map, $key) {
@return map-get($map, $key);
} @else {
@error "Key `#{$key}` doesn't exist in map `#{$map}`";
}
}
//---------------------------------------------------------------
// Tint
//---------------------------------------------------------------
/*
Function for lightening a color
@param $color (color) - color to tint
@param $percentage (number) - percentage of `$color` in returned color
@return color
*/
@function tint($color, $percentage) {
@return mix($tint-mix, $color, $percentage);
}
//---------------------------------------------------------------
// Shade
//---------------------------------------------------------------
/*
Function for darkening a color
@param $color (color) - color to tint
@param $percentage (number) - percentage of `$color` in returned color
@return color
*/
@function shade($color, $percentage) {
@return mix($shade-mix, $color, $percentage);
}
//---------------------------------------------------------------
// Output Helper Classes
//---------------------------------------------------------------
/*
Loop through the $colors map (defined in `_base/variable.scss`)
and generate helpers classes we can use to apply directly into our
template markup.
*/
@mixin output-color-helpers {
@each $color in map-keys($colors) {
#{'.h-color-text-' + $color} {
color: color($color);
}
#{'.h-color-bg-' + $color} {
background-color: color($color);
}
}
}