mirror of
https://github.com/pezkuwichain/pwap.git
synced 2026-07-26 18:55:40 +00:00
971df8edba
- Remove all 3rd party parachain configurations from endpoints: - productionRelayPolkadot.ts: Keep only system parachains - productionRelayDicle.ts: Keep only system parachains - testingRelayZagros.ts: Keep only system parachains - testingRelayTeyrChain.ts: Keep only system parachains - Update domain references: - polkadot.js.org → pezkuwichain.app - wiki.polkadot.network → wiki.pezkuwichain.io - dotapps.io → pezkuwichain.app - statement.polkadot.network → docs.pezkuwichain.io/statement - support.polkadot.network → docs.pezkuwichain.io - Update repository references: - github.com/pezkuwi-js/apps → github.com/pezkuwichain/pwap - Rename system parachains to Pezkuwi ecosystem: - PolkadotAssetHub → PezkuwiAssetHub - polkadotBridgeHub → pezkuwiBridgeHub - polkadotCollectives → pezkuwiCollectives - polkadotCoretime → pezkuwiCoretime - polkadotPeople → pezkuwiPeople - Update network name in claims utility: - Polkadot → Pezkuwi
78 lines
2.1 KiB
TypeScript
78 lines
2.1 KiB
TypeScript
// Copyright 2017-2026 @pezkuwi/apps authors & contributors
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
import type { IconName } from '@fortawesome/fontawesome-svg-core';
|
|
|
|
import React, { useMemo } from 'react';
|
|
|
|
import { createWsEndpoints } from '@pezkuwi/apps-config';
|
|
import { externalEmptySVG } from '@pezkuwi/apps-config/ui/logos/external';
|
|
import { useApi } from '@pezkuwi/react-hooks';
|
|
|
|
import Icon from './Icon.js';
|
|
import { styled } from './styled.js';
|
|
|
|
interface Props {
|
|
className?: string;
|
|
isInline?: boolean;
|
|
logo?: string;
|
|
onClick?: () => any;
|
|
withoutHl?: boolean;
|
|
}
|
|
|
|
const endpoints = createWsEndpoints(() => '');
|
|
|
|
function ChainImg ({ className = '', isInline, logo, onClick, withoutHl }: Props): React.ReactElement<Props> {
|
|
const { apiEndpoint } = useApi();
|
|
const [isEmpty, img, isFa] = useMemo((): [boolean, unknown, boolean] => {
|
|
const endpoint = endpoints.find((o) => o.info === logo);
|
|
const found = endpoint?.ui.logo || logo || apiEndpoint?.ui.logo;
|
|
const imgBase = found || externalEmptySVG;
|
|
const [isFa, img] = !imgBase || imgBase === 'empty' || !(imgBase.startsWith('data:') || imgBase.startsWith('fa;'))
|
|
? [false, externalEmptySVG]
|
|
: imgBase.startsWith('fa;')
|
|
? [true, imgBase.substring(3)]
|
|
: [false, imgBase];
|
|
|
|
return [!found || logo === 'empty', img, isFa];
|
|
}, [apiEndpoint, logo]);
|
|
|
|
const iconClassName = `${className} ui--ChainImg ${(isEmpty && !withoutHl) ? 'highlight--bg' : ''} ${isInline ? 'isInline' : ''}`;
|
|
|
|
return isFa
|
|
? (
|
|
<StyledIcon
|
|
className={iconClassName}
|
|
icon={img as IconName}
|
|
/>
|
|
)
|
|
: (
|
|
<StyledImg
|
|
alt='chain logo'
|
|
className={iconClassName}
|
|
onClick={onClick}
|
|
src={img as string}
|
|
/>
|
|
);
|
|
}
|
|
|
|
const STYLE = `
|
|
background: white;
|
|
border-radius: 50%;
|
|
box-sizing: border-box;
|
|
color: #333;
|
|
|
|
&.isInline {
|
|
display: inline-block;
|
|
height: 24px;
|
|
margin-right: 0.75rem;
|
|
vertical-align: middle;
|
|
width: 24px;
|
|
}
|
|
`;
|
|
|
|
const StyledIcon = styled(Icon)`${STYLE}`;
|
|
const StyledImg = styled.img`${STYLE}`;
|
|
|
|
export default React.memo(ChainImg);
|