Skip to content

Commit

Permalink
Allow wrapping of address
Browse files Browse the repository at this point in the history
  • Loading branch information
darkwing committed Mar 15, 2023
1 parent 5fbe413 commit db53a0b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
8 changes: 7 additions & 1 deletion ui/components/multichain/address-copy-button/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ import { shortenAddress } from '../../../helpers/utils/util';
import Tooltip from '../../ui/tooltip/tooltip';
import { useI18nContext } from '../../../hooks/useI18nContext';

export const AddressCopyButton = ({ address, shorten = false }) => {
export const AddressCopyButton = ({
address,
shorten = false,
wrap = false,
}) => {
const displayAddress = shorten ? shortenAddress(address) : address;
const [copied, handleCopy] = useCopyToClipboard();
const t = useI18nContext();
Expand All @@ -33,6 +37,7 @@ export const AddressCopyButton = ({ address, shorten = false }) => {
variant={TextVariant.bodyXs}
color={TextColor.primaryDefault}
data-testid="address-copy-button-text"
style={wrap ? { wordBreak: 'break-word' } : {}}
>
{displayAddress}
</Text>
Expand All @@ -49,4 +54,5 @@ export const AddressCopyButton = ({ address, shorten = false }) => {
AddressCopyButton.propTypes = {
address: PropTypes.string.isRequired,
shorten: PropTypes.bool,
wrap: PropTypes.bool,
};
10 changes: 10 additions & 0 deletions ui/components/multichain/address-copy-button/index.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ export default {
shorten: {
control: 'boolean',
},
wrap: {
control: 'boolean',
},
},
args: {
address: '0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc',
Expand All @@ -22,3 +25,10 @@ DefaultStory.storyName = 'Default';

export const ShortenedStory = (args) => <AddressCopyButton shorten {...args} />;
ShortenedStory.storyName = 'Shortened';

export const WrappedStory = (args) => (
<div style={{ width: '200px' }}>
<AddressCopyButton wrap {...args} />
</div>
);
WrappedStory.storyName = 'Wrapped';

0 comments on commit db53a0b

Please sign in to comment.