mirror of
https://github.com/pezkuwichain/pwap.git
synced 2026-08-02 19:25:41 +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
1.9 KiB
TypeScript
78 lines
1.9 KiB
TypeScript
// Copyright 2017-2026 @pezkuwi/react-components authors & contributors
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
import type { IconName } from '@fortawesome/fontawesome-svg-core';
|
|
|
|
import React, { useCallback } from 'react';
|
|
import CopyToClipboard from 'react-copy-to-clipboard';
|
|
|
|
import { useQueue } from '@pezkuwi/react-hooks';
|
|
import { isString } from '@pezkuwi/util';
|
|
|
|
import Button from './Button/index.js';
|
|
import { styled } from './styled.js';
|
|
import { useTranslation } from './translate.js';
|
|
|
|
interface Props {
|
|
children?: React.ReactNode;
|
|
className?: string;
|
|
icon?: IconName;
|
|
label?: React.ReactNode;
|
|
type?: string;
|
|
isMnemonic?: boolean;
|
|
value?: React.ReactNode | null;
|
|
}
|
|
|
|
const NOOP = () => undefined;
|
|
|
|
function CopyButton ({ children, className = '', icon = 'copy', label, type, value }: Props): React.ReactElement<Props> | null {
|
|
const { t } = useTranslation();
|
|
const { queueAction } = useQueue();
|
|
|
|
const _onCopy = useCallback(
|
|
(): void => {
|
|
queueAction && queueAction({
|
|
action: t('clipboard'),
|
|
message: t('{{type}} copied', { replace: { type: type || t('value') } }),
|
|
status: 'queued'
|
|
});
|
|
},
|
|
[type, queueAction, t]
|
|
);
|
|
|
|
if (!isString(value)) {
|
|
return null;
|
|
}
|
|
|
|
return (
|
|
<StyledDiv className={`${className} ui--CopyButton`}>
|
|
{/* @ts-expect-error React 18 type compatibility */}
|
|
<CopyToClipboard
|
|
onCopy={_onCopy}
|
|
text={value as string}
|
|
>
|
|
<div className='copyContainer'>
|
|
{children}
|
|
<span className='copySpan'>
|
|
<Button
|
|
className='icon-button show-on-hover'
|
|
icon={icon}
|
|
isDisabled={!value}
|
|
label={label}
|
|
onClick={NOOP}
|
|
/>
|
|
</span>
|
|
</div>
|
|
</CopyToClipboard>
|
|
</StyledDiv>
|
|
);
|
|
}
|
|
|
|
const StyledDiv = styled.div`
|
|
.copySpan {
|
|
white-space: nowrap;
|
|
}
|
|
`;
|
|
|
|
export default React.memo(CopyButton);
|