ghost-portal/packages/apps-config/src/ui/index.ts
Jaco Greeff ce0ac32f01
Make colors file explicit (#3721)
* Make colors file explicit

* Remove empty defaultColor
2020-09-19 10:13:46 +02:00

19 lines
759 B
TypeScript

// Copyright 2017-2020 @polkadot/apps-config authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { chainColors, nodeColors } from './colors';
import { identityNodes } from './identityIcons';
function sanitize (value?: string): string {
return value?.toLowerCase().replace('-', ' ') || '';
}
export function getSystemIcon (systemName: string): 'beachball' | 'polkadot' | 'substrate' {
return (identityNodes[systemName.toLowerCase().replace(/-/g, ' ')] || 'substrate') as 'substrate';
}
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)];
}