diff --git a/packages/apps-config/README.md b/packages/apps-config/README.md index 4e8aa79da9..106e179eb3 100644 --- a/packages/apps-config/README.md +++ b/packages/apps-config/README.md @@ -33,6 +33,11 @@ There are 2 general areas of interest here - These are self-explanatory and config here actually does get used in other parts such as well. Basically the information here is broken down into a couple of catagories - -- chains - Specific logos when connecting to a specific chain -- nodes - Logos that are used when connecting to a specific runtime spec type (catch-all) -- named - These logos are used [settings](./settings) +- general + - color configuration based on chain +- identityIcon + - specific identityIcon to use based on node name +- logos + - chains - Specific logos when connecting to a specific chain + - nodes - Logos that are used when connecting to a specific runtime spec type (catch-all) + - named - These logos are used [settings](./settings) diff --git a/packages/apps-config/src/ui/identityIcons/index.ts b/packages/apps-config/src/ui/identityIcons/index.ts new file mode 100644 index 0000000000..3d9d1b573e --- /dev/null +++ b/packages/apps-config/src/ui/identityIcons/index.ts @@ -0,0 +1,20 @@ +// Copyright 2017-2020 @polkadot/apps-config authors & contributors +// This software may be modified and distributed under the terms +// of the Apache-2.0 license. See the LICENSE file for details. + +// overrides based on the actual software node type +const identityNodes: Record = [ + ['edgeware-node', 'substrate'], + ['joystream-node', 'beachball'], + ['node-template', 'substrate'], + ['parity-polkadot', 'polkadot'], + ['polkadot-js', 'polkadot'], + ['substrate-node', 'substrate'] +].reduce((icons, [spec, icon]): Record => ({ + ...icons, + [spec.toLowerCase().replace(/-/g, ' ')]: icon +}), {}); + +export { + identityNodes +}; diff --git a/packages/react-components/src/IdentityIcon.tsx b/packages/react-components/src/IdentityIcon.tsx index 09302fcb08..dd007a59a1 100644 --- a/packages/react-components/src/IdentityIcon.tsx +++ b/packages/react-components/src/IdentityIcon.tsx @@ -6,6 +6,7 @@ import { DeriveAccountInfo } from '@polkadot/api-derive/types'; import { IdentityProps as Props } from '@polkadot/react-identicon/types'; import React, { useContext, useEffect, useState } from 'react'; +import { identityNodes } from '@polkadot/apps-config/ui/identityIcons'; import { useApi, useCall } from '@polkadot/react-hooks'; import BaseIdentityIcon from '@polkadot/react-identicon'; import uiSettings from '@polkadot/ui-settings'; @@ -14,18 +15,8 @@ import { ValidatorsContext } from '@polkadot/react-query'; import StatusContext from './Status/Context'; import { useTranslation } from './translate'; -// overrides based on the actual software node type -const NODES: Record = { - 'edgeware-node': 'substrate', - 'joystream-node': 'beachball', - 'node-template': 'substrate', - 'parity-polkadot': 'polkadot', - 'polkadot-js': 'polkadot', - 'substrate-node': 'substrate' -}; - export function getIdentityTheme (systemName: string): 'empty' { - return ((uiSettings.icon === 'default' && NODES[systemName]) || uiSettings.icon) as 'empty'; + return ((uiSettings.icon === 'default' && identityNodes[systemName.toLowerCase().replace(/-/g, ' ')]) || uiSettings.icon) as 'empty'; } export default function IdentityIcon ({ className, onCopy, prefix, size, style, theme, value }: Props): React.ReactElement {