Adjust Badge to inline default (as used) (#3150)
* Adjust Badge to inline default (as used) * Default to isTooltip with hover set
This commit is contained in:
parent
1567258441
commit
1c7865cf65
@ -106,7 +106,6 @@ function Item ({ isCollapsed, onClick, route }: Props): React.ReactElement<Props
|
||||
<Badge
|
||||
color='counter'
|
||||
info={count}
|
||||
isInline
|
||||
/>
|
||||
)}
|
||||
<Tooltip
|
||||
|
||||
@ -242,8 +242,6 @@ function Account ({ account: { address, meta }, className = '', delegation, filt
|
||||
</div>
|
||||
}
|
||||
icon='shield'
|
||||
isInline
|
||||
isTooltip
|
||||
/>
|
||||
)}
|
||||
{multiInfos && multiInfos.length !== 0 && (
|
||||
@ -251,8 +249,6 @@ function Account ({ account: { address, meta }, className = '', delegation, filt
|
||||
color='red'
|
||||
hover={t<string>('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<string>('Proxied account has no owned proxies')}
|
||||
info='0'
|
||||
isInline
|
||||
isTooltip
|
||||
/>
|
||||
)}
|
||||
</td>
|
||||
|
||||
@ -129,8 +129,6 @@ function Referendum ({ className = '', value: { allAye, allNay, image, imageHash
|
||||
: t<string>('{{threshold}}, not passing', { replace: { threshold } })
|
||||
}
|
||||
icon={isPassing ? 'check' : 'times'}
|
||||
isInline
|
||||
isTooltip
|
||||
/>
|
||||
)}
|
||||
</td>
|
||||
|
||||
@ -50,7 +50,6 @@ function Parachain ({ className = '', parachain: { didUpdate, id, info, pendingS
|
||||
<Icon icon='check' />
|
||||
}
|
||||
isGray={!didUpdate}
|
||||
isTooltip
|
||||
/>
|
||||
<Badge
|
||||
className='pending-messages'
|
||||
@ -62,7 +61,6 @@ function Parachain ({ className = '', parachain: { didUpdate, id, info, pendingS
|
||||
})}
|
||||
info={relayDispatchQueueSize}
|
||||
isGray={relayDispatchQueueSize <= 0}
|
||||
isTooltip
|
||||
/>
|
||||
</div>
|
||||
</td>
|
||||
|
||||
@ -20,7 +20,6 @@ function MaxBadge ({ numNominators }: Props): React.ReactElement<Props> | null {
|
||||
<Badge
|
||||
color='red'
|
||||
info='64+'
|
||||
isInline
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
@ -22,21 +22,14 @@ function Status ({ isElected, numNominators, onlineCount, onlineMessage }: Props
|
||||
<Badge
|
||||
color='blue'
|
||||
icon='chevron-right'
|
||||
isInline
|
||||
/>
|
||||
)
|
||||
: (
|
||||
<Badge
|
||||
color='transparent'
|
||||
isInline
|
||||
/>
|
||||
)
|
||||
: <Badge color='transparent' />
|
||||
}
|
||||
{(!!onlineCount || onlineMessage) && (
|
||||
<Badge
|
||||
color='green'
|
||||
info={onlineCount || <Icon icon='envelope' />}
|
||||
isInline
|
||||
/>
|
||||
)}
|
||||
<MaxBadge numNominators={numNominators} />
|
||||
|
||||
@ -92,30 +92,18 @@ function Validator ({ canSelect, filterName, info, isNominated, isSelected, togg
|
||||
<Badge
|
||||
color='green'
|
||||
icon='hand-paper'
|
||||
isInline
|
||||
/>
|
||||
)
|
||||
: (
|
||||
<Badge
|
||||
color='transparent'
|
||||
isInline
|
||||
/>
|
||||
)
|
||||
: <Badge color='transparent' />
|
||||
}
|
||||
{isElected
|
||||
? (
|
||||
<Badge
|
||||
color='blue'
|
||||
icon='chevron-right'
|
||||
isInline
|
||||
/>
|
||||
)
|
||||
: (
|
||||
<Badge
|
||||
color='transparent'
|
||||
isInline
|
||||
/>
|
||||
)
|
||||
: <Badge color='transparent' />
|
||||
}
|
||||
<MaxBadge numNominators={numNominators} />
|
||||
</td>
|
||||
|
||||
@ -78,7 +78,6 @@ function extractName (address: string, accountIndex?: AccountIndex, defaultName?
|
||||
<Badge
|
||||
color='green'
|
||||
icon='archway'
|
||||
isInline
|
||||
isSmall
|
||||
/>
|
||||
)}
|
||||
@ -97,9 +96,7 @@ function createIdElem (nameElem: React.ReactNode, color: 'green' | 'red' | 'gray
|
||||
<Badge
|
||||
color={color}
|
||||
icon={icon}
|
||||
isInline
|
||||
isSmall
|
||||
isTooltip
|
||||
/>
|
||||
{nameElem}
|
||||
</div>
|
||||
@ -122,7 +119,7 @@ function extractIdentity (address: string, identity: DeriveAccountRegistration):
|
||||
(
|
||||
<span className={`name ${isGood ? 'isGood' : ''}`}>
|
||||
{displayParent
|
||||
? <><span className='top'>{displayParent}</span><span className='sub'>/{displayName}</span></>
|
||||
? <><span className='top'>{displayParent}</span><span className='sub'>{`/${displayName || ''}`}</span></>
|
||||
: displayName
|
||||
}
|
||||
</span>
|
||||
|
||||
@ -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<Props> | null {
|
||||
function Badge ({ className = '', color = 'normal', hover, icon, info, isSmall, onClick }: Props): React.ReactElement<Props> | null {
|
||||
const [trigger] = useState(`badge-hover-${Date.now()}-${badgeId++}`);
|
||||
const extraProps = isTooltip && hover
|
||||
const extraProps = hover
|
||||
? { 'data-for': trigger, 'data-tip': true }
|
||||
: {};
|
||||
|
||||
return (
|
||||
<div
|
||||
{...extraProps}
|
||||
className={`ui--Badge ${isInline ? 'isInline' : ''} ${isTooltip ? 'isTooltip' : ''} ${isSmall ? 'isSmall' : ''} ${onClick ? 'isClickable' : ''} ${color}Color ${className}`}
|
||||
className={`ui--Badge ${hover ? 'isTooltip' : ''} ${isSmall ? 'isSmall' : ''} ${onClick ? 'isClickable' : ''} ${color}Color ${className}`}
|
||||
onClick={onClick}
|
||||
>
|
||||
<div className='badge'>
|
||||
{info || (icon && <Icon icon={icon} />)}
|
||||
</div>
|
||||
<div className='detail'>
|
||||
{hover}
|
||||
</div>
|
||||
{hover && (
|
||||
<Tooltip
|
||||
text={hover}
|
||||
@ -56,8 +51,11 @@ export default React.memo(styled(Badge)`
|
||||
border-radius: 16px;
|
||||
box-shadow: 0 3px 3px rgba(0, 0, 0, 0.2);
|
||||
color: #eee;
|
||||
display: inline-block;
|
||||
font-size: 12px;
|
||||
height: 22px;
|
||||
margin-right: 0.25rem;
|
||||
vertical-align: middle;
|
||||
padding: 0 4px;
|
||||
text-align: center;
|
||||
width: 22px;
|
||||
@ -87,18 +85,6 @@ export default React.memo(styled(Badge)`
|
||||
width: 16px;
|
||||
}
|
||||
|
||||
&:not(.isInline) {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
margin-bottom: 0.25rem;
|
||||
}
|
||||
|
||||
&.isInline {
|
||||
display: inline-block;
|
||||
margin-right: 0.25rem;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
&.blueColor {
|
||||
background: steelblue;
|
||||
}
|
||||
@ -139,21 +125,4 @@ export default React.memo(styled(Badge)`
|
||||
&.isSmall > * {
|
||||
line-height: 16px;
|
||||
}
|
||||
|
||||
.detail {
|
||||
height: 0;
|
||||
width: 0;
|
||||
}
|
||||
|
||||
&.expand {
|
||||
width: 300px;
|
||||
|
||||
.badge {
|
||||
width: 0;
|
||||
}
|
||||
|
||||
.detail {
|
||||
width: auto;
|
||||
}
|
||||
}
|
||||
`);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user