diff --git a/packages/react-components/src/Call.tsx b/packages/react-components/src/Call.tsx index 0449671d64..e9e10198a5 100644 --- a/packages/react-components/src/Call.tsx +++ b/packages/react-components/src/Call.tsx @@ -78,6 +78,7 @@ function Call ({ children, className = '', labelHash, mortality, onError, tip, v ('extrinsic hash')} + withCopy > {hash.toHex()} @@ -117,8 +118,8 @@ export default React.memo(styled(Call)` .ui--Labelled { padding-left: 0; - label { - left: 1.55rem; + > label { + left: 1.55rem !important; } } } diff --git a/packages/react-components/src/CopyButton.tsx b/packages/react-components/src/CopyButton.tsx index 9eea5f54f4..385f378f75 100644 --- a/packages/react-components/src/CopyButton.tsx +++ b/packages/react-components/src/CopyButton.tsx @@ -22,7 +22,7 @@ interface Props { const NOOP = () => undefined; -function CopyButton ({ children, className, icon = 'copy', type, value }: Props): React.ReactElement { +function CopyButton ({ children, className = '', icon = 'copy', type, value }: Props): React.ReactElement { const { t } = useTranslation(); const { queueAction } = useContext(StatusContext); @@ -39,7 +39,7 @@ function CopyButton ({ children, className, icon = 'copy', type, value }: Props) ); return ( -
+
- ) - : 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} /> );