index.ts 853 B

12345678910111213141516171819
  1. // Copyright 2017-2020 @polkadot/apps-config authors & contributors
  2. // This software may be modified and distributed under the terms
  3. // of the Apache-2.0 license. See the LICENSE file for details.
  4. import { chainColors, nodeColors } from './general';
  5. import { identityNodes } from './identityIcons';
  6. function sanitize (value?: string): string {
  7. return value?.toLowerCase().replace('-', ' ') || '';
  8. }
  9. export function getSystemIcon (systemName: string): 'beachball' | 'polkadot' | 'substrate' {
  10. return (identityNodes[systemName.toLowerCase().replace(/-/g, ' ')] || 'substrate') as 'substrate';
  11. }
  12. export const getSystemChainColor = (systemChain: string, systemName: string): string | undefined => {
  13. // eslint-disable-next-line @typescript-eslint/no-unsafe-return
  14. return chainColors[sanitize(systemChain)] || nodeColors[sanitize(systemName)];
  15. };