mirror of
https://github.com/luxfi/explore.git
synced 2026-09-24 00:28:18 +00:00
* basic components and address page refactoring * second part of refactoring * third part of refactoring * NativeCoinValue component * more refactoring * rename TruncatedValue into TruncatedText * minor fixes * refactor block details * fix layout of value and fee in tx table * update screenshots * different units for tooltip and stats widget small value fix * update screenshots * update tx table screenshot * fix copy button vertical alignment
96 lines
3.2 KiB
TypeScript
96 lines
3.2 KiB
TypeScript
import { Box, Flex, Grid } from '@chakra-ui/react';
|
|
import { capitalize } from 'es-toolkit';
|
|
import React from 'react';
|
|
|
|
import type { Block } from 'types/api/block';
|
|
|
|
import config from 'configs/app';
|
|
import getBlockTotalReward from 'lib/block/getBlockTotalReward';
|
|
import getNetworkValidatorTitle from 'lib/networks/getNetworkValidatorTitle';
|
|
import { currencyUnits } from 'lib/units';
|
|
import { Skeleton } from 'toolkit/chakra/skeleton';
|
|
import { Tooltip } from 'toolkit/chakra/tooltip';
|
|
import { thinsp } from 'toolkit/utils/htmlEntities';
|
|
import AddressEntity from 'ui/shared/entities/address/AddressEntity';
|
|
import BlockEntity from 'ui/shared/entities/block/BlockEntity';
|
|
import IconSvg from 'ui/shared/IconSvg';
|
|
import TimeWithTooltip from 'ui/shared/time/TimeWithTooltip';
|
|
import SimpleValue from 'ui/shared/value/SimpleValue';
|
|
|
|
type Props = {
|
|
block: Block;
|
|
isLoading?: boolean;
|
|
animation?: string;
|
|
};
|
|
|
|
const LatestBlocksItem = ({ block, isLoading, animation }: Props) => {
|
|
const totalReward = getBlockTotalReward(block);
|
|
return (
|
|
<Box
|
|
animation={ animation }
|
|
borderRadius="md"
|
|
border="1px solid"
|
|
borderColor="border.divider"
|
|
p={ 3 }
|
|
>
|
|
<Flex alignItems="center" overflow="hidden" w="100%" mb={ 3 }>
|
|
<BlockEntity
|
|
isLoading={ isLoading }
|
|
number={ block.height }
|
|
tailLength={ 2 }
|
|
textStyle="md"
|
|
fontWeight={ 500 }
|
|
mr="auto"
|
|
/>
|
|
{ block.celo?.l1_era_finalized_epoch_number && (
|
|
<Tooltip content={ `Finalized epoch #${ block.celo.l1_era_finalized_epoch_number }` }>
|
|
<IconSvg name="checkered_flag" boxSize={ 5 } p="1px" ml={ 2 } isLoading={ isLoading } flexShrink={ 0 }/>
|
|
</Tooltip>
|
|
) }
|
|
<TimeWithTooltip
|
|
timestamp={ block.timestamp }
|
|
enableIncrement={ !isLoading }
|
|
timeFormat="relative"
|
|
isLoading={ isLoading }
|
|
color="text.secondary"
|
|
display="inline-block"
|
|
textStyle="sm"
|
|
flexShrink={ 0 }
|
|
ml={ 2 }
|
|
/>
|
|
</Flex>
|
|
<Grid gridGap={ 2 } templateColumns="auto minmax(0, 1fr)" textStyle="sm">
|
|
<Skeleton loading={ isLoading }>Txn</Skeleton>
|
|
<Skeleton loading={ isLoading } color="text.secondary"><span>{ block.transactions_count }</span></Skeleton>
|
|
|
|
{ !config.features.rollup.isEnabled && !config.UI.views.block.hiddenFields?.total_reward && (
|
|
<>
|
|
<Skeleton loading={ isLoading }>Reward</Skeleton>
|
|
<SimpleValue
|
|
value={ totalReward }
|
|
loading={ isLoading }
|
|
color="text.secondary"
|
|
endElement={ `${ thinsp }${ currencyUnits.ether }` }
|
|
/>
|
|
</>
|
|
) }
|
|
|
|
{ !config.features.rollup.isEnabled && !config.UI.views.block.hiddenFields?.miner && (
|
|
<>
|
|
<Skeleton loading={ isLoading }>{ capitalize(getNetworkValidatorTitle()) }</Skeleton>
|
|
<AddressEntity
|
|
address={ block.miner }
|
|
isLoading={ isLoading }
|
|
noIcon
|
|
noCopy
|
|
truncation="constant"
|
|
/>
|
|
</>
|
|
) }
|
|
</Grid>
|
|
</Box>
|
|
);
|
|
};
|
|
|
|
export default LatestBlocksItem;
|