+
- )
- : null
- }
+ {withCopy && (
+
+ )}
);
}
diff --git a/packages/react-components/src/Static.tsx b/packages/react-components/src/Static.tsx
index 584d7644c9..8a854266dc 100644
--- a/packages/react-components/src/Static.tsx
+++ b/packages/react-components/src/Static.tsx
@@ -3,6 +3,7 @@
import React from 'react';
+import CopyButton from './CopyButton';
import Labelled from './Labelled';
interface Props {
@@ -17,10 +18,11 @@ interface Props {
isSmall?: boolean;
label?: React.ReactNode;
value?: React.ReactNode;
+ withCopy?: boolean;
withLabel?: boolean;
}
-function Static ({ children, className = '', defaultValue, help, isFull, isHidden, isSmall, label, value, withLabel }: Props): React.ReactElement
{
+function Static ({ children, className = '', defaultValue, help, isFull, isHidden, isSmall, label, value, withCopy, withLabel }: Props): React.ReactElement {
return (
+ {withCopy && (
+
+ )}
);
}
diff --git a/packages/react-components/src/styles/components.ts b/packages/react-components/src/styles/components.ts
index af0401df34..553f828791 100644
--- a/packages/react-components/src/styles/components.ts
+++ b/packages/react-components/src/styles/components.ts
@@ -24,12 +24,6 @@ export default (theme: ThemeDef): string => `
&.monospace {
font-family: monospace;
}
-
- .ui--output-button {
- position: absolute;
- top: 0.25rem;
- right: 0.25rem;
- }
}
header .ui--Button-Group {
diff --git a/packages/react-params/src/Param/BaseBytes.tsx b/packages/react-params/src/Param/BaseBytes.tsx
index b2b6f445d6..7ce06c383d 100644
--- a/packages/react-params/src/Param/BaseBytes.tsx
+++ b/packages/react-params/src/Param/BaseBytes.tsx
@@ -5,7 +5,7 @@ import type { TypeDef } from '@polkadot/types/types';
import type { RawParam, RawParamOnChange, RawParamOnEnter, RawParamOnEscape, Size } from '../types';
import React, { useCallback, useState } from 'react';
-import { Input } from '@polkadot/react-components';
+import { CopyButton, Input } from '@polkadot/react-components';
import { compactAddLength, hexToU8a, isAscii, isHex, isU8a, stringToU8a, u8aToHex, u8aToString } from '@polkadot/util';
import { decodeAddress } from '@polkadot/util-crypto';
@@ -28,6 +28,7 @@ interface Props {
size?: Size;
type: TypeDef & { withOptionActive?: boolean };
validate?: (u8a: Uint8Array) => boolean;
+ withCopy?: boolean;
withLabel?: boolean;
withLength?: boolean;
}
@@ -58,7 +59,7 @@ function convertInput (value: string): [boolean, Uint8Array] {
: [value === '0x', new Uint8Array([])];
}
-function BaseBytes ({ asHex, children, className = '', defaultValue: { value }, isDisabled, isError, label, length = -1, onChange, onEnter, onEscape, size = 'full', validate = defaultValidate, withLabel, withLength }: Props): React.ReactElement {
+function BaseBytes ({ asHex, children, className = '', defaultValue: { value }, isDisabled, isError, label, length = -1, onChange, onEnter, onEscape, size = 'full', validate = defaultValidate, withCopy, withLabel, withLength }: Props): React.ReactElement {
const { t } = useTranslation();
const [defaultValue] = useState(
value
@@ -115,6 +116,9 @@ function BaseBytes ({ asHex, children, className = '', defaultValue: { value },
withLabel={withLabel}
>
{children}
+ {withCopy && (
+
+ )}
);
diff --git a/packages/react-params/src/Param/Hash160.tsx b/packages/react-params/src/Param/Hash160.tsx
index f2f3bd6942..fdd1ea048b 100644
--- a/packages/react-params/src/Param/Hash160.tsx
+++ b/packages/react-params/src/Param/Hash160.tsx
@@ -21,6 +21,7 @@ function Hash160 ({ className = '', defaultValue, isDisabled, isError, label, na
onEnter={onEnter}
onEscape={onEscape}
type={type}
+ withCopy={isDisabled}
withLabel={withLabel}
/>
);
diff --git a/packages/react-params/src/Param/Hash256.tsx b/packages/react-params/src/Param/Hash256.tsx
index a63dd80c0e..5ebc370e21 100644
--- a/packages/react-params/src/Param/Hash256.tsx
+++ b/packages/react-params/src/Param/Hash256.tsx
@@ -21,6 +21,7 @@ function Hash256 ({ className = '', defaultValue, isDisabled, isError, label, na
onEnter={onEnter}
onEscape={onEscape}
type={type}
+ withCopy={isDisabled}
withLabel={withLabel}
/>
);
diff --git a/packages/react-params/src/Param/Hash512.tsx b/packages/react-params/src/Param/Hash512.tsx
index 93cbf36a94..781678705d 100644
--- a/packages/react-params/src/Param/Hash512.tsx
+++ b/packages/react-params/src/Param/Hash512.tsx
@@ -21,6 +21,7 @@ function Hash512 ({ className = '', defaultValue, isDisabled, isError, label, na
onEnter={onEnter}
onEscape={onEscape}
type={type}
+ withCopy={isDisabled}
withLabel={withLabel}
/>
);