Commit ff717d1a authored by isstuev's avatar isstuev

design-fixes

parent 08148d64
...@@ -9,7 +9,7 @@ import appConfig from 'configs/app/config'; ...@@ -9,7 +9,7 @@ import appConfig from 'configs/app/config';
import getBlockTotalReward from 'lib/block/getBlockTotalReward'; import getBlockTotalReward from 'lib/block/getBlockTotalReward';
import useTimeAgoIncrement from 'lib/hooks/useTimeAgoIncrement'; import useTimeAgoIncrement from 'lib/hooks/useTimeAgoIncrement';
import LinkInternal from 'ui/shared/LinkInternal'; import LinkInternal from 'ui/shared/LinkInternal';
import ListItemMobile from 'ui/shared/ListItemMobile'; import ListItemMobile from 'ui/shared/ListItemMobile/ListItemMobile';
import Utilization from 'ui/shared/Utilization/Utilization'; import Utilization from 'ui/shared/Utilization/Utilization';
type Props = Block & { type Props = Block & {
......
...@@ -11,7 +11,7 @@ import useTimeAgoIncrement from 'lib/hooks/useTimeAgoIncrement'; ...@@ -11,7 +11,7 @@ import useTimeAgoIncrement from 'lib/hooks/useTimeAgoIncrement';
import Address from 'ui/shared/address/Address'; import Address from 'ui/shared/address/Address';
import AddressLink from 'ui/shared/address/AddressLink'; import AddressLink from 'ui/shared/address/AddressLink';
import LinkInternal from 'ui/shared/LinkInternal'; import LinkInternal from 'ui/shared/LinkInternal';
import ListItemMobile from 'ui/shared/ListItemMobile'; import ListItemMobile from 'ui/shared/ListItemMobile/ListItemMobile';
type Props = AddressCoinBalanceHistoryItem & { type Props = AddressCoinBalanceHistoryItem & {
page: number; page: number;
......
...@@ -13,7 +13,7 @@ import AddressIcon from 'ui/shared/address/AddressIcon'; ...@@ -13,7 +13,7 @@ import AddressIcon from 'ui/shared/address/AddressIcon';
import AddressLink from 'ui/shared/address/AddressLink'; import AddressLink from 'ui/shared/address/AddressLink';
import InOutTag from 'ui/shared/InOutTag'; import InOutTag from 'ui/shared/InOutTag';
import LinkInternal from 'ui/shared/LinkInternal'; import LinkInternal from 'ui/shared/LinkInternal';
import ListItemMobile from 'ui/shared/ListItemMobile'; import ListItemMobile from 'ui/shared/ListItemMobile/ListItemMobile';
import TxStatus from 'ui/shared/TxStatus'; import TxStatus from 'ui/shared/TxStatus';
import { TX_INTERNALS_ITEMS } from 'ui/tx/internals/utils'; import { TX_INTERNALS_ITEMS } from 'ui/tx/internals/utils';
......
...@@ -6,7 +6,7 @@ import type { AddressTokenBalance } from 'types/api/address'; ...@@ -6,7 +6,7 @@ import type { AddressTokenBalance } from 'types/api/address';
import getCurrencyValue from 'lib/getCurrencyValue'; import getCurrencyValue from 'lib/getCurrencyValue';
import AddressLink from 'ui/shared/address/AddressLink'; import AddressLink from 'ui/shared/address/AddressLink';
import CopyToClipboard from 'ui/shared/CopyToClipboard'; import CopyToClipboard from 'ui/shared/CopyToClipboard';
import ListItemMobile from 'ui/shared/ListItemMobile'; import ListItemMobile from 'ui/shared/ListItemMobile/ListItemMobile';
import TokenLogo from 'ui/shared/TokenLogo'; import TokenLogo from 'ui/shared/TokenLogo';
import AddressAddToMetaMask from '../details/AddressAddToMetaMask'; import AddressAddToMetaMask from '../details/AddressAddToMetaMask';
......
...@@ -8,7 +8,7 @@ import appConfig from 'configs/app/config'; ...@@ -8,7 +8,7 @@ import appConfig from 'configs/app/config';
import Address from 'ui/shared/address/Address'; import Address from 'ui/shared/address/Address';
import AddressIcon from 'ui/shared/address/AddressIcon'; import AddressIcon from 'ui/shared/address/AddressIcon';
import AddressLink from 'ui/shared/address/AddressLink'; import AddressLink from 'ui/shared/address/AddressLink';
import ListItemMobile from 'ui/shared/ListItemMobile'; import ListItemMobile from 'ui/shared/ListItemMobile/ListItemMobile';
type Props = { type Props = {
item: AddressesItem; item: AddressesItem;
......
...@@ -3,7 +3,7 @@ import React, { useCallback } from 'react'; ...@@ -3,7 +3,7 @@ import React, { useCallback } from 'react';
import type { ApiKey } from 'types/api/account'; import type { ApiKey } from 'types/api/account';
import ApiKeySnippet from 'ui/shared/ApiKeySnippet'; import ApiKeySnippet from 'ui/shared/ApiKeySnippet';
import ListItemMobile from 'ui/shared/ListItemMobile'; import ListItemMobile from 'ui/shared/ListItemMobile/ListItemMobile';
import TableItemActionButtons from 'ui/shared/TableItemActionButtons'; import TableItemActionButtons from 'ui/shared/TableItemActionButtons';
interface Props { interface Props {
......
...@@ -15,7 +15,7 @@ import BlockTimestamp from 'ui/blocks/BlockTimestamp'; ...@@ -15,7 +15,7 @@ import BlockTimestamp from 'ui/blocks/BlockTimestamp';
import AddressLink from 'ui/shared/address/AddressLink'; import AddressLink from 'ui/shared/address/AddressLink';
import GasUsedToTargetRatio from 'ui/shared/GasUsedToTargetRatio'; import GasUsedToTargetRatio from 'ui/shared/GasUsedToTargetRatio';
import LinkInternal from 'ui/shared/LinkInternal'; import LinkInternal from 'ui/shared/LinkInternal';
import ListItemMobile from 'ui/shared/ListItemMobile'; import ListItemMobile from 'ui/shared/ListItemMobile/ListItemMobile';
import Utilization from 'ui/shared/Utilization/Utilization'; import Utilization from 'ui/shared/Utilization/Utilization';
interface Props { interface Props {
......
...@@ -3,7 +3,7 @@ import React, { useCallback } from 'react'; ...@@ -3,7 +3,7 @@ import React, { useCallback } from 'react';
import type { CustomAbi } from 'types/api/account'; import type { CustomAbi } from 'types/api/account';
import AddressSnippet from 'ui/shared/AddressSnippet'; import AddressSnippet from 'ui/shared/AddressSnippet';
import ListItemMobile from 'ui/shared/ListItemMobile'; import ListItemMobile from 'ui/shared/ListItemMobile/ListItemMobile';
import TableItemActionButtons from 'ui/shared/TableItemActionButtons'; import TableItemActionButtons from 'ui/shared/TableItemActionButtons';
interface Props { interface Props {
......
import { Box, Flex, Text, HStack, Icon } from '@chakra-ui/react'; import { Box, Flex, Text, Icon } from '@chakra-ui/react';
import { route } from 'nextjs-routes'; import { route } from 'nextjs-routes';
import React from 'react'; import React from 'react';
...@@ -6,26 +6,30 @@ import type { OutputRootsItem } from 'types/api/outputRoots'; ...@@ -6,26 +6,30 @@ import type { OutputRootsItem } from 'types/api/outputRoots';
import appConfig from 'configs/app/config'; import appConfig from 'configs/app/config';
import txIcon from 'icons/transactions.svg'; import txIcon from 'icons/transactions.svg';
import useTimeAgoIncrement from 'lib/hooks/useTimeAgoIncrement'; import dayjs from 'lib/date/dayjs';
import CopyToClipboard from 'ui/shared/CopyToClipboard'; import CopyToClipboard from 'ui/shared/CopyToClipboard';
import HashStringShortenDynamic from 'ui/shared/HashStringShortenDynamic'; import HashStringShortenDynamic from 'ui/shared/HashStringShortenDynamic';
import LinkExternal from 'ui/shared/LinkExternal'; import LinkExternal from 'ui/shared/LinkExternal';
import LinkInternal from 'ui/shared/LinkInternal'; import LinkInternal from 'ui/shared/LinkInternal';
import ListItemMobile from 'ui/shared/ListItemMobile'; import ListItemMobileGrid from 'ui/shared/ListItemMobile/ListItemMobileGrid';
type Props = { item: OutputRootsItem }; type Props = { item: OutputRootsItem };
const OutputRootsListItem = ({ item }: Props) => { const OutputRootsListItem = ({ item }: Props) => {
const timeAgo = useTimeAgoIncrement(item.l1_timestamp, false); const timeAgo = dayjs(item.l1_timestamp).fromNow();
return ( const items = [
<ListItemMobile rowGap={ 3 }> {
<Flex alignItems="center" justifyContent="space-between" w="100%"> name: 'L2 output index',
#{ item.l2_output_index } value: item.l2_output_index,
{ item.l1_timestamp && <Text variant="secondary" fontWeight="400" fontSize="sm">{ timeAgo }</Text> } },
</Flex> {
<HStack spacing={ 3 }> name: 'Age',
<Text fontSize="sm" fontWeight={ 500 }>L2 block</Text> value: timeAgo,
},
{
name: 'L2 block #',
value: (
<LinkInternal <LinkInternal
display="flex" display="flex"
width="fit-content" width="fit-content"
...@@ -34,20 +38,33 @@ const OutputRootsListItem = ({ item }: Props) => { ...@@ -34,20 +38,33 @@ const OutputRootsListItem = ({ item }: Props) => {
> >
{ item.l2_block_number } { item.l2_block_number }
</LinkInternal> </LinkInternal>
</HStack> ),
<HStack spacing={ 3 } width="100%"> },
<Text fontSize="sm" fontWeight={ 500 } whiteSpace="nowrap">Output root</Text> {
<Flex overflow="hidden" whiteSpace="nowrap" alignItems="center" w="100%"> name: 'L1 txn hash',
<Text variant="secondary" w="calc(100% - 36px)"><HashStringShortenDynamic hash={ item.output_root }/></Text> value: (
<CopyToClipboard text={ item.output_root } ml={ 2 }/> <LinkExternal
w="100%"
overflow="hidden"
href={ appConfig.L2.L1BaseUrl + route({ pathname: '/tx/[hash]', query: { hash: item.l1_tx_hash } }) }
>
<Icon as={ txIcon } boxSize={ 6 } mr={ 1 }/>
<Box w="calc(100% - 36px)" overflow="hidden" whiteSpace="nowrap"><HashStringShortenDynamic hash={ item.l1_tx_hash }/></Box>
</LinkExternal>
),
},
{
name: 'Output root',
value: (
<Flex overflow="hidden" whiteSpace="nowrap" alignItems="center" w="100%" justifyContent="space-between">
<Text variant="secondary" w="calc(100% - 24px)"><HashStringShortenDynamic hash={ item.output_root }/></Text>
<CopyToClipboard text={ item.output_root }/>
</Flex> </Flex>
</HStack> ),
<LinkExternal w="100%" href={ appConfig.L2.L1BaseUrl + route({ pathname: '/tx/[hash]', query: { hash: item.l1_tx_hash } }) }> },
<Icon as={ txIcon } boxSize={ 6 } mr={ 1 }/> ];
<Box w="calc(100% - 36px)" overflow="hidden" whiteSpace="nowrap"><HashStringShortenDynamic hash={ item.l1_tx_hash }/></Box>
</LinkExternal> return <ListItemMobileGrid items={ items } gridTemplateColumns="100px auto"/>;
</ListItemMobile>
);
}; };
export default OutputRootsListItem; export default OutputRootsListItem;
...@@ -7,7 +7,7 @@ import type { OutputRootsItem } from 'types/api/outputRoots'; ...@@ -7,7 +7,7 @@ import type { OutputRootsItem } from 'types/api/outputRoots';
import appConfig from 'configs/app/config'; import appConfig from 'configs/app/config';
import txIcon from 'icons/transactions.svg'; import txIcon from 'icons/transactions.svg';
import txBatchIcon from 'icons/txBatch.svg'; import txBatchIcon from 'icons/txBatch.svg';
import useTimeAgoIncrement from 'lib/hooks/useTimeAgoIncrement'; import dayjs from 'lib/date/dayjs';
import CopyToClipboard from 'ui/shared/CopyToClipboard'; import CopyToClipboard from 'ui/shared/CopyToClipboard';
import HashStringShortenDynamic from 'ui/shared/HashStringShortenDynamic'; import HashStringShortenDynamic from 'ui/shared/HashStringShortenDynamic';
import LinkExternal from 'ui/shared/LinkExternal'; import LinkExternal from 'ui/shared/LinkExternal';
...@@ -16,7 +16,7 @@ import LinkInternal from 'ui/shared/LinkInternal'; ...@@ -16,7 +16,7 @@ import LinkInternal from 'ui/shared/LinkInternal';
type Props = { item: OutputRootsItem }; type Props = { item: OutputRootsItem };
const OutputRootsTableItem = ({ item }: Props) => { const OutputRootsTableItem = ({ item }: Props) => {
const timeAgo = useTimeAgoIncrement(item.l1_timestamp, false); const timeAgo = dayjs(item.l1_timestamp).fromNow();
return ( return (
<Tr> <Tr>
......
...@@ -9,7 +9,7 @@ import OutputRoots from './OutputRoots'; ...@@ -9,7 +9,7 @@ import OutputRoots from './OutputRoots';
const OUTPUT_ROOTS_API_URL = buildApiUrl('output_roots'); const OUTPUT_ROOTS_API_URL = buildApiUrl('output_roots');
test('base view +@dark-mode', async({ mount, page }) => { test('base view +@mobile', async({ mount, page }) => {
await page.route('https://request-global.czilladx.com/serve/native.php?z=19260bf627546ab7242', (route) => route.fulfill({ await page.route('https://request-global.czilladx.com/serve/native.php?z=19260bf627546ab7242', (route) => route.fulfill({
status: 200, status: 200,
body: '', body: '',
......
...@@ -9,7 +9,7 @@ import Withdrawals from './Withdrawals'; ...@@ -9,7 +9,7 @@ import Withdrawals from './Withdrawals';
const WITHDRAWALS_API_URL = buildApiUrl('withdrawals'); const WITHDRAWALS_API_URL = buildApiUrl('withdrawals');
test('base view +@dark-mode', async({ mount, page }) => { test('base view +@mobile', async({ mount, page }) => {
await page.route('https://request-global.czilladx.com/serve/native.php?z=19260bf627546ab7242', (route) => route.fulfill({ await page.route('https://request-global.czilladx.com/serve/native.php?z=19260bf627546ab7242', (route) => route.fulfill({
status: 200, status: 200,
body: '', body: '',
......
...@@ -4,7 +4,7 @@ import React, { useCallback } from 'react'; ...@@ -4,7 +4,7 @@ import React, { useCallback } from 'react';
import type { AddressTag } from 'types/api/account'; import type { AddressTag } from 'types/api/account';
import AddressSnippet from 'ui/shared/AddressSnippet'; import AddressSnippet from 'ui/shared/AddressSnippet';
import ListItemMobile from 'ui/shared/ListItemMobile'; import ListItemMobile from 'ui/shared/ListItemMobile/ListItemMobile';
import TableItemActionButtons from 'ui/shared/TableItemActionButtons'; import TableItemActionButtons from 'ui/shared/TableItemActionButtons';
interface Props { interface Props {
......
...@@ -3,7 +3,7 @@ import React, { useCallback } from 'react'; ...@@ -3,7 +3,7 @@ import React, { useCallback } from 'react';
import type { TransactionTag } from 'types/api/account'; import type { TransactionTag } from 'types/api/account';
import ListItemMobile from 'ui/shared/ListItemMobile'; import ListItemMobile from 'ui/shared/ListItemMobile/ListItemMobile';
import TableItemActionButtons from 'ui/shared/TableItemActionButtons'; import TableItemActionButtons from 'ui/shared/TableItemActionButtons';
import TransactionSnippet from 'ui/shared/TransactionSnippet'; import TransactionSnippet from 'ui/shared/TransactionSnippet';
......
...@@ -4,7 +4,7 @@ import React, { useCallback } from 'react'; ...@@ -4,7 +4,7 @@ import React, { useCallback } from 'react';
import type { PublicTag } from 'types/api/account'; import type { PublicTag } from 'types/api/account';
import AddressSnippet from 'ui/shared/AddressSnippet'; import AddressSnippet from 'ui/shared/AddressSnippet';
import ListItemMobile from 'ui/shared/ListItemMobile'; import ListItemMobile from 'ui/shared/ListItemMobile/ListItemMobile';
import TableItemActionButtons from 'ui/shared/TableItemActionButtons'; import TableItemActionButtons from 'ui/shared/TableItemActionButtons';
import TruncatedTextTooltip from 'ui/shared/TruncatedTextTooltip'; import TruncatedTextTooltip from 'ui/shared/TruncatedTextTooltip';
......
...@@ -13,7 +13,7 @@ import AddressIcon from 'ui/shared/address/AddressIcon'; ...@@ -13,7 +13,7 @@ import AddressIcon from 'ui/shared/address/AddressIcon';
import AddressLink from 'ui/shared/address/AddressLink'; import AddressLink from 'ui/shared/address/AddressLink';
import HashStringShortenDynamic from 'ui/shared/HashStringShortenDynamic'; import HashStringShortenDynamic from 'ui/shared/HashStringShortenDynamic';
import LinkInternal from 'ui/shared/LinkInternal'; import LinkInternal from 'ui/shared/LinkInternal';
import ListItemMobile from 'ui/shared/ListItemMobile'; import ListItemMobile from 'ui/shared/ListItemMobile/ListItemMobile';
import TokenLogo from 'ui/shared/TokenLogo'; import TokenLogo from 'ui/shared/TokenLogo';
interface Props { interface Props {
......
import { Grid, Text, chakra } from '@chakra-ui/react';
import { motion } from 'framer-motion';
import React from 'react';
type Item = {
name: string;
value: string | React.ReactNode;
}
interface Props {
items: Array<Item>;
className?: string;
isAnimated?: boolean;
}
const ListItemMobileGrid = ({ isAnimated, items, className }: Props) => {
return (
<Grid
as={ motion.div }
w="100%"
initial={ isAnimated ? { opacity: 0, scale: 0.97 } : { opacity: 1, scale: 1 } }
animate={{ opacity: 1, scale: 1 }}
transitionDuration="normal"
transitionTimingFunction="linear"
rowGap={ 4 }
columnGap={ 2 }
gridTemplateColumns="max-content auto"
paddingY={ 6 }
borderColor="divider"
borderTopWidth="1px"
_last={{
borderBottomWidth: '1px',
}}
className={ className }
fontSize="sm"
>
{ items.map(item => Boolean(item.value) && (
<>
<Text >{ item.name }</Text>
{ typeof item.value === 'string' ? <Text variant="secondary">{ item.value }</Text> : item.value }
</>
)) }
</Grid>
);
};
export default chakra(ListItemMobileGrid);
...@@ -11,7 +11,7 @@ import Address from 'ui/shared/address/Address'; ...@@ -11,7 +11,7 @@ import Address from 'ui/shared/address/Address';
import AddressIcon from 'ui/shared/address/AddressIcon'; import AddressIcon from 'ui/shared/address/AddressIcon';
import AddressLink from 'ui/shared/address/AddressLink'; import AddressLink from 'ui/shared/address/AddressLink';
import InOutTag from 'ui/shared/InOutTag'; import InOutTag from 'ui/shared/InOutTag';
import ListItemMobile from 'ui/shared/ListItemMobile'; import ListItemMobile from 'ui/shared/ListItemMobile/ListItemMobile';
import TokenSnippet from 'ui/shared/TokenSnippet/TokenSnippet'; import TokenSnippet from 'ui/shared/TokenSnippet/TokenSnippet';
import { getTokenTransferTypeText } from 'ui/shared/TokenTransfer/helpers'; import { getTokenTransferTypeText } from 'ui/shared/TokenTransfer/helpers';
import TokenTransferNft from 'ui/shared/TokenTransfer/TokenTransferNft'; import TokenTransferNft from 'ui/shared/TokenTransfer/TokenTransferNft';
......
...@@ -7,7 +7,7 @@ import type { TokenHolder, TokenInfo } from 'types/api/token'; ...@@ -7,7 +7,7 @@ import type { TokenHolder, TokenInfo } from 'types/api/token';
import Address from 'ui/shared/address/Address'; import Address from 'ui/shared/address/Address';
import AddressIcon from 'ui/shared/address/AddressIcon'; import AddressIcon from 'ui/shared/address/AddressIcon';
import AddressLink from 'ui/shared/address/AddressLink'; import AddressLink from 'ui/shared/address/AddressLink';
import ListItemMobile from 'ui/shared/ListItemMobile'; import ListItemMobile from 'ui/shared/ListItemMobile/ListItemMobile';
import Utilization from 'ui/shared/Utilization/Utilization'; import Utilization from 'ui/shared/Utilization/Utilization';
interface Props { interface Props {
......
...@@ -11,7 +11,7 @@ import trimTokenSymbol from 'lib/token/trimTokenSymbol'; ...@@ -11,7 +11,7 @@ import trimTokenSymbol from 'lib/token/trimTokenSymbol';
import Address from 'ui/shared/address/Address'; import Address from 'ui/shared/address/Address';
import AddressIcon from 'ui/shared/address/AddressIcon'; import AddressIcon from 'ui/shared/address/AddressIcon';
import AddressLink from 'ui/shared/address/AddressLink'; import AddressLink from 'ui/shared/address/AddressLink';
import ListItemMobile from 'ui/shared/ListItemMobile'; import ListItemMobile from 'ui/shared/ListItemMobile/ListItemMobile';
import TokenTransferNft from 'ui/shared/TokenTransfer/TokenTransferNft'; import TokenTransferNft from 'ui/shared/TokenTransfer/TokenTransferNft';
type Props = TokenTransfer & {tokenId?: string}; type Props = TokenTransfer & {tokenId?: string};
......
...@@ -7,7 +7,7 @@ import getCurrencyValue from 'lib/getCurrencyValue'; ...@@ -7,7 +7,7 @@ import getCurrencyValue from 'lib/getCurrencyValue';
import AddressAddToMetaMask from 'ui/address/details/AddressAddToMetaMask'; import AddressAddToMetaMask from 'ui/address/details/AddressAddToMetaMask';
import AddressLink from 'ui/shared/address/AddressLink'; import AddressLink from 'ui/shared/address/AddressLink';
import CopyToClipboard from 'ui/shared/CopyToClipboard'; import CopyToClipboard from 'ui/shared/CopyToClipboard';
import ListItemMobile from 'ui/shared/ListItemMobile'; import ListItemMobile from 'ui/shared/ListItemMobile/ListItemMobile';
import TokenLogo from 'ui/shared/TokenLogo'; import TokenLogo from 'ui/shared/TokenLogo';
type Props = { type Props = {
......
...@@ -9,7 +9,7 @@ import eastArrowIcon from 'icons/arrows/east.svg'; ...@@ -9,7 +9,7 @@ import eastArrowIcon from 'icons/arrows/east.svg';
import Address from 'ui/shared/address/Address'; import Address from 'ui/shared/address/Address';
import AddressIcon from 'ui/shared/address/AddressIcon'; import AddressIcon from 'ui/shared/address/AddressIcon';
import AddressLink from 'ui/shared/address/AddressLink'; import AddressLink from 'ui/shared/address/AddressLink';
import ListItemMobile from 'ui/shared/ListItemMobile'; import ListItemMobile from 'ui/shared/ListItemMobile/ListItemMobile';
import TxStatus from 'ui/shared/TxStatus'; import TxStatus from 'ui/shared/TxStatus';
import { TX_INTERNALS_ITEMS } from 'ui/tx/internals/utils'; import { TX_INTERNALS_ITEMS } from 'ui/tx/internals/utils';
......
...@@ -11,7 +11,7 @@ import getNetworkValidatorTitle from 'lib/networks/getNetworkValidatorTitle'; ...@@ -11,7 +11,7 @@ import getNetworkValidatorTitle from 'lib/networks/getNetworkValidatorTitle';
import Address from 'ui/shared/address/Address'; import Address from 'ui/shared/address/Address';
// import AddressIcon from 'ui/shared/address/AddressIcon'; // import AddressIcon from 'ui/shared/address/AddressIcon';
import AddressLink from 'ui/shared/address/AddressLink'; import AddressLink from 'ui/shared/address/AddressLink';
import ListItemMobile from 'ui/shared/ListItemMobile'; import ListItemMobile from 'ui/shared/ListItemMobile/ListItemMobile';
import TxStateStorageItem from './TxStateStorageItem'; import TxStateStorageItem from './TxStateStorageItem';
......
import { Box, Flex, Text, HStack, Icon, VStack } from '@chakra-ui/react'; import { Box, Icon, VStack } from '@chakra-ui/react';
import { route } from 'nextjs-routes'; import { route } from 'nextjs-routes';
import React from 'react'; import React from 'react';
...@@ -7,20 +7,21 @@ import type { TxnBatchesItem } from 'types/api/txnBatches'; ...@@ -7,20 +7,21 @@ import type { TxnBatchesItem } from 'types/api/txnBatches';
import appConfig from 'configs/app/config'; import appConfig from 'configs/app/config';
import txIcon from 'icons/transactions.svg'; import txIcon from 'icons/transactions.svg';
import txBatchIcon from 'icons/txBatch.svg'; import txBatchIcon from 'icons/txBatch.svg';
import useTimeAgoIncrement from 'lib/hooks/useTimeAgoIncrement'; import dayjs from 'lib/date/dayjs';
import HashStringShortenDynamic from 'ui/shared/HashStringShortenDynamic'; import HashStringShortenDynamic from 'ui/shared/HashStringShortenDynamic';
import LinkExternal from 'ui/shared/LinkExternal'; import LinkExternal from 'ui/shared/LinkExternal';
import LinkInternal from 'ui/shared/LinkInternal'; import LinkInternal from 'ui/shared/LinkInternal';
import ListItemMobile from 'ui/shared/ListItemMobile'; import ListItemMobileGrid from 'ui/shared/ListItemMobile/ListItemMobileGrid';
type Props = { item: TxnBatchesItem }; type Props = { item: TxnBatchesItem };
const TxnBatchesListItem = ({ item }: Props) => { const TxnBatchesListItem = ({ item }: Props) => {
const timeAgo = useTimeAgoIncrement(item.l1_tx_timestamp, false); const timeAgo = dayjs(item.l1_tx_timestamp).fromNow();
return ( const items = [
<ListItemMobile rowGap={ 3 }> {
<Flex alignItems="center" justifyContent="space-between" w="100%"> name: 'L2 block #',
value: (
<LinkInternal <LinkInternal
fontWeight={ 600 } fontWeight={ 600 }
display="flex" display="flex"
...@@ -31,34 +32,51 @@ const TxnBatchesListItem = ({ item }: Props) => { ...@@ -31,34 +32,51 @@ const TxnBatchesListItem = ({ item }: Props) => {
<Icon as={ txBatchIcon } boxSize={ 6 } mr={ 1 }/> <Icon as={ txBatchIcon } boxSize={ 6 } mr={ 1 }/>
{ item.l2_block_number } { item.l2_block_number }
</LinkInternal> </LinkInternal>
<Text variant="secondary" fontWeight="400" fontSize="sm">{ timeAgo }</Text> ),
</Flex> },
<HStack spacing={ 3 } width="100%"> {
<Text fontSize="sm" fontWeight={ 500 } whiteSpace="nowrap">L2 block txn count</Text> name: 'L2 block txn count',
value: (
<LinkInternal href={ route({ pathname: '/block/[height]', query: { height: item.l2_block_number.toString(), tab: 'txs' } }) }> <LinkInternal href={ route({ pathname: '/block/[height]', query: { height: item.l2_block_number.toString(), tab: 'txs' } }) }>
{ item.tx_count } { item.tx_count }
</LinkInternal> </LinkInternal>
</HStack> ),
<HStack spacing={ 3 }> },
<Text fontSize="sm" fontWeight={ 500 }>Epoch number</Text> {
<LinkExternal href={ appConfig.L2.L1BaseUrl + route({ pathname: '/block/[height]', query: { height: item.epoch_number.toString() } }) }> name: 'Epoch number',
value: (
<LinkExternal
fontWeight={ 600 }
href={ appConfig.L2.L1BaseUrl + route({ pathname: '/block/[height]', query: { height: item.epoch_number.toString() } }) }
>
{ item.epoch_number } { item.epoch_number }
</LinkExternal> </LinkExternal>
</HStack> ),
<VStack spacing={ 3 } w="100%"> },
{ item.l1_tx_hashes.map(hash => ( {
<LinkExternal name: 'L1 txn hash',
w="100%" value: (
href={ appConfig.L2.L1BaseUrl + route({ pathname: '/tx/[hash]', query: { hash: hash } }) } <VStack spacing={ 3 } w="100%" overflow="hidden">
key={ hash } { item.l1_tx_hashes.map(hash => (
> <LinkExternal
<Icon as={ txIcon } boxSize={ 6 } mr={ 1 }/> w="100%"
<Box w="calc(100% - 36px)" overflow="hidden" whiteSpace="nowrap"><HashStringShortenDynamic hash={ hash }/></Box> href={ appConfig.L2.L1BaseUrl + route({ pathname: '/tx/[hash]', query: { hash: hash } }) }
</LinkExternal> key={ hash }
)) } >
</VStack> <Icon as={ txIcon } boxSize={ 6 } mr={ 1 }/>
</ListItemMobile> <Box w="calc(100% - 36px)" overflow="hidden" whiteSpace="nowrap"><HashStringShortenDynamic hash={ hash }/></Box>
); </LinkExternal>
)) }
</VStack>
),
},
{
name: 'Age',
value: timeAgo,
},
];
return <ListItemMobileGrid items={ items } gridTemplateColumns="100px auto"/>;
}; };
export default TxnBatchesListItem; export default TxnBatchesListItem;
...@@ -7,7 +7,7 @@ import type { TxnBatchesItem } from 'types/api/txnBatches'; ...@@ -7,7 +7,7 @@ import type { TxnBatchesItem } from 'types/api/txnBatches';
import appConfig from 'configs/app/config'; import appConfig from 'configs/app/config';
import txIcon from 'icons/transactions.svg'; import txIcon from 'icons/transactions.svg';
import txBatchIcon from 'icons/txBatch.svg'; import txBatchIcon from 'icons/txBatch.svg';
import useTimeAgoIncrement from 'lib/hooks/useTimeAgoIncrement'; import dayjs from 'lib/date/dayjs';
import HashStringShortenDynamic from 'ui/shared/HashStringShortenDynamic'; import HashStringShortenDynamic from 'ui/shared/HashStringShortenDynamic';
import LinkExternal from 'ui/shared/LinkExternal'; import LinkExternal from 'ui/shared/LinkExternal';
import LinkInternal from 'ui/shared/LinkInternal'; import LinkInternal from 'ui/shared/LinkInternal';
...@@ -15,7 +15,7 @@ import LinkInternal from 'ui/shared/LinkInternal'; ...@@ -15,7 +15,7 @@ import LinkInternal from 'ui/shared/LinkInternal';
type Props = { item: TxnBatchesItem }; type Props = { item: TxnBatchesItem };
const TxnBatchesTableItem = ({ item }: Props) => { const TxnBatchesTableItem = ({ item }: Props) => {
const timeAgo = useTimeAgoIncrement(item.l1_tx_timestamp, false); const timeAgo = dayjs(item.l1_tx_timestamp).fromNow();
return ( return (
<Tr> <Tr>
......
...@@ -20,7 +20,7 @@ import AddressIcon from 'ui/shared/address/AddressIcon'; ...@@ -20,7 +20,7 @@ import AddressIcon from 'ui/shared/address/AddressIcon';
import AddressLink from 'ui/shared/address/AddressLink'; import AddressLink from 'ui/shared/address/AddressLink';
import InOutTag from 'ui/shared/InOutTag'; import InOutTag from 'ui/shared/InOutTag';
import LinkInternal from 'ui/shared/LinkInternal'; import LinkInternal from 'ui/shared/LinkInternal';
import ListItemMobile from 'ui/shared/ListItemMobile'; import ListItemMobile from 'ui/shared/ListItemMobile/ListItemMobile';
import TxStatus from 'ui/shared/TxStatus'; import TxStatus from 'ui/shared/TxStatus';
import TxAdditionalInfo from 'ui/txs/TxAdditionalInfo'; import TxAdditionalInfo from 'ui/txs/TxAdditionalInfo';
import TxType from 'ui/txs/TxType'; import TxType from 'ui/txs/TxType';
......
...@@ -6,7 +6,7 @@ import type { TWatchlistItem } from 'types/client/account'; ...@@ -6,7 +6,7 @@ import type { TWatchlistItem } from 'types/client/account';
import useApiFetch from 'lib/api/useApiFetch'; import useApiFetch from 'lib/api/useApiFetch';
import useToast from 'lib/hooks/useToast'; import useToast from 'lib/hooks/useToast';
import ListItemMobile from 'ui/shared/ListItemMobile'; import ListItemMobile from 'ui/shared/ListItemMobile/ListItemMobile';
import TableItemActionButtons from 'ui/shared/TableItemActionButtons'; import TableItemActionButtons from 'ui/shared/TableItemActionButtons';
import WatchListAddressItem from './WatchListAddressItem'; import WatchListAddressItem from './WatchListAddressItem';
......
import { Box, Flex, Text, HStack, Icon } from '@chakra-ui/react'; import { Box, Icon } from '@chakra-ui/react';
import { route } from 'nextjs-routes'; import { route } from 'nextjs-routes';
import React from 'react'; import React from 'react';
...@@ -7,73 +7,79 @@ import type { WithdrawalsItem } from 'types/api/withdrawals'; ...@@ -7,73 +7,79 @@ import type { WithdrawalsItem } from 'types/api/withdrawals';
import appConfig from 'configs/app/config'; import appConfig from 'configs/app/config';
import txIcon from 'icons/transactions.svg'; import txIcon from 'icons/transactions.svg';
import dayjs from 'lib/date/dayjs'; import dayjs from 'lib/date/dayjs';
import useTimeAgoIncrement from 'lib/hooks/useTimeAgoIncrement';
import Address from 'ui/shared/address/Address'; import Address from 'ui/shared/address/Address';
import AddressIcon from 'ui/shared/address/AddressIcon'; import AddressIcon from 'ui/shared/address/AddressIcon';
import AddressLink from 'ui/shared/address/AddressLink'; import AddressLink from 'ui/shared/address/AddressLink';
import HashStringShorten from 'ui/shared/HashStringShorten'; import HashStringShortenDynamic from 'ui/shared/HashStringShortenDynamic';
import LinkExternal from 'ui/shared/LinkExternal'; import LinkExternal from 'ui/shared/LinkExternal';
import LinkInternal from 'ui/shared/LinkInternal'; import LinkInternal from 'ui/shared/LinkInternal';
import ListItemMobile from 'ui/shared/ListItemMobile'; import ListItemMobileGrid from 'ui/shared/ListItemMobile/ListItemMobileGrid';
type Props = { item: WithdrawalsItem }; type Props = { item: WithdrawalsItem };
const WithdrawalsListItem = ({ item }: Props) => { const WithdrawalsListItem = ({ item }: Props) => {
const timeAgo = useTimeAgoIncrement(item.l2_timestamp, false); const timeAgo = item.l2_timestamp ? dayjs(item.l2_timestamp).fromNow() : '';
const timeToEnd = item.challenge_period_end ? dayjs(item.challenge_period_end).fromNow(true) + ' left' : ''; const timeToEnd = item.challenge_period_end ? dayjs(item.challenge_period_end).fromNow(true) + ' left' : '';
return ( const items = [
<ListItemMobile rowGap={ 3 }> {
<Flex alignItems="center" justifyContent="space-between" w="100%"> name: 'Msg nonce',
value: item.msg_nonce_version + '-' + item.msg_nonce,
},
{
name: 'From',
value: item.from ? (
<Address>
<AddressIcon address={ item.from }/>
<AddressLink hash={ item.from?.hash } type="address" truncation="dynamic" ml={ 2 }/>
</Address>
) : null,
},
{
name: 'L2 txn hash',
value: (
<LinkInternal <LinkInternal
href={ route({ pathname: '/tx/[hash]', query: { hash: item.l2_tx_hash } }) } href={ route({ pathname: '/tx/[hash]', query: { hash: item.l2_tx_hash } }) }
display="flex" display="flex"
width="fit-content" width="fit-content"
alignItems="center" alignItems="center"
overflow="hidden"
w="100%"
> >
<Icon as={ txIcon } boxSize={ 6 } mr={ 1 }/> <Icon as={ txIcon } boxSize={ 6 } mr={ 1 }/>
<Box w="calc(100% - 36px)" overflow="hidden" whiteSpace="nowrap"><HashStringShorten hash={ item.l2_tx_hash }/></Box> <Box w="calc(100% - 36px)" overflow="hidden" whiteSpace="nowrap"><HashStringShortenDynamic hash={ item.l2_tx_hash }/></Box>
</LinkInternal> </LinkInternal>
<Text variant="secondary">{ timeAgo }</Text> ),
</Flex> },
<HStack spacing={ 3 } width="100%"> {
<Text fontSize="sm" fontWeight={ 500 } whiteSpace="nowrap">Msg nonce</Text> name: 'Age',
<Text variant="secondary">{ item.msg_nonce_version + '-' + item.msg_nonce }</Text> value: timeAgo,
</HStack> },
<HStack spacing={ 3 } width="100%"> {
<Text fontSize="sm" fontWeight={ 500 } whiteSpace="nowrap">Status</Text> name: 'Status',
{ item.status === 'Ready for relay' ? value: item.status === 'Ready for relay' ?
<LinkExternal href={ appConfig.L2.withdrawalUrl }>{ item.status }</LinkExternal> : <LinkExternal href={ appConfig.L2.withdrawalUrl }>{ item.status }</LinkExternal> :
<Text variant="secondary">{ item.status }</Text> item.status,
} },
</HStack> {
{ item.from && ( name: 'L1 txn hash',
<HStack spacing={ 3 } width="100%"> value: item.l1_tx_hash ? (
<Text fontSize="sm" fontWeight={ 500 } whiteSpace="nowrap">From</Text> <LinkExternal
<Address> href={ appConfig.L2.L1BaseUrl + route({ pathname: '/tx/[hash]', query: { hash: item.l1_tx_hash } }) }
<AddressIcon address={ item.from }/> w="100%"
<AddressLink hash={ item.from.hash } type="address" truncation="constant" ml={ 2 }/> overflow="hidden"
</Address> >
</HStack> <Box w="calc(100% - 16px)" overflow="hidden" whiteSpace="nowrap"><HashStringShortenDynamic hash={ item.l1_tx_hash }/></Box>
) } </LinkExternal>
{ item.l1_tx_hash && ( ) : null,
<HStack spacing={ 3 } width="100%"> },
<Text fontSize="sm" fontWeight={ 500 } whiteSpace="nowrap">L1 txn hash</Text> {
<LinkExternal name: 'Time left',
href={ appConfig.L2.L1BaseUrl + route({ pathname: '/tx/[hash]', query: { hash: item.l1_tx_hash } }) } value: timeToEnd,
> },
<HashStringShorten hash={ item.l1_tx_hash }/> ];
</LinkExternal>
</HStack> return <ListItemMobileGrid items={ items } gridTemplateColumns="92px auto"/>;
) }
{ item.challenge_period_end && (
<HStack spacing={ 3 } width="100%">
<Text fontSize="sm" fontWeight={ 500 } whiteSpace="nowrap">Time left</Text>
<Text variant="secondary">{ timeToEnd }</Text>
</HStack>
) }
</ListItemMobile>
);
}; };
export default WithdrawalsListItem; export default WithdrawalsListItem;
...@@ -7,7 +7,6 @@ import type { WithdrawalsItem } from 'types/api/withdrawals'; ...@@ -7,7 +7,6 @@ import type { WithdrawalsItem } from 'types/api/withdrawals';
import appConfig from 'configs/app/config'; import appConfig from 'configs/app/config';
import txIcon from 'icons/transactions.svg'; import txIcon from 'icons/transactions.svg';
import dayjs from 'lib/date/dayjs'; import dayjs from 'lib/date/dayjs';
import useTimeAgoIncrement from 'lib/hooks/useTimeAgoIncrement';
import Address from 'ui/shared/address/Address'; import Address from 'ui/shared/address/Address';
import AddressIcon from 'ui/shared/address/AddressIcon'; import AddressIcon from 'ui/shared/address/AddressIcon';
import AddressLink from 'ui/shared/address/AddressLink'; import AddressLink from 'ui/shared/address/AddressLink';
...@@ -18,7 +17,7 @@ import LinkInternal from 'ui/shared/LinkInternal'; ...@@ -18,7 +17,7 @@ import LinkInternal from 'ui/shared/LinkInternal';
type Props = { item: WithdrawalsItem }; type Props = { item: WithdrawalsItem };
const WithdrawalsTableItem = ({ item }: Props) => { const WithdrawalsTableItem = ({ item }: Props) => {
const timeAgo = useTimeAgoIncrement(item.l2_timestamp, false) || 'N/A'; const timeAgo = item.l2_timestamp ? dayjs(item.l2_timestamp).fromNow() : 'N/A';
const timeToEnd = item.challenge_period_end ? dayjs(item.challenge_period_end).fromNow(true) + ' left' : '-'; const timeToEnd = item.challenge_period_end ? dayjs(item.challenge_period_end).fromNow(true) + ' left' : '-';
return ( return (
...@@ -66,7 +65,7 @@ const WithdrawalsTableItem = ({ item }: Props) => { ...@@ -66,7 +65,7 @@ const WithdrawalsTableItem = ({ item }: Props) => {
} }
</Td> </Td>
<Td verticalAlign="middle"> <Td verticalAlign="middle">
{ timeToEnd } <Text variant="secondary">{ timeToEnd }</Text>
</Td> </Td>
</Tr> </Tr>
); );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment