Skip to content

Commit

Permalink
Merge pull request #1471 from blockscout/tom2drum/issue-1448
Browse files Browse the repository at this point in the history
Replace "in/out" with arrow
  • Loading branch information
tom2drum authored Jan 17, 2024
2 parents 528a232 + ba685cf commit 63b5efd
Show file tree
Hide file tree
Showing 78 changed files with 414 additions and 451 deletions.
4 changes: 2 additions & 2 deletions ui/address/AddressTxsFilter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ const AddressTxsFilter = ({ onFilterChange, defaultFilter, isActive, isLoading }
<MenuList zIndex={ 2 }>
<MenuOptionGroup defaultValue={ defaultFilter || 'all' } title="Address" type="radio" onChange={ onFilterChange }>
<MenuItemOption value="all">All</MenuItemOption>
<MenuItemOption value="from">From</MenuItemOption>
<MenuItemOption value="to">To</MenuItemOption>
<MenuItemOption value="from">Outgoing transactions</MenuItemOption>
<MenuItemOption value="to">Incoming transactions</MenuItemOption>
</MenuOptionGroup>
</MenuList>
</Menu>
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 9 additions & 29 deletions ui/address/internals/AddressIntTxsListItem.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
import { Flex, Box, HStack, Skeleton } from '@chakra-ui/react';
import { Flex, HStack, Skeleton } from '@chakra-ui/react';
import BigNumber from 'bignumber.js';
import React from 'react';

import type { InternalTransaction } from 'types/api/internalTransaction';

import config from 'configs/app';
import dayjs from 'lib/date/dayjs';
import AddressFromTo from 'ui/shared/address/AddressFromTo';
import Tag from 'ui/shared/chakra/Tag';
import AddressEntity from 'ui/shared/entities/address/AddressEntity';
import BlockEntity from 'ui/shared/entities/block/BlockEntity';
import TxEntity from 'ui/shared/entities/tx/TxEntity';
import IconSvg from 'ui/shared/IconSvg';
import InOutTag from 'ui/shared/InOutTag';
import ListItemMobile from 'ui/shared/ListItemMobile/ListItemMobile';
import TxStatus from 'ui/shared/statusTag/TxStatus';
import { TX_INTERNALS_ITEMS } from 'ui/tx/internals/utils';
Expand All @@ -35,9 +33,6 @@ const TxInternalsListItem = ({
const typeTitle = TX_INTERNALS_ITEMS.find(({ id }) => id === type)?.title;
const toData = to ? to : createdContract;

const isOut = Boolean(currentAddress && currentAddress === from.hash);
const isIn = Boolean(currentAddress && currentAddress === toData?.hash);

return (
<ListItemMobile rowGap={ 3 }>
<Flex columnGap={ 2 }>
Expand Down Expand Up @@ -65,28 +60,13 @@ const TxInternalsListItem = ({
lineHeight={ 5 }
/>
</HStack>
<Box w="100%" display="flex" columnGap={ 3 }>
<AddressEntity
address={ from }
isLoading={ isLoading }
noLink={ isOut }
noCopy={ isOut }
width="calc((100% - 48px) / 2)"
/>
{ (isIn || isOut) ?
<InOutTag isIn={ isIn } isOut={ isOut } isLoading={ isLoading }/> :
<IconSvg name="arrows/east" boxSize={ 6 } color="gray.500" isLoading={ isLoading }/>
}
{ toData && (
<AddressEntity
address={ toData }
isLoading={ isLoading }
noLink={ isIn }
noCopy={ isIn }
width="calc((100% - 48px) / 2)"
/>
) }
</Box>
<AddressFromTo
from={ from }
to={ toData }
current={ currentAddress }
isLoading={ isLoading }
w="100%"
/>
<HStack spacing={ 3 }>
<Skeleton isLoaded={ !isLoading } fontSize="sm" fontWeight={ 500 }>Value { config.chain.currency.symbol }</Skeleton>
<Skeleton isLoaded={ !isLoading } fontSize="sm" color="text_secondary" minW={ 6 }>
Expand Down
6 changes: 2 additions & 4 deletions ui/address/internals/AddressIntTxsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,9 @@ const AddressIntTxsTable = ({ data, currentAddress, isLoading }: Props) => {
<Th width="15%">Parent txn hash</Th>
<Th width="15%">Type</Th>
<Th width="10%">Block</Th>
<Th width="20%">From</Th>
<Th width="48px" px={ 0 }/>
<Th width="20%">To</Th>
<Th width="40%">From/To</Th>
<Th width="20%" isNumeric>
Value { config.chain.currency.symbol }
Value { config.chain.currency.symbol }
</Th>
</Tr>
</Thead>
Expand Down
35 changes: 5 additions & 30 deletions ui/address/internals/AddressIntTxsTableItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@ import type { InternalTransaction } from 'types/api/internalTransaction';

import config from 'configs/app';
import useTimeAgoIncrement from 'lib/hooks/useTimeAgoIncrement';
import AddressFromTo from 'ui/shared/address/AddressFromTo';
import Tag from 'ui/shared/chakra/Tag';
import AddressEntity from 'ui/shared/entities/address/AddressEntity';
import BlockEntity from 'ui/shared/entities/block/BlockEntity';
import TxEntity from 'ui/shared/entities/tx/TxEntity';
import IconSvg from 'ui/shared/IconSvg';
import InOutTag from 'ui/shared/InOutTag';
import TxStatus from 'ui/shared/statusTag/TxStatus';
import { TX_INTERNALS_ITEMS } from 'ui/tx/internals/utils';

Expand All @@ -34,9 +32,6 @@ const AddressIntTxsTableItem = ({
const typeTitle = TX_INTERNALS_ITEMS.find(({ id }) => id === type)?.title;
const toData = to ? to : createdContract;

const isOut = Boolean(currentAddress && currentAddress === from.hash);
const isIn = Boolean(currentAddress && currentAddress === toData?.hash);

const timeAgo = useTimeAgoIncrement(timestamp, true);

return (
Expand Down Expand Up @@ -77,33 +72,13 @@ const AddressIntTxsTableItem = ({
/>
</Td>
<Td verticalAlign="middle">
<AddressEntity
address={ from }
<AddressFromTo
from={ from }
to={ toData }
current={ currentAddress }
isLoading={ isLoading }
noLink={ isOut }
noCopy={ isOut }
w="min-content"
maxW="100%"
/>
</Td>
<Td px={ 0 } verticalAlign="middle">
{ (isIn || isOut) ?
<InOutTag isIn={ isIn } isOut={ isOut } isLoading={ isLoading } w="100%"/> :
<IconSvg name="arrows/east" boxSize={ 6 } color="gray.500" isLoading={ isLoading }/>
}
</Td>
<Td verticalAlign="middle">
{ toData && (
<AddressEntity
address={ toData }
isLoading={ isLoading }
noLink={ isIn }
noCopy={ isIn }
w="min-content"
maxW="100%"
/>
) }
</Td>
<Td isNumeric verticalAlign="middle">
<Skeleton isLoaded={ !isLoading } display="inline-block" minW={ 6 }>
{ BigNumber(value).div(BigNumber(10 ** config.chain.currency.decimals)).toFormat() }
Expand Down
41 changes: 8 additions & 33 deletions ui/home/LatestTxsItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@ import type { Transaction } from 'types/api/transaction';
import config from 'configs/app';
import getValueWithUnit from 'lib/getValueWithUnit';
import useTimeAgoIncrement from 'lib/hooks/useTimeAgoIncrement';
import AddressEntity from 'ui/shared/entities/address/AddressEntity';
import AddressFromTo from 'ui/shared/address/AddressFromTo';
import TxEntity from 'ui/shared/entities/tx/TxEntity';
import IconSvg from 'ui/shared/IconSvg';
import TxStatus from 'ui/shared/statusTag/TxStatus';
import TxFeeStability from 'ui/shared/tx/TxFeeStability';
import TxWatchListTags from 'ui/shared/tx/TxWatchListTags';
Expand All @@ -35,7 +34,7 @@ const LatestTxsItem = ({ tx, isLoading }: Props) => {
return (
<Grid
gridTemplateColumns={{
lg: columnNum === 2 ? '3fr minmax(auto, 160px)' : '3fr minmax(auto, 160px) 150px',
lg: columnNum === 2 ? '3fr minmax(auto, 180px)' : '3fr minmax(auto, 180px) 150px',
xl: columnNum === 2 ? '3fr minmax(auto, 250px)' : '3fr minmax(auto, 275px) 150px',
}}
gridGap={ 8 }
Expand Down Expand Up @@ -80,36 +79,12 @@ const LatestTxsItem = ({ tx, isLoading }: Props) => {
</Flex>
</Box>
</Flex>
<Flex alignItems="center" alignSelf="flex-start">
<IconSvg
name="arrows/east"
boxSize={ 6 }
color="gray.500"
transform="rotate(90deg)"
isLoading={ isLoading }
flexShrink={ 0 }
/>
<Flex ml={ 1 } maxW="calc(100% - 24px)" flexDir="column" rowGap="1px">
<AddressEntity
isLoading={ isLoading }
address={ tx.from }
fontSize="sm"
lineHeight={ 5 }
my="5px"
fontWeight="500"
/>
{ dataTo && (
<AddressEntity
isLoading={ isLoading }
address={ dataTo }
fontSize="sm"
lineHeight={ 5 }
my="5px"
fontWeight="500"
/>
) }
</Flex>
</Flex>
<AddressFromTo
from={ tx.from }
to={ dataTo }
isLoading={ isLoading }
mode="compact"
/>
<Flex flexDir="column">
{ !config.UI.views.tx.hiddenFields?.value && (
<Skeleton isLoaded={ !isLoading } my="3px">
Expand Down
36 changes: 9 additions & 27 deletions ui/home/LatestTxsItemMobile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ import type { Transaction } from 'types/api/transaction';
import config from 'configs/app';
import getValueWithUnit from 'lib/getValueWithUnit';
import useTimeAgoIncrement from 'lib/hooks/useTimeAgoIncrement';
import AddressEntity from 'ui/shared/entities/address/AddressEntity';
import AddressFromTo from 'ui/shared/address/AddressFromTo';
import TxEntity from 'ui/shared/entities/tx/TxEntity';
import IconSvg from 'ui/shared/IconSvg';
import TxStatus from 'ui/shared/statusTag/TxStatus';
import TxFeeStability from 'ui/shared/tx/TxFeeStability';
import TxWatchListTags from 'ui/shared/tx/TxWatchListTags';
Expand Down Expand Up @@ -66,31 +65,14 @@ const LatestTxsItem = ({ tx, isLoading }: Props) => {
</Skeleton>
) }
</Flex>
<Flex alignItems="center" mb={ 3 }>
<AddressEntity
isLoading={ isLoading }
address={ tx.from }
truncation="constant"
fontSize="sm"
fontWeight="500"
mr={ 2 }
/>
<IconSvg
name="arrows/east"
boxSize={ 6 }
color="gray.500"
isLoading={ isLoading }
/>
{ dataTo && (
<AddressEntity
isLoading={ isLoading }
address={ dataTo }
truncation="constant"
fontSize="sm"
fontWeight="500"
/>
) }
</Flex>
<AddressFromTo
from={ tx.from }
to={ dataTo }
isLoading={ isLoading }
fontSize="sm"
fontWeight="500"
mb={ 3 }
/>
{ !config.UI.views.tx.hiddenFields?.value && (
<Skeleton isLoaded={ !isLoading } mb={ 2 } fontSize="sm" w="fit-content">
<Text as="span">Value { config.chain.currency.symbol } </Text>
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 3 additions & 2 deletions ui/shared/CopyToClipboard.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IconButton, Tooltip, useClipboard, chakra, useDisclosure, Skeleton } from '@chakra-ui/react';
import { IconButton, Tooltip, useClipboard, chakra, useDisclosure, Skeleton, useColorModeValue } from '@chakra-ui/react';
import React, { useEffect, useState } from 'react';

import IconSvg from 'ui/shared/IconSvg';
Expand All @@ -14,6 +14,7 @@ const CopyToClipboard = ({ text, className, isLoading }: Props) => {
const [ copied, setCopied ] = useState(false);
// have to implement controlled tooltip because of the issue - https://github.com/chakra-ui/chakra-ui/issues/7107
const { isOpen, onOpen, onClose } = useDisclosure();
const iconColor = useColorModeValue('gray.400', 'gray.500');

useEffect(() => {
if (hasCopied) {
Expand All @@ -34,7 +35,7 @@ const CopyToClipboard = ({ text, className, isLoading }: Props) => {
icon={ <IconSvg name="copy" boxSize={ 5 }/> }
w="20px"
h="20px"
color="gray.400"
color={ iconColor }
variant="simple"
display="inline-block"
flexShrink={ 0 }
Expand Down
6 changes: 3 additions & 3 deletions ui/shared/IconSvg.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ interface Props extends HTMLChakraProps<'div'> {
isLoading?: boolean;
}

const IconSvg = ({ name, isLoading, ...props }: Props) => {
const IconSvg = ({ name, isLoading, ...props }: Props, ref: React.ForwardedRef<HTMLDivElement>) => {
return (
<Skeleton isLoaded={ !isLoading } display="inline-block" { ...props }>
<Skeleton isLoaded={ !isLoading } display="inline-block" { ...props } ref={ ref }>
<chakra.svg w="100%" h="100%">
<use href={ `${ href }#${ name }` }/>
</chakra.svg>
</Skeleton>
);
};

export default IconSvg;
export default React.forwardRef(IconSvg);
33 changes: 0 additions & 33 deletions ui/shared/InOutTag.tsx

This file was deleted.

6 changes: 3 additions & 3 deletions ui/shared/TokenTransfer/TokenTransferFilter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const TokenTransferFilter = ({
const isInitialLoading = useIsInitialLoading(isLoading);

return (
<PopoverFilter appliedFiltersNum={ appliedFiltersNum } contentProps={{ w: '200px' }} isLoading={ isInitialLoading }>
<PopoverFilter appliedFiltersNum={ appliedFiltersNum } contentProps={{ w: '220px' }} isLoading={ isInitialLoading }>
{ withAddressFilter && (
<>
<Text variant="secondary" fontWeight={ 600 }>Address</Text>
Expand All @@ -49,8 +49,8 @@ const TokenTransferFilter = ({
>
<Stack spacing={ 4 }>
<Radio value="all"><Text fontSize="md">All</Text></Radio>
<Radio value="from"><Text fontSize="md">From</Text></Radio>
<Radio value="to"><Text fontSize="md">To</Text></Radio>
<Radio value="from"><Text fontSize="md">Outgoing transfers</Text></Radio>
<Radio value="to"><Text fontSize="md">Incoming transfers</Text></Radio>
</Stack>
</RadioGroup>
</>
Expand Down
Loading

0 comments on commit 63b5efd

Please sign in to comment.