Some small -> styled-components conversions (#1262)
* Combine AddressSummary & Row * Cleanup address rendering * Tiny tags cleanups * Remove unused ui--AddressSummary overrides * Column component * Columar * Cleanups * Remove hot client * Backport data padding * Some small -> styled-components conversions * Move RecebtlyOffline styles * Cleanups
This commit is contained in:
parent
1fceb4df51
commit
783ca2c5c0
@ -6,6 +6,7 @@ import { BareProps } from './types';
|
||||
|
||||
import BN from 'bn.js';
|
||||
import React from 'react';
|
||||
import styled from 'styled-components';
|
||||
import { AccountId, AccountIndex, Address } from '@polkadot/types';
|
||||
import { OfflineStatus } from '@polkadot/app-staking/types';
|
||||
import { RecentlyOffline } from '@polkadot/ui-app';
|
||||
@ -28,7 +29,7 @@ type Props = BareProps & {
|
||||
withBonded?: boolean
|
||||
};
|
||||
|
||||
export default class AddressMini extends React.PureComponent<Props> {
|
||||
class AddressMini extends React.PureComponent<Props> {
|
||||
render () {
|
||||
const { children, className, isPadded = true, style, value } = this.props;
|
||||
|
||||
@ -128,3 +129,55 @@ export default class AddressMini extends React.PureComponent<Props> {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default styled(AddressMini)`
|
||||
display: inline-block;
|
||||
padding: 0 0.25rem 0 1rem;
|
||||
white-space: nowrap;
|
||||
|
||||
&.padded {
|
||||
display: inline-block;
|
||||
padding: 0.25rem 0 0 1rem;
|
||||
}
|
||||
|
||||
&.summary {
|
||||
position: relative;
|
||||
top: -0.2rem;
|
||||
}
|
||||
|
||||
.ui--AddressMini-address {
|
||||
&.withAddr {
|
||||
font-family: monospace;
|
||||
}
|
||||
|
||||
&.withName {
|
||||
text-align: right;
|
||||
text-transform: uppercase;
|
||||
min-width: 4em;
|
||||
}
|
||||
}
|
||||
|
||||
.ui--AddressMini-balances {
|
||||
display: grid;
|
||||
}
|
||||
|
||||
.ui--AddressMini-balances .ui--Bonded.result-bonded,
|
||||
.ui--AddressMini-balances .ui--Bonded {
|
||||
font-size: .75rem;
|
||||
margin-right: 2.25rem;
|
||||
margin-top: -.5rem;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.ui--AddressMini-info,
|
||||
.ui--IdentityIcon {
|
||||
display: inline-block;
|
||||
position:relative;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.ui--IdentityIcon {
|
||||
margin-left: 0.5rem;
|
||||
margin-right: 0;
|
||||
}
|
||||
`;
|
||||
|
||||
@ -7,6 +7,7 @@ import { SemanticCOLORS, SemanticICONS } from 'semantic-ui-react/dist/commonjs/g
|
||||
|
||||
import React from 'react';
|
||||
import SUILabel from 'semantic-ui-react/dist/commonjs/elements/Label/Label';
|
||||
import styled from 'styled-components';
|
||||
import settings from '@polkadot/ui-settings';
|
||||
|
||||
import { classes } from './util';
|
||||
@ -19,7 +20,7 @@ type Props = BareProps & {
|
||||
label?: React.ReactNode
|
||||
};
|
||||
|
||||
export default class Bubble extends React.PureComponent<Props> {
|
||||
class Bubble extends React.PureComponent<Props> {
|
||||
render () {
|
||||
const { color, children, className, icon, label } = this.props;
|
||||
|
||||
@ -29,16 +30,8 @@ export default class Bubble extends React.PureComponent<Props> {
|
||||
color={color}
|
||||
>
|
||||
<div className='ui--Bubble-header'>
|
||||
{
|
||||
icon
|
||||
? <Icon name={icon} size='large' />
|
||||
: undefined
|
||||
}
|
||||
{
|
||||
label
|
||||
? <div className='text'>{label}</div>
|
||||
: undefined
|
||||
}
|
||||
{icon && <Icon name={icon} size='large' />}
|
||||
{label && <div className='text'>{label}</div>}
|
||||
</div>
|
||||
<div className='ui--Bubble-children'>
|
||||
{children}
|
||||
@ -47,3 +40,44 @@ export default class Bubble extends React.PureComponent<Props> {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default styled(Bubble)`
|
||||
font-weight: normal;
|
||||
margin: 0.25rem;
|
||||
padding: 0;
|
||||
|
||||
* {
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.ui--Bubble-children,
|
||||
.ui--Bubble-header {
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.ui--Bubble-children {
|
||||
padding: 0 0.75rem 0 0;
|
||||
}
|
||||
|
||||
.ui--Bubble-header {
|
||||
background: rgba(0, 0, 0, 0.05);
|
||||
box-sizing: border-box;
|
||||
border-radius: .28571429rem 0 0 .28571429rem;
|
||||
height: 2.75rem;
|
||||
margin-right: 0.75rem;
|
||||
padding: 0 0.75rem;
|
||||
text-align: center;
|
||||
vertical-align: middle;
|
||||
|
||||
> div {
|
||||
display: inline-block;
|
||||
line-height: 2.75rem !important;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
> .text {
|
||||
padding: 0 0 0 0.25rem;
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
@ -7,11 +7,13 @@ import { OfflineStatus } from '@polkadot/app-staking/types';
|
||||
|
||||
import BN from 'bn.js';
|
||||
import React from 'react';
|
||||
import styled from 'styled-components';
|
||||
import { formatNumber } from '@polkadot/util';
|
||||
|
||||
import Tooltip from './Tooltip';
|
||||
|
||||
import translate from './translate';
|
||||
import { classes } from './util';
|
||||
|
||||
type Props = I18nProps & {
|
||||
accountId: AccountId | string,
|
||||
@ -30,19 +32,10 @@ class RecentlyOffline extends React.PureComponent<Props, State> {
|
||||
};
|
||||
|
||||
render () {
|
||||
const { offline, inline, tooltip = false, t } = this.props;
|
||||
const { accountId, className, inline, offline, tooltip = false, t } = this.props;
|
||||
const { isOpen } = this.state;
|
||||
const accountId = this.props.accountId.toString();
|
||||
|
||||
const count = offline.reduce((total, { count }) => total.add(count), new BN(0));
|
||||
const blockNumbers = offline.map(({ blockNumber }) => `#${formatNumber(blockNumber)}`);
|
||||
|
||||
const tooltipData = {
|
||||
'data-for': `offline-${accountId}`,
|
||||
'data-tip': true,
|
||||
'data-tip-disable': !tooltip
|
||||
};
|
||||
|
||||
const text = t('Reported offline {{count}} times, last at {{blockNumber}}', {
|
||||
replace: {
|
||||
count,
|
||||
@ -52,17 +45,11 @@ class RecentlyOffline extends React.PureComponent<Props, State> {
|
||||
|
||||
return (
|
||||
<div
|
||||
className={[
|
||||
'ui--RecentlyOffline',
|
||||
isOpen ? 'expand' : '',
|
||||
tooltip ? 'tooltip' : '',
|
||||
inline ? 'inline' : ''
|
||||
].join(' ')}
|
||||
{...(!tooltip ?
|
||||
{ onClick: this.toggleOpen } :
|
||||
{}
|
||||
)}
|
||||
{...tooltipData}
|
||||
className={classes('ui--RecentlyOffline', isOpen && 'expand', tooltip && 'tooltip', inline && 'inline', className)}
|
||||
{...(!tooltip ? { onClick: this.toggleOpen } : {})}
|
||||
data-for={`offline-${accountId}`}
|
||||
data-tip={true}
|
||||
data-tip-disable={!tooltip}
|
||||
>
|
||||
<div className='badge'>
|
||||
{count.toString()}
|
||||
@ -85,4 +72,56 @@ class RecentlyOffline extends React.PureComponent<Props, State> {
|
||||
}
|
||||
}
|
||||
|
||||
export default translate(RecentlyOffline);
|
||||
export default translate(styled(RecentlyOffline)`
|
||||
background: red;
|
||||
border-radius: 16px;
|
||||
box-shadow: 0 3px 3px rgba(0, 0, 0, 0.2);
|
||||
color: #eee;
|
||||
cursor: help;
|
||||
display: flex;
|
||||
font-size: 12px;
|
||||
height: 22px;
|
||||
justify-content: center;
|
||||
left: 1rem;
|
||||
padding: 0;
|
||||
position: absolute;
|
||||
text-align: center;
|
||||
top: 1rem;
|
||||
transition: all ease .2s;
|
||||
width: 22px;
|
||||
|
||||
& > * {
|
||||
line-height: 22px;
|
||||
overflow: hidden;
|
||||
transition: all ease 0.25;
|
||||
}
|
||||
|
||||
.badge {
|
||||
font-weight: bold;
|
||||
width: auto;
|
||||
}
|
||||
|
||||
.detail {
|
||||
width: 0;
|
||||
}
|
||||
|
||||
&.expand {
|
||||
width: 300px;
|
||||
|
||||
.badge {
|
||||
width: 0;
|
||||
}
|
||||
|
||||
.detail {
|
||||
width: auto;
|
||||
}
|
||||
}
|
||||
|
||||
&.inline {
|
||||
left: auto;
|
||||
position: absolute;
|
||||
right: -2.75rem;
|
||||
top: -1rem;
|
||||
z-index: 1;
|
||||
}
|
||||
`);
|
||||
|
||||
@ -2,16 +2,17 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { BareProps } from './types';
|
||||
|
||||
import React from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
import ReactTooltip from 'react-tooltip';
|
||||
|
||||
import { BareProps } from './types';
|
||||
import { classes } from './util';
|
||||
|
||||
const rootElement = document.getElementById('tooltips');
|
||||
|
||||
type Props = BareProps & {
|
||||
delayShow?: number,
|
||||
dataFor?: string,
|
||||
effect?: 'solid' | 'float'
|
||||
offset?: { bottom?: number, left?: number, right?: number, top?: number },
|
||||
@ -21,13 +22,6 @@ type Props = BareProps & {
|
||||
};
|
||||
|
||||
export default class Tooltip extends React.PureComponent<Props> {
|
||||
static defaultProps = {
|
||||
delayShow: 250,
|
||||
effect: 'solid',
|
||||
place: 'bottom',
|
||||
className: 'ui--Tooltip'
|
||||
};
|
||||
|
||||
private tooltipContainer: HTMLElement;
|
||||
|
||||
constructor (props: Props) {
|
||||
@ -49,16 +43,16 @@ export default class Tooltip extends React.PureComponent<Props> {
|
||||
}
|
||||
|
||||
render () {
|
||||
const { className, delayShow, effect, offset, place, text, trigger } = this.props;
|
||||
const { className, effect = 'solid', offset, place = 'bottom', text, trigger } = this.props;
|
||||
|
||||
return ReactDOM.createPortal(
|
||||
<ReactTooltip
|
||||
id={trigger}
|
||||
delayShow={delayShow}
|
||||
delayShow={250}
|
||||
effect={effect}
|
||||
offset={offset}
|
||||
place={place}
|
||||
className={className}
|
||||
className={classes('ui--Tooltip', className)}
|
||||
>
|
||||
{text}
|
||||
</ReactTooltip>,
|
||||
|
||||
@ -43,46 +43,6 @@ header .ui--Button-Group {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.ui--AddressMini {
|
||||
display: inline-block;
|
||||
padding: 0 0.25rem 0 1rem;
|
||||
white-space: nowrap;
|
||||
|
||||
&.padded {
|
||||
display: inline-block;
|
||||
padding: 0.25rem 0 0 1rem;
|
||||
}
|
||||
|
||||
&.summary {
|
||||
position: relative;
|
||||
top: -0.2rem;
|
||||
}
|
||||
|
||||
.ui--AddressMini-info,
|
||||
.ui--IdentityIcon {
|
||||
display: inline-block;
|
||||
position:relative;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.ui--IdentityIcon {
|
||||
margin-left: 0.5rem;
|
||||
margin-right: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.ui--AddressMini-address {
|
||||
&.withAddr {
|
||||
font-family: monospace;
|
||||
}
|
||||
|
||||
&.withName {
|
||||
text-align: right;
|
||||
text-transform: uppercase;
|
||||
min-width: 4em;
|
||||
}
|
||||
}
|
||||
|
||||
button.ui.icon.iconButton {
|
||||
padding: 0em .3em .3em .3em !important;
|
||||
color: #2e86ab !important;
|
||||
@ -97,59 +57,6 @@ button.ui.icon.iconButton {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.ui--AddressMini-balances {
|
||||
display: grid;
|
||||
}
|
||||
|
||||
.ui--AddressMini-balances .ui--Bonded.result-bonded,
|
||||
.ui--AddressMini-balances .ui--Bonded {
|
||||
font-size: .75rem;
|
||||
margin-right: 2.25rem;
|
||||
margin-top: -.5rem;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.ui--Bubble.ui.label {
|
||||
font-weight: normal;
|
||||
margin: 0.25rem;
|
||||
padding: 0;
|
||||
|
||||
* {
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.ui--Bubble-children,
|
||||
.ui--Bubble-header {
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.ui--Bubble-children {
|
||||
padding: 0 0.75rem 0 0;
|
||||
}
|
||||
|
||||
.ui--Bubble-header {
|
||||
background: rgba(0, 0, 0, 0.05);
|
||||
box-sizing: border-box;
|
||||
border-radius: .28571429rem 0 0 .28571429rem;
|
||||
height: 2.75rem;
|
||||
margin-right: 0.75rem;
|
||||
padding: 0 0.75rem;
|
||||
text-align: center;
|
||||
vertical-align: middle;
|
||||
|
||||
> div {
|
||||
display: inline-block;
|
||||
line-height: 2.75rem !important;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
> .text {
|
||||
padding: 0 0 0 0.25rem;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.ui--DropdownLinked.ui--row {
|
||||
.small .ui.selection.dropdown {
|
||||
min-width: 5rem;
|
||||
@ -215,60 +122,6 @@ button.ui.icon.iconButton {
|
||||
}
|
||||
}
|
||||
|
||||
.ui--RecentlyOffline {
|
||||
position: absolute;
|
||||
font-size: 12px;
|
||||
cursor: help;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
left: 1rem;
|
||||
width: 22px;
|
||||
height: 22px;
|
||||
padding: 0;
|
||||
background: red;
|
||||
color: #eee;
|
||||
border-radius: 16px;
|
||||
box-shadow: 0 3px 3px rgba(0, 0, 0, 0.2);
|
||||
text-align: center;
|
||||
top: 1rem;
|
||||
transition: all ease .2s;
|
||||
|
||||
& > * {
|
||||
line-height: 22px;
|
||||
overflow: hidden;
|
||||
transition: all ease 0.25;
|
||||
}
|
||||
|
||||
.badge {
|
||||
font-weight: bold;
|
||||
width: auto;
|
||||
}
|
||||
|
||||
.detail {
|
||||
width: 0;
|
||||
}
|
||||
|
||||
&.expand {
|
||||
width: 300px;
|
||||
|
||||
.badge {
|
||||
width: 0;
|
||||
}
|
||||
|
||||
.detail {
|
||||
width: auto;
|
||||
}
|
||||
}
|
||||
|
||||
&.inline {
|
||||
position: absolute;
|
||||
left: auto;
|
||||
right: -2.75rem;
|
||||
top: -1rem;
|
||||
z-index: 1;
|
||||
}
|
||||
}
|
||||
|
||||
.ui--Static {
|
||||
overflow: hidden;
|
||||
word-break: break-all;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user