Repository navigation
Expand file tree
/
Copy paththeme-colors.js
More file actions
97 lines (89 loc) · 2.3 KB
/
Copy paththeme-colors.js
File metadata and controls
97 lines (89 loc) · 2.3 KB
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
94
95
96
97
// export let bg = "#323437";
// export let main = "#e2b714";
// export let caret = "#e2b714";
// export let sub = "#646669";
// export let text = "#d1d0c5";
// export let error = "#ca4754";
// export let errorExtra = "#7e2a33";
// export let colorfulError = "#ca4754";
// export let colorfulErrorExtra = "#7e2a33";
let colors = {
bg: "#323437",
main: "#e2b714",
caret: "#e2b714",
sub: "#646669",
text: "#d1d0c5",
error: "#ca4754",
errorExtra: "#7e2a33",
colorfulError: "#ca4754",
colorfulErrorExtra: "#7e2a33",
};
export async function get(color) {
let ret;
if (color === undefined) {
ret = colors;
} else {
ret = colors[color];
}
return ret;
// return check();
// async function run() {
// return new Promise(function (resolve, reject) {
// window.setTimeout(() => {
// update();
// if (color === undefined) {
// ret = colors;
// } else {
// ret = colors[color];
// }
// resolve(check());
// }, 250);
// });
// }
// async function check() {
// if (color === undefined) {
// if (ret.bg === "") {
// return await run();
// } else {
// return ret;
// }
// } else {
// if (ret === "") {
// return await run();
// } else {
// return ret;
// }
// }
// }
}
export function reset() {
colors = {
bg: "",
main: "",
caret: "",
sub: "",
text: "",
error: "",
errorExtra: "",
colorfulError: "",
colorfulErrorExtra: "",
};
}
export function update() {
let st = getComputedStyle(document.body);
colors.bg = st.getPropertyValue("--bg-color").replace(" ", "");
colors.main = st.getPropertyValue("--main-color").replace(" ", "");
colors.caret = st.getPropertyValue("--caret-color").replace(" ", "");
colors.sub = st.getPropertyValue("--sub-color").replace(" ", "");
colors.text = st.getPropertyValue("--text-color").replace(" ", "");
colors.error = st.getPropertyValue("--error-color").replace(" ", "");
colors.errorExtra = st
.getPropertyValue("--error-extra-color")
.replace(" ", "");
colors.colorfulError = st
.getPropertyValue("--colorful-error-color")
.replace(" ", "");
colors.colorfulErrorExtra = st
.getPropertyValue("--colorful-error-extra-color")
.replace(" ", "");
}