-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathPickButtonStyle.ts
More file actions
70 lines (60 loc) · 2.47 KB
/
PickButtonStyle.ts
File metadata and controls
70 lines (60 loc) · 2.47 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
import { themeStore } from "./store/ThemeStore";
const colorStyles = [
{ background: "#4589ff", color: "white" }, // blue
{ background: "#198038", color: "white" }, // green
{ background: "#a2191f", color: "white" }, // red
{ background: "#d2a106", color: "black" }, // yellow
{ background: "#8a3ffc", color: "white" }, // violet
{ background: '#f58231', color: "white" },
{ background: '#42d4f4', color: "black" },
{ background: '#911eb4', color: "white" },
{ background: '#f032e6', color: "white" },
{ background: '#a9a9a9', color: "black" },
{ background: '#ff0000', color: "white" }, // dark red
{ background: '#9A6324', color: "white" },
{ background: '#808000', color: "white" },
{ background: '#469990', color: "white" },
{ background: '#1f45fc', color: "white" }, // dark blue
//{ background: '#000000', color: "white" },
{ background: '#fabed4', color: "black" },
{ background: '#ffd8b1', color: "black" },
{ background: '#fffac8', color: "black" },
{ background: '#aaffc3', color: "black" },
{ background: '#dcbeff', color: "black" },
{ background: '#bfef45', color: "black" },
];
let labelIndex = 0;
let appNameIndex = 0;
const styleMap: { [key: string]: { background: string, color: string, lightColor: string, filter: string } } = {};
export function pickCategoryKindStyle(name: string): { background: string, color: string, filter: string } {
return pickStyle(name, 'app');
}
export function pickLabelStyle(name: string): { background: string, color: string, filter: string } {
return pickStyle(name, 'label');
}
function pickStyle(name: string, type: 'app' | 'label'): { background: string, color: string, filter: string } {
let style = styleMap[name];
if (style === undefined) {
//console.log(index, name)
style = { background: '', color: '', lightColor: '', filter: '' };
let index = type === 'app' ? appNameIndex : labelIndex;
const s = colorStyles[index];
style.background = s.background;
style.lightColor = s.color;
styleMap[name] = style;
++index;
if (index === colorStyles.length) index = 0;
if (type === 'app') {
appNameIndex = index;
} else {
labelIndex = index;
}
}
if (themeStore.getTheme() === 'dark') {
style.color = style.lightColor;
style.filter = 'grayscale(60%)';
} else {
style.color = style.lightColor;
}
return style;
}