From 35c1eaa2bd408838b3d9406ff3db9ada96ca644c Mon Sep 17 00:00:00 2001 From: VSaric <92527393+VSaric@users.noreply.github.com> Date: Mon, 29 Nov 2021 20:35:56 +0100 Subject: [PATCH] Created a Nickname popover (#12632) * Created a Nickname popover * Fixing lines in index.scss * Handle copy button and fix some paddings * Added text to be editable in the storybook component * Simplify nickname scss and html * Delete harcoded address * Change color usage with new color system --- app/_locales/en/messages.json | 3 + ui/components/ui/nickname-popover/index.js | 1 + ui/components/ui/nickname-popover/index.scss | 67 +++++++++++++++++++ .../nickname-popover.component.js | 67 +++++++++++++++++++ .../nickname-popover.stories.js | 32 +++++++++ ui/components/ui/ui-components.scss | 1 + 6 files changed, 171 insertions(+) create mode 100644 ui/components/ui/nickname-popover/index.js create mode 100644 ui/components/ui/nickname-popover/index.scss create mode 100644 ui/components/ui/nickname-popover/nickname-popover.component.js create mode 100644 ui/components/ui/nickname-popover/nickname-popover.stories.js diff --git a/app/_locales/en/messages.json b/app/_locales/en/messages.json index b33f198a4..ef61ac4c6 100644 --- a/app/_locales/en/messages.json +++ b/app/_locales/en/messages.json @@ -3223,6 +3223,9 @@ "viewMore": { "message": "View More" }, + "viewOnBlockExplorer": { + "message": "View on block explorer" + }, "viewOnCustomBlockExplorer": { "message": "View $1 at $2", "description": "$1 is the action type. e.g (Account, Transaction, Swap) and $2 is the Custom Block Exporer URL" diff --git a/ui/components/ui/nickname-popover/index.js b/ui/components/ui/nickname-popover/index.js new file mode 100644 index 000000000..f5303aa1e --- /dev/null +++ b/ui/components/ui/nickname-popover/index.js @@ -0,0 +1 @@ +export { default } from './nickname-popover.component'; diff --git a/ui/components/ui/nickname-popover/index.scss b/ui/components/ui/nickname-popover/index.scss new file mode 100644 index 000000000..39fae062d --- /dev/null +++ b/ui/components/ui/nickname-popover/index.scss @@ -0,0 +1,67 @@ +.nickname-popover { + &__popover-wrap { + height: 232px; + border-radius: 8px; + background: $ui-white; + display: flex; + justify-content: center; + + .popover-header { + padding: 16px 16px 0 0; + } + + .popover-content { + margin-top: -15px; + align-items: center; + } + } + + &__address { + @include H4; + + font-weight: bold; + display: flex; + align-items: center; + color: $Black-100; + padding-top: 8px; + } + + &__public-address { + @include H7; + + display: flex; + flex-direction: row; + align-items: center; + min-height: 25px; + background: $Grey-000; + border-radius: 40px; + padding-left: 8px; + padding-right: 2px; + margin-top: 8px; + + button { + background: none; + } + + &__constant { + @include H8; + + color: $Grey-500; + } + } + + &__view-on-block-explorer { + @include H7; + + color: $primary-1; + margin-top: 12px; + } + + &__footer-button { + margin-top: 16px; + width: 152px; + height: 40px; + border-radius: 100px; + background: $primary-1; + } +} diff --git a/ui/components/ui/nickname-popover/nickname-popover.component.js b/ui/components/ui/nickname-popover/nickname-popover.component.js new file mode 100644 index 000000000..106df9fed --- /dev/null +++ b/ui/components/ui/nickname-popover/nickname-popover.component.js @@ -0,0 +1,67 @@ +import React, { useCallback, useContext } from 'react'; +import PropTypes from 'prop-types'; +import { I18nContext } from '../../../contexts/i18n'; +import Popover from '../popover'; +import Button from '../button'; +import Identicon from '../identicon/identicon.component'; +import { shortenAddress } from '../../../helpers/utils/util'; +import CopyIcon from '../icon/copy-icon.component'; +import { useCopyToClipboard } from '../../../hooks/useCopyToClipboard'; + +const NicknamePopover = ({ address, onClose = null, onAdd = null }) => { + const t = useContext(I18nContext); + + const onAddClick = useCallback(() => { + onAdd(address); + onClose(); + }, [address, onClose, onAdd]); + + const [copied, handleCopy] = useCopyToClipboard(); + + return ( +