This repository has been archived by the owner on Apr 19, 2023. It is now read-only.
forked from kodadot/nft-gallery
-
Notifications
You must be signed in to change notification settings - Fork 0
/
colors.ts
183 lines (169 loc) · 6.15 KB
/
colors.ts
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
// Copyright 2017-2021 @polkadot/apps-config authors & contributors
// SPDX-License-Identifier: Apache-2.0
// The mapping here is done on the actual chain name (system.chain RPC) or
// the actual RPC node it is corrected to (system.name RPC)
import Connector from '@vue-polkadot/vue-api';
// defaults
const emptyColor = '#99999';
// based on chain name
// alphabetical
const chainBitCountry = '#191a2e';
const chainCrab = '#7C30DD';
const chainCrust = '#ff8812';
const chainClover = 'linear-gradient(to right, #52ad75, #7cc773)';
const chainChainx = '#F6C94A';
const chainDarwinia = 'linear-gradient(-45deg, #FE3876 0%, #7C30DD 71%, #3A30DD 100%)';
const chainHanonycash = '#0099CC';
const chainHydrate = '#000000';
const chainIntegritee = '#080808';
const chainKulupu = '#003366';
const chainPhala = '#a7e300';
const chainPlasm = '#2096F3';
const chainPolkabtc = '#510101';
const chainPolkadex = '#7C30DD';
const chainPolkadot = '#e6007a';
const chainKilt = '#8c175b';
const chainKusama = '#000000';
const chainRocco = '#6f36dc';
const chainRoccoAcala = '#173DC9';
const chainRoccoAres = '#70FF8B';
const chainRoccoBifrost = '#002cc3';
const chainRoccoDarwinia = 'linear-gradient(-45deg, #FE3876 0%, #7C30DD 71%, #3A30DD 100%)';
const chainRoccoDataHighway = '#000000';
const chainRococoLaminar = '#004FFF';
const chainRoccoTick = '#22bb22';
const chainRoccoTrack = '#bb2222';
const chainRoccoTrick = '#2222bb';
const chainWestend = '#da68a7';
const chainGalois = '#000000';
const chainZero = '#000000';
const chainZenlink = 'linear-gradient(45deg, #F20082 0%, #FF4D4D 100%)';
const chainJupiter = '#7143ff';
const chainUniarts = '#b39ef7';
const chainIdavoll = '#ff43ff';
const chainSubDAO = 'linear-gradient(50deg, #F20092 0%, #FF4D5D 100%)';
// based on node name
// alphabetical
const nodeBitCountry = '#191a2e';
const nodeBifrost = '#002cc3';
const nodeCanvas = '#c77cff';
const nodeCentrifuge = '#fcc367';
const nodeEdgeware = '#0a95df';
const nodeEncointerNotee = '#cc0000';
const nodeEncointerTeeproxy = '#0000cc';
const nodeEquilibrium = '#1792ff';
const nodeJupiter = '#7143ff';
const nodeMoonbeam = '#53cbc9';
const nodeNodle = '#1ab394';
const nodePolkadex = '#7C30DD';
const nodeSora = '#2D2926';
const nodeStafi = '#00F3AB';
const nodeSubDAO = 'linear-gradient(50deg, #F20092 0%, #FF4D5D 100%)';
const nodeTernoa = '#d622ff';
const nodeZero = '#0099cc';
const nodeZenlink = 'linear-gradient(45deg, #F20082 0%, #FF4D4D 100%)';
export { emptyColor };
// Alphabetical overrides based on the actual matched chain name
// NOTE: This is as retrieved via the system.chain RPC
export const chainColors: Record<string, any> = [
['acala mandala pc1', chainRoccoAcala],
['acala mandala pc2', chainRoccoAcala],
['Ares PC1', chainRoccoAres],
['Bit.Country Tewai Chain', chainBitCountry],
['Bifrost PC1', chainRoccoBifrost],
['Darwinia Crab', chainCrab],
['Clover', chainClover],
['crust maxwell', chainCrust],
['Crust PC1', chainCrust],
['ChainX', chainChainx],
['darwinia cc1', chainDarwinia],
['Darwinia PC2', chainRoccoDarwinia],
['DataHighway', chainRoccoDataHighway],
['Encointer PC1', nodeEncointerNotee],
['hanonycash', chainHanonycash],
['HydraDX Hydrate', chainHydrate],
['IntegriTEE PC1', chainIntegritee],
['Idavoll', chainIdavoll],
['Jupiter Testnet', chainJupiter],
['KILT Testnet', chainKilt],
['KILT Collator Rococo', chainKilt],
['Kulupu', chainKulupu],
['Kusama', chainKusama],
['Kusama CC1', chainKusama],
['Kusama CC2', chainKusama],
['Kusama CC3', chainKusama],
['laminar turbulence pc1', chainRococoLaminar],
['Moonbase Alpha', nodeMoonbeam],
['Phala poc 3', chainPhala],
['Phala PC1', chainPhala],
['Plasm', chainPlasm],
['Plasm PC2', chainPlasm],
['PolkaBTC', chainPolkabtc],
['PolkaBTC Staging', chainPolkabtc],
['Polkadex Testnet', chainPolkadex],
['Polkadot', chainPolkadot],
['Polkadot CC1', chainPolkadot],
['Rococo', chainRocco],
['Tick', chainRoccoTick],
['Track', chainRoccoTrack],
['Trick', chainRoccoTrick],
['Westend', chainWestend],
['Galois', chainGalois],
['ZΞRO Alphaville', chainZero],
['Zenlink PC1', chainZenlink],
['Uniarts', chainUniarts],
['SubDAO PC1', chainSubDAO]
].reduce((colors, [chain, color]): Record<string, any> => ({
...colors,
[chain.toLowerCase()]: color
}), {});
// Alphabetical overrides based on the actual software node type
// NOTE: This is as retrieved via the system.name RPC
export const nodeColors: Record<string, any> = [
['Bit.Country Node', nodeBitCountry],
['Bifrost Node', nodeBifrost],
['Canvas Node', nodeCanvas],
['centrifuge chain', nodeCentrifuge],
['Centrifuge Chain Node', nodeCentrifuge],
['edgeware node', nodeEdgeware],
['Encointer Node', nodeEncointerNotee],
['Encointer Node noTEE', nodeEncointerNotee],
['Encointer Node TEE proxy', nodeEncointerTeeproxy],
['Equilibrium node', nodeEquilibrium],
['Jupiter Node', nodeJupiter],
['nodle chain node', nodeNodle],
['Polkadex Node', nodePolkadex],
['SORA-staging Node', nodeSora],
['Stafi node', nodeStafi],
['SUBZΞRO', nodeZero],
['Ternoa Node', nodeTernoa],
['Zenlink Collator', nodeZenlink],
['SubDAO Collator', nodeSubDAO]
// ['node template', emptyColor],
// ['parity polkadot', emptyColor],
// ['substrate node', emptyColor]
].reduce((colors, [node, color]): Record<string, any> => ({
...colors,
[node.toLowerCase().replace(/-/g, ' ')]: color
}), {});
function sanitize (value?: string): string {
return value?.toLowerCase().replace('-', ' ') || '';
}
export function getSystemChainColor (systemChain: string, systemName: string): string | undefined {
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
return chainColors[sanitize(systemChain)] || nodeColors[sanitize(systemName)];
}
const kodaDotGreen = '#41b883'
let currentColor = kodaDotGreen;
export const getCurrentColor = () => currentColor
export const changeCurrentColor = async () => {
const { api } = Connector.getInstance()
try {
const chain = await api.rpc.system.chain();
const node = await api.rpc.system.name();
currentColor = getSystemChainColor(chain.toHuman(), node.toHuman()) || kodaDotGreen;
return currentColor;
} catch (e) {
console.warn('[COLORS] NO collor for this chain')
}
}