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
|
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
export const SHADE = Object.freeze({
APP_BACKGROUND: 0,
SUBTLE_BACKGROUND: 1,
UI_ELEMENT_BACKGROUND: 2,
HOVERED_ELEMENT_BACKGROUND: 3,
SUBTLE_BORDER_AND_SEPARATOR: 4,
UI_ELEMENT_BORDER_AND_FOCUS: 5,
SOLID_BACKGROUND: 6,
HOVERED_SOLID_BACKGROUND: 7,
LOW_CONTRAST_TEXT: 8,
HIGH_CONTRAST_TEXT: 9,
});
export class Colors {
constructor(theme) {
this.theme = theme;
this.themeColor = theme.colors['blue'];
}
getAppBackground() {
return this.themeColor[SHADE.APP_BACKGROUND];
}
getSubtleBackground() {
return this.themeColor[SHADE.SUBTLE_BACKGROUND];
}
getUiElementBackground() {
return this.themeColor[SHADE.UI_ELEMENT_BACKGROUND];
}
getHoveredUiElementBackground() {
return this.themeColor[SHADE.HOVERED_ELEMENT_BACKGROUND];
}
getSubtleBorderAndSeparator() {
return this.themeColor[SHADE.SUBTLE_BORDER_AND_SEPARATOR];
}
getUiElementBorderAndFocus() {
return this.themeColor[SHADE.UI_ELEMENT_BORDER_AND_FOCUS];
}
getSolidBackground(color) {
return this.theme.fn.themeColor(color, SHADE.SOLID_BACKGROUND);
}
getHoveredSolidBackground(color) {
return this.theme.fn.themeColor(color, SHADE.HOVERED_SOLID_BACKGROUND);
}
getLowContrastText() {
return this.theme.colors.gray[SHADE.LOW_CONTRAST_TEXT];
}
getHighContrastText() {
return this.theme.colors.gray[SHADE.HIGH_CONTRAST_TEXT];
}
getText(color, variant) {
return color === 'dimmed'
? this.theme.fn.themeColor('gray', SHADE.SOLID_BACKGROUND)
: color in this.theme.colors
? this.theme.fn.themeColor(color, SHADE.LOW_CONTRAST_TEXT)
: variant === 'link'
? this.theme.fn.themeColor(color, SHADE.SOLID_BACKGROUND)
: color || 'inherit';
}
}
|