Move identity icon overrides to apps-config (#2366)
* Move identity icon overrides to apps-config * Rename to identityNodes
This commit is contained in:
parent
d81c8c8a34
commit
1c8f74732a
@ -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)
|
||||
|
||||
20
packages/apps-config/src/ui/identityIcons/index.ts
Normal file
20
packages/apps-config/src/ui/identityIcons/index.ts
Normal file
@ -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<string, string> = [
|
||||
['edgeware-node', 'substrate'],
|
||||
['joystream-node', 'beachball'],
|
||||
['node-template', 'substrate'],
|
||||
['parity-polkadot', 'polkadot'],
|
||||
['polkadot-js', 'polkadot'],
|
||||
['substrate-node', 'substrate']
|
||||
].reduce((icons, [spec, icon]): Record<string, string> => ({
|
||||
...icons,
|
||||
[spec.toLowerCase().replace(/-/g, ' ')]: icon
|
||||
}), {});
|
||||
|
||||
export {
|
||||
identityNodes
|
||||
};
|
||||
@ -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<string, string> = {
|
||||
'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<Props> {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user