-
Notifications
You must be signed in to change notification settings - Fork 420
/
Copy pathgraph-color.js
88 lines (83 loc) · 1.75 KB
/
graph-color.js
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
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// @flow
import {
BLUE_50,
BLUE_60,
GREEN_50,
GREEN_60,
GREY_50,
GREY_60,
INK_50,
INK_60,
MAGENTA_50,
MAGENTA_60,
ORANGE_50,
ORANGE_60,
PURPLE_50,
PURPLE_60,
RED_50,
RED_60,
TEAL_50,
TEAL_60,
YELLOW_50,
YELLOW_60,
} from 'photon-colors';
import type { GraphColor } from 'firefox-profiler/types';
export function getStrokeColor(color: GraphColor) {
switch (color) {
case 'magenta':
return MAGENTA_50;
case 'purple':
return PURPLE_50;
case 'blue':
return BLUE_50;
case 'teal':
return TEAL_50;
case 'green':
return GREEN_50;
case 'yellow':
return YELLOW_50;
case 'red':
return RED_50;
case 'orange':
return ORANGE_50;
case 'grey':
return GREY_50;
case 'ink':
return INK_50;
default:
throw new Error('Unexpected track color: ' + color);
}
}
export function getFillColor(color: GraphColor) {
// Same as stroke color with transparency.
return getStrokeColor(color) + '88';
}
export function getDotColor(color: GraphColor) {
switch (color) {
case 'magenta':
return MAGENTA_60;
case 'purple':
return PURPLE_60;
case 'blue':
return BLUE_60;
case 'teal':
return TEAL_60;
case 'green':
return GREEN_60;
case 'yellow':
return YELLOW_60;
case 'red':
return RED_60;
case 'orange':
return ORANGE_60;
case 'grey':
return GREY_60;
case 'ink':
return INK_60;
default:
throw new Error('Unexpected track color: ' + color);
}
}