From 7429414fb6d316dcbf4c3559397e772f2673e3c9 Mon Sep 17 00:00:00 2001 From: Gilles Barnier Date: Mon, 4 Apr 2022 10:05:13 +0200 Subject: [PATCH] Add "Copy" icon to the User Sidebar (#7235) * PR 7209 fixes * Update packages/page-accounts/src/Sidebar/AddressSection.tsx Co-authored-by: Jaco * Update packages/page-accounts/src/Sidebar/AddressSection.tsx Co-authored-by: Jaco * Update packages/page-accounts/src/Sidebar/AddressSection.tsx Co-authored-by: Jaco * Update packages/page-accounts/src/Sidebar/AddressSection.tsx Co-authored-by: Jaco * corrections on PR 7209 * corrections on PR 7209 * fixed based on Jegor s comments * replaced donothing with NOOP function Co-authored-by: Jaco --- .../src/Sidebar/AddressSection.tsx | 27 ++++++++++++++++++- .../page-accounts/src/Sidebar/Sidebar.tsx | 26 +++++++++++++++++- 2 files changed, 51 insertions(+), 2 deletions(-) diff --git a/packages/page-accounts/src/Sidebar/AddressSection.tsx b/packages/page-accounts/src/Sidebar/AddressSection.tsx index 18506b495f..57b1001c1e 100644 --- a/packages/page-accounts/src/Sidebar/AddressSection.tsx +++ b/packages/page-accounts/src/Sidebar/AddressSection.tsx @@ -2,8 +2,10 @@ // SPDX-License-Identifier: Apache-2.0 import React from 'react'; +import { CopyToClipboard } from 'react-copy-to-clipboard'; -import { AccountName, IdentityIcon, Input } from '@polkadot/react-components'; +import { AccountName, Button, IdentityIcon, Input } from '@polkadot/react-components'; +import { useToggle } from '@polkadot/react-hooks'; import { AddressFlags } from '@polkadot/react-hooks/types'; import { useTranslation } from '../translate'; @@ -19,6 +21,8 @@ interface Props { function AddressSection ({ accountIndex, defaultValue, editingName, flags, onChange, value }: Props): React.ReactElement { const { t } = useTranslation(); + const [isCopyShown, toggleIsCopyShown] = useToggle(); + const NOOP = () => undefined; return (
@@ -46,15 +50,36 @@ function AddressSection ({ accountIndex, defaultValue, editingName, flags, onCha value={value} withSidebar={false} /> +
{value}
+ {accountIndex && (
{accountIndex}
)}
+ +
+
+ + + +
+
); } diff --git a/packages/page-accounts/src/Sidebar/Sidebar.tsx b/packages/page-accounts/src/Sidebar/Sidebar.tsx index 8f6d9c5834..c437bf288c 100644 --- a/packages/page-accounts/src/Sidebar/Sidebar.tsx +++ b/packages/page-accounts/src/Sidebar/Sidebar.tsx @@ -110,6 +110,15 @@ export default React.memo(styled(FullSidebar)` overflow: hidden; } } + + .ui--AddressSection__CopyColumn { + margin-left: 1rem; + + .ui--AccountName { + max-width: 10rem; + overflow: hidden; + } + } } .ui--AddressMenu-addr, @@ -121,11 +130,26 @@ export default React.memo(styled(FullSidebar)` .ui--AddressMenu-addr { word-break: break-all; - width: 26ch; + width: 24ch; margin: 0.571rem 0; color: var(--color-label); } + .ui--AddressMenu-copyaddr, + .ui--AddressMenu-index { + font: var(--font-mono); + text-align: left; + font-size: 0.857rem; + } + + .ui--AddressMenu-copyaaddr { + word-break: break-all; + width: 12ch; + margin: 0.371rem 0; + color: var(--color-label); + } + + .ui--AddressMenu-index { display: flex; flex-direction: row;