-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_colors.scss
93 lines (87 loc) · 2.06 KB
/
_colors.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
86
87
88
89
90
91
92
93
// Configuration for generating css variables and stuff
// no-theme: Disables theme specific color generation
// theme-override: For setting custom color rather than default generated theme color
// static: For disabling interactive colors
// @property [name: string]: { value: string, no-theme?: bool, theme-override?: { [theme]: string }, static?: bool }
$_colors: (
'lime': (
value: #86cd74,
no-theme: true,
),
'cactus': (
value: #3f573d,
no-theme: true,
),
'red': (
value: #ff5552,
no-theme: true,
),
'yellow': (
value: #ffbe42,
no-theme: true,
),
'disabled': (
value: #cacaca,
no-action: true,
no-theme: true,
),
'white': (
value: #ffffff,
),
'gray': (
value: #65676b,
),
'darkviolet': (
value: #272532,
),
'charcoal': (
value: #191820,
),
);
// For looping to generate stuff
$colors: map-keys($_colors);
$_modifiers: (
hover: h,
active: a,
);
// For generating the tag itself
@function css-var($color, $modifier: null) {
$var: --c_#{$color};
@if $modifier and map-has-key($_modifiers, $modifier) {
$var: $var + '-' + map-get($_modifiers, $modifier);
}
@return $var;
}
// Convert hex to raw
@function _hex-to-raw($color) {
@return #{red($color)}, #{green($color)}, #{blue($color)};
}
// Getting css variable based on params
@function css-color($color, $modifier: null, $opacity: 1, $raw: false) {
@if $raw {
@return rgba(var(#{$color}), $opacity);
} @else {
@return rgba(var(#{css-var($color, $modifier)}), $opacity);
}
}
// For creating core css color variables
@mixin init {
:root {
@each $color, $config in $_colors {
$value: map-get($config, value);
#{css-var($color)}: _hex-to-raw($value);
}
}
}
// For creating deferred css
@mixin deferInit {
:root {
@each $color, $config in $_colors {
@if not map-get($config, no-action) {
$value: map-get($config, value);
#{css-var($color, hover)}: _hex-to-raw(darken($value, 6%));
#{css-var($color, active)}: _hex-to-raw(darken($value, 10%));
}
}
}
}