From 0fa680789b4f60e049a160c610f7e5ef9a0d151d Mon Sep 17 00:00:00 2001 From: Jaco Date: Tue, 10 Jan 2023 06:36:00 +0200 Subject: [PATCH] Adjust popup & tooltip spacing (#8741) --- packages/react-components/src/AddressInfo.tsx | 82 +++++++++---------- .../react-components/src/DemocracyLocks.tsx | 7 +- .../src/Popup/PopupWindow.tsx | 31 ++++--- .../react-components/src/StakingUnbonding.tsx | 7 +- packages/react-components/src/Tooltip.tsx | 28 +++---- 5 files changed, 73 insertions(+), 82 deletions(-) diff --git a/packages/react-components/src/AddressInfo.tsx b/packages/react-components/src/AddressInfo.tsx index 91ce93d14e..c1bfd5a79a 100644 --- a/packages/react-components/src/AddressInfo.tsx +++ b/packages/react-components/src/AddressInfo.tsx @@ -278,36 +278,31 @@ function createBalanceItems (formatIndex: number, lookup: Record } value={deriveBalances.vestedBalance} > - + +
+ {formatBalance(deriveBalances.vestedClaimable, { forceUnit: '-' })} +
{t('available to be unlocked')}
+
+ {allVesting.map(({ endBlock, locked, perBlock, vested }, index) => ( +
- {formatBalance(deriveBalances.vestedClaimable, { forceUnit: '-' })} -
{t('available to be unlocked')}
+ {formatBalance(vested, { forceUnit: '-' })} +
{t('of {{locked}} vested', { replace: { locked: formatBalance(locked, { forceUnit: '-' }) } })}
- {allVesting.map(({ endBlock, locked, perBlock, vested }, index) => ( -
-
- {formatBalance(vested, { forceUnit: '-' })} -
{t('of {{locked}} vested', { replace: { locked: formatBalance(locked, { forceUnit: '-' }) } })}
-
-
- -
{t('until block')} {formatNumber(endBlock)}
-
-
- {formatBalance(perBlock)} -
{t('per block')}
-
-
- ))} - - } - trigger={`${address}-vested-trigger`} - /> +
+ +
{t('until block')} {formatNumber(endBlock)}
+
+
+ {formatBalance(perBlock)} +
{t('per block')}
+
+
+ ))} +
); @@ -328,17 +323,19 @@ function createBalanceItems (formatIndex: number, lookup: Record icon='info-circle' tooltip={`${address}-locks-trigger`} /> - ( -
+ + {deriveBalances.lockedBreakdown.map(({ amount, id, reasons }, index): React.ReactNode => ( +
{amount?.isMax() ? t('everything') : formatBalance(amount, { forceUnit: '-' }) }{id &&
{lookupLock(lookup, id)}
}
{reasons.toString()}
))} - trigger={`${address}-locks-trigger`} - /> +
} value={isAllLocked ? 'all' : deriveBalances.lockedBalance} @@ -359,15 +356,14 @@ function createBalanceItems (formatIndex: number, lookup: Record icon='info-circle' tooltip={`${address}-named-reserves-trigger`} /> - ( + + {allReserves.map(({ amount, id }, index): React.ReactNode => (
{formatBalance(amount, { forceUnit: '-' }) }{id &&
{lookupLock(lookup, id)}
}
))} - trigger={`${address}-named-reserves-trigger`} - /> +
) : @@ -457,9 +453,12 @@ function createBalanceItems (formatIndex: number, lookup: Record icon='clock' tooltip={`${address}-conviction-locks-trigger`} /> - ( -
+ + {convictionLocks.map(({ endBlock, locked, refId, total }, index): React.ReactNode => ( +
#{refId.toString()} {formatBalance(total, { forceUnit: '-' })} {locked}
{ endBlock.eq(BN_MAX_INTEGER) @@ -474,8 +473,7 @@ function createBalanceItems (formatIndex: number, lookup: Record }
))} - trigger={`${address}-conviction-locks-trigger`} - /> +
} value={max} diff --git a/packages/react-components/src/DemocracyLocks.tsx b/packages/react-components/src/DemocracyLocks.tsx index 0cc47b7b06..ab278379df 100644 --- a/packages/react-components/src/DemocracyLocks.tsx +++ b/packages/react-components/src/DemocracyLocks.tsx @@ -119,8 +119,8 @@ function DemocracyLocks ({ className = '', value }: Props): React.ReactElement

- ( + + {sorted.map(({ details, headers }, index): React.ReactNode => (

{details}
))} - trigger={trigger} - /> +
); } diff --git a/packages/react-components/src/Popup/PopupWindow.tsx b/packages/react-components/src/Popup/PopupWindow.tsx index 5f6acb2a2f..93f5edeebb 100644 --- a/packages/react-components/src/Popup/PopupWindow.tsx +++ b/packages/react-components/src/Popup/PopupWindow.tsx @@ -1,31 +1,28 @@ // Copyright 2017-2023 @polkadot/react-components authors & contributors // SPDX-License-Identifier: Apache-2.0 -import type { PopupWindowProps } from './types'; +import type { PopupWindowProps as Props } from './types'; -import React, { useMemo } from 'react'; +import React from 'react'; import { createPortal } from 'react-dom'; import styled, { css } from 'styled-components'; import { usePopupWindow } from '@polkadot/react-hooks/usePopupWindow'; -function PopupWindow ({ children, className = '', position, triggerRef, windowRef }: PopupWindowProps) { - const { pointerStyle, renderCoords } = usePopupWindow(windowRef, triggerRef, position); - - const style = useMemo( - () => ({ - transform: `translate3d(${renderCoords.x}px, ${renderCoords.y}px, 0)`, - zIndex: 1000 - }), - [renderCoords] - ); +function PopupWindow ({ children, className = '', position, triggerRef, windowRef }: Props): React.ReactElement { + const { pointerStyle, renderCoords: { x, y } } = usePopupWindow(windowRef, triggerRef, position); return createPortal(
{children}
, @@ -47,7 +44,7 @@ export default React.memo(styled(PopupWindow)` z-index: -1; &::before { - bottom: -0.45rem; + bottom: -0.5rem; box-shadow: 1px 1px 0 0 #bababc; position: absolute; right: 50%; @@ -55,11 +52,11 @@ export default React.memo(styled(PopupWindow)` ${({ position }) => position === 'left' && css` left: unset; - right: 0.8rem; + right: 0.75rem; `} ${({ position }) => position === 'right' && css` - left: 0.8rem; + left: 0.75rem; right: unset; `} @@ -75,7 +72,7 @@ export default React.memo(styled(PopupWindow)` &.bottomPointer::before { box-shadow: -1px -1px 0 0 #bababc; - top: -0.45rem; + top: -0.5rem; bottom: unset; } diff --git a/packages/react-components/src/StakingUnbonding.tsx b/packages/react-components/src/StakingUnbonding.tsx index 5c622d3cfb..d97014de28 100644 --- a/packages/react-components/src/StakingUnbonding.tsx +++ b/packages/react-components/src/StakingUnbonding.tsx @@ -77,8 +77,8 @@ function StakingUnbonding ({ className = '', iconPosition = 'left', stakingInfo /> )} - ( + + {mapped.map(([{ value }, eras, blocks], index): React.ReactNode => (
))} - trigger={trigger} - /> +
{iconPosition === 'right' && ( | null { +function Tooltip ({ children, className = '', isCickable = false, place, text, trigger }: Props): React.ReactElement | null { const [tooltipContainer] = useState( typeof document === 'undefined' ? {} as HTMLElement // This hack is required for server side rendering @@ -48,19 +41,24 @@ function Tooltip ({ className = '', clickable = false, effect = 'solid', offset, return createPortal( - {className?.includes('address') ?
{text}
: text} +
+ {text}{children} +
, tooltipContainer ); } export default React.memo(styled(Tooltip)` + .tooltipSpacer { + padding: 0.375rem; + } + > div { overflow: hidden; }