Add total issuance summary card (#1086)
* Add total issuance summary card * Remove unit from TotalInsurance formatting
This commit is contained in:
parent
0ad5d79f7a
commit
dd245ce5db
@ -6,7 +6,7 @@ import { I18nProps } from '@polkadot/ui-app/types';
|
||||
|
||||
import React from 'react';
|
||||
import { SummaryBox, CardSummary } from '@polkadot/ui-app';
|
||||
import { BestFinalized, BestNumber, TimeNow, TimePeriod } from '@polkadot/ui-reactive';
|
||||
import { BestFinalized, BestNumber, TimeNow, TimePeriod, TotalIssuance } from '@polkadot/ui-reactive';
|
||||
|
||||
import SummarySession from './SummarySession';
|
||||
import translate from './translate';
|
||||
@ -20,14 +20,20 @@ class Summary extends React.PureComponent<Props> {
|
||||
return (
|
||||
<SummaryBox>
|
||||
<section>
|
||||
<CardSummary label={t('last block')}>
|
||||
<TimeNow />
|
||||
</CardSummary>
|
||||
<CardSummary
|
||||
className='ui--media-small'
|
||||
label={t('target')}
|
||||
>
|
||||
<TimePeriod />
|
||||
</CardSummary>
|
||||
<CardSummary label={t('last block')}>
|
||||
<TimeNow />
|
||||
<CardSummary
|
||||
className='ui--media-small'
|
||||
label={t('total issuance')}
|
||||
>
|
||||
<TotalIssuance />
|
||||
</CardSummary>
|
||||
</section>
|
||||
<section className='ui--media-large'>
|
||||
|
||||
40
packages/ui-reactive/src/TotalIssuance.tsx
Normal file
40
packages/ui-reactive/src/TotalIssuance.tsx
Normal file
@ -0,0 +1,40 @@
|
||||
// Copyright 2017-2019 @polkadot/ui-reactive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { BareProps, CallProps } from '@polkadot/ui-api/types';
|
||||
|
||||
import React from 'react';
|
||||
import { Balance } from '@polkadot/types';
|
||||
import { withCalls } from '@polkadot/ui-api';
|
||||
import { formatBalance } from '@polkadot/util';
|
||||
|
||||
type Props = BareProps & CallProps & {
|
||||
children?: React.ReactNode,
|
||||
label?: string,
|
||||
balances_totalIssuance?: Balance
|
||||
};
|
||||
|
||||
export class TotalIssuance extends React.PureComponent<Props> {
|
||||
render () {
|
||||
const { children, className, label = '', style, balances_totalIssuance } = this.props;
|
||||
const value = balances_totalIssuance
|
||||
? balances_totalIssuance.toString()
|
||||
: null;
|
||||
|
||||
return (
|
||||
<div
|
||||
className={className}
|
||||
style={style}
|
||||
>
|
||||
{label}{
|
||||
value
|
||||
? `${formatBalance(value, false)}${formatBalance.calcSi(value).value}`
|
||||
: '-'
|
||||
}{children}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default withCalls<Props>('query.balances.totalIssuance')(TotalIssuance);
|
||||
@ -15,4 +15,5 @@ export { default as NodeVersion } from './NodeVersion';
|
||||
export { default as Nonce } from './Nonce';
|
||||
export { default as TimeNow } from './TimeNow';
|
||||
export { default as TimePeriod } from './TimePeriod';
|
||||
export { default as TotalIssuance } from './TotalIssuance';
|
||||
export { default as Unlocking } from './Unlocking';
|
||||
|
||||
Loading…
Reference in New Issue
Block a user