Displayed average block time for chains in explorer page (#11999)
* feat: displayed average block time for chains in explorer page * feat: enhance average block time display with tooltip
This commit is contained in:
parent
defabb1aa0
commit
ee87b1ad20
@ -5,11 +5,12 @@ import type { AugmentedBlockHeader } from '@polkadot/react-hooks/ctx/types';
|
||||
|
||||
import React from 'react';
|
||||
|
||||
import { CardSummary, SummaryBox } from '@polkadot/react-components';
|
||||
import { CardSummary, Icon, styled, SummaryBox, Tooltip } from '@polkadot/react-components';
|
||||
import { useApi } from '@polkadot/react-hooks';
|
||||
import { BestFinalized, BestNumber, BlockToTime, TimeNow, TotalInactive, TotalIssuance } from '@polkadot/react-query';
|
||||
import { BN_ONE, formatNumber } from '@polkadot/util';
|
||||
import { BestFinalized, BestNumber, TimeNow, TotalInactive, TotalIssuance } from '@polkadot/react-query';
|
||||
import { formatNumber } from '@polkadot/util';
|
||||
|
||||
import useLatency from './Latency/useLatency.js';
|
||||
import SummarySession from './SummarySession.js';
|
||||
import { useTranslation } from './translate.js';
|
||||
|
||||
@ -21,10 +22,11 @@ interface Props {
|
||||
function Summary ({ eventCount, headers }: Props): React.ReactElement {
|
||||
const { t } = useTranslation();
|
||||
const { api } = useApi();
|
||||
const { isLoaded, timeAvg } = useLatency();
|
||||
|
||||
return (
|
||||
<SummaryBox>
|
||||
<section>
|
||||
<Section>
|
||||
{api.query.timestamp && (
|
||||
<>
|
||||
<CardSummary label={t('last block')}>
|
||||
@ -32,10 +34,24 @@ function Summary ({ eventCount, headers }: Props): React.ReactElement {
|
||||
<TimeNow key={headers.at(0)?.hash.toHex()} />
|
||||
</CardSummary>
|
||||
<CardSummary
|
||||
className='media--800'
|
||||
label={t('slot')}
|
||||
className='media--800 avgBlockTime'
|
||||
label={
|
||||
<p>
|
||||
{t('average block time')}
|
||||
<Icon
|
||||
icon='info-circle'
|
||||
isPadded
|
||||
tooltip='average-blocktime'
|
||||
/>
|
||||
<Tooltip
|
||||
place='top'
|
||||
text={t('Average block time calculated over the last 50 blocks')}
|
||||
trigger='average-blocktime'
|
||||
/>
|
||||
</p>
|
||||
}
|
||||
>
|
||||
<BlockToTime value={BN_ONE} />
|
||||
<span className={`--digits ${isLoaded ? '' : '--tmp'}`}>{`${(timeAvg / 1000).toFixed(3)}`}<span className='postfix timeUnit'> s</span></span>
|
||||
</CardSummary>
|
||||
</>
|
||||
)}
|
||||
@ -57,7 +73,7 @@ function Summary ({ eventCount, headers }: Props): React.ReactElement {
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
</section>
|
||||
</Section>
|
||||
<section className='media--1100'>
|
||||
<SummarySession withEra={false} />
|
||||
</section>
|
||||
@ -81,4 +97,12 @@ function Summary ({ eventCount, headers }: Props): React.ReactElement {
|
||||
);
|
||||
}
|
||||
|
||||
const Section = styled.section`
|
||||
.avgBlockTime span.--digits {
|
||||
.postfix {
|
||||
font-size: var(--font-percent-tiny);
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
export default React.memo(Summary);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user