From 1c7865cf65904b330e7898fd4a8c3d92d4b513ff Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Thu, 9 Jul 2020 13:40:46 +0200 Subject: [PATCH] Adjust Badge to inline default (as used) (#3150) * Adjust Badge to inline default (as used) * Default to isTooltip with hover set --- packages/apps/src/SideBar/Item.tsx | 1 - .../page-accounts/src/Accounts/Account.tsx | 6 --- .../src/Overview/Referendum.tsx | 2 - .../src/Overview/Parachain.tsx | 2 - packages/page-staking/src/MaxBadge.tsx | 1 - .../src/Overview/Address/Status.tsx | 9 +--- .../page-staking/src/Targets/Validator.tsx | 16 +------ packages/react-components/src/AccountName.tsx | 5 +-- packages/react-components/src/Badge.tsx | 43 +++---------------- 9 files changed, 10 insertions(+), 75 deletions(-) diff --git a/packages/apps/src/SideBar/Item.tsx b/packages/apps/src/SideBar/Item.tsx index b60e0843ce..5a222a952a 100644 --- a/packages/apps/src/SideBar/Item.tsx +++ b/packages/apps/src/SideBar/Item.tsx @@ -106,7 +106,6 @@ function Item ({ isCollapsed, onClick, route }: Props): React.ReactElement )} } icon='shield' - isInline - isTooltip /> )} {multiInfos && multiInfos.length !== 0 && ( @@ -251,8 +249,6 @@ function Account ({ account: { address, meta }, className = '', delegation, filt color='red' hover={t('Multisig approvals pending')} info={multiInfos.length} - isInline - isTooltip /> )} {isProxied && !proxyInfo.hasOwned && ( @@ -260,8 +256,6 @@ function Account ({ account: { address, meta }, className = '', delegation, filt color='red' hover={t('Proxied account has no owned proxies')} info='0' - isInline - isTooltip /> )} diff --git a/packages/page-democracy/src/Overview/Referendum.tsx b/packages/page-democracy/src/Overview/Referendum.tsx index b4d0f5399d..5940e72ed4 100644 --- a/packages/page-democracy/src/Overview/Referendum.tsx +++ b/packages/page-democracy/src/Overview/Referendum.tsx @@ -129,8 +129,6 @@ function Referendum ({ className = '', value: { allAye, allNay, image, imageHash : t('{{threshold}}, not passing', { replace: { threshold } }) } icon={isPassing ? 'check' : 'times'} - isInline - isTooltip /> )} diff --git a/packages/page-parachains/src/Overview/Parachain.tsx b/packages/page-parachains/src/Overview/Parachain.tsx index c8a7bf07bb..d83a81b3b1 100644 --- a/packages/page-parachains/src/Overview/Parachain.tsx +++ b/packages/page-parachains/src/Overview/Parachain.tsx @@ -50,7 +50,6 @@ function Parachain ({ className = '', parachain: { didUpdate, id, info, pendingS } isGray={!didUpdate} - isTooltip /> diff --git a/packages/page-staking/src/MaxBadge.tsx b/packages/page-staking/src/MaxBadge.tsx index 3a77c65ee0..d616060ff7 100644 --- a/packages/page-staking/src/MaxBadge.tsx +++ b/packages/page-staking/src/MaxBadge.tsx @@ -20,7 +20,6 @@ function MaxBadge ({ numNominators }: Props): React.ReactElement | null { ); } diff --git a/packages/page-staking/src/Overview/Address/Status.tsx b/packages/page-staking/src/Overview/Address/Status.tsx index 277f8759b9..2282cc1d71 100644 --- a/packages/page-staking/src/Overview/Address/Status.tsx +++ b/packages/page-staking/src/Overview/Address/Status.tsx @@ -22,21 +22,14 @@ function Status ({ isElected, numNominators, onlineCount, onlineMessage }: Props - ) - : ( - ) + : } {(!!onlineCount || onlineMessage) && ( } - isInline /> )} diff --git a/packages/page-staking/src/Targets/Validator.tsx b/packages/page-staking/src/Targets/Validator.tsx index 75c859765e..beb45cde41 100644 --- a/packages/page-staking/src/Targets/Validator.tsx +++ b/packages/page-staking/src/Targets/Validator.tsx @@ -92,30 +92,18 @@ function Validator ({ canSelect, filterName, info, isNominated, isSelected, togg - ) - : ( - ) + : } {isElected ? ( - ) - : ( - ) + : } diff --git a/packages/react-components/src/AccountName.tsx b/packages/react-components/src/AccountName.tsx index b44684de9f..a02a007cee 100644 --- a/packages/react-components/src/AccountName.tsx +++ b/packages/react-components/src/AccountName.tsx @@ -78,7 +78,6 @@ function extractName (address: string, accountIndex?: AccountIndex, defaultName? )} @@ -97,9 +96,7 @@ function createIdElem (nameElem: React.ReactNode, color: 'green' | 'red' | 'gray {nameElem} @@ -122,7 +119,7 @@ function extractIdentity (address: string, identity: DeriveAccountRegistration): ( {displayParent - ? <>{displayParent}/{displayName} + ? <>{displayParent}{`/${displayName || ''}`} : displayName } diff --git a/packages/react-components/src/Badge.tsx b/packages/react-components/src/Badge.tsx index fb0ce45adb..2b027fb6d0 100644 --- a/packages/react-components/src/Badge.tsx +++ b/packages/react-components/src/Badge.tsx @@ -16,32 +16,27 @@ interface Props { hover?: React.ReactNode; icon?: IconName; info?: React.ReactNode; - isInline?: boolean; isSmall?: boolean; - isTooltip?: boolean; onClick?: () => void; } let badgeId = 0; -function Badge ({ className = '', color = 'normal', hover, icon, info, isInline, isSmall, isTooltip, onClick }: Props): React.ReactElement | null { +function Badge ({ className = '', color = 'normal', hover, icon, info, isSmall, onClick }: Props): React.ReactElement | null { const [trigger] = useState(`badge-hover-${Date.now()}-${badgeId++}`); - const extraProps = isTooltip && hover + const extraProps = hover ? { 'data-for': trigger, 'data-tip': true } : {}; return (
{info || (icon && )}
-
- {hover} -
{hover && ( * { line-height: 16px; } - - .detail { - height: 0; - width: 0; - } - - &.expand { - width: 300px; - - .badge { - width: 0; - } - - .detail { - width: auto; - } - } `);