1 |
|
2 | import { category } from './swu-structure';
|
3 | import { parse } from './swu-parse';
|
4 | import { swu2code } from '../convert';
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 | const colors = ['#0000CC', '#CC0000', '#FF0099', '#006600', '#000000', '#884411', '#FF9900'];
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 | const colorize = (swuSym) => {
|
24 | const parsed = parse.symbol(swuSym);
|
25 | let color = '#000000';
|
26 | if (parsed.symbol) {
|
27 | const code = swu2code(parsed.symbol);
|
28 | const index = category.findIndex((val) => val > code);
|
29 | color = colors[(index < 0 ? 6 : index - 1)];
|
30 | }
|
31 | return color;
|
32 | }
|
33 |
|
34 | export { colors, colorize }
|