-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Expand file tree
/
Copy pathutils.ts
More file actions
70 lines (59 loc) · 1.23 KB
/
utils.ts
File metadata and controls
70 lines (59 loc) · 1.23 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 color from 'color';
import type { InternalTheme } from 'src/types';
import type { black, white } from '@/styles/themes/v2/colors';
type BaseProps = {
defaultColor: typeof black | typeof white;
theme: InternalTheme;
};
export const getActiveTintColor = ({
activeColor,
defaultColor,
theme,
}: BaseProps & {
activeColor: string | undefined;
}) => {
if (typeof activeColor === 'string') {
return activeColor;
}
if (theme.isV3) {
return theme.colors.onSecondaryContainer;
}
return defaultColor;
};
export const getInactiveTintColor = ({
inactiveColor,
defaultColor,
theme,
}: BaseProps & {
inactiveColor: string | undefined;
}) => {
if (typeof inactiveColor === 'string') {
return inactiveColor;
}
if (theme.isV3) {
return theme.colors.onSurfaceVariant;
}
return color(defaultColor).alpha(0.5).rgb().string();
};
export const getLabelColor = ({
tintColor,
hasColor,
focused,
defaultColor,
theme,
}: BaseProps & {
tintColor: string;
hasColor: boolean;
focused: boolean;
}) => {
if (hasColor) {
return tintColor;
}
if (theme.isV3) {
if (focused) {
return theme.colors.onSurface;
}
return theme.colors.onSurfaceVariant;
}
return defaultColor;
};