Skip to content

Commit adad0a2

Browse files
authored
Address widget improvements (#2932)
1 parent 8862ad5 commit adad0a2

8 files changed

+53
-47
lines changed

ui/address/AddressDetails.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ const AddressDetails = ({ addressQuery, countersQuery, isLoading }: Props) => {
4343

4444
const addressHash = getQueryParamString(router.query.hash);
4545

46-
const address3rdPartyWidgets = useAddress3rdPartyWidgets(addressQuery.data?.is_contract ? 'contract' : 'eoa', addressQuery.isPlaceholderData);
46+
const addressType = addressQuery.data?.is_contract && addressQuery.data?.proxy_type !== 'eip7702' ? 'contract' : 'eoa';
47+
const address3rdPartyWidgets = useAddress3rdPartyWidgets(addressType, addressQuery.isPlaceholderData);
4748

4849
const error404Data = React.useMemo(() => ({
4950
hash: addressHash || '',
@@ -317,7 +318,7 @@ const AddressDetails = ({ addressQuery, countersQuery, isLoading }: Props) => {
317318
</DetailedInfo.ItemLabel>
318319
<DetailedInfo.ItemValue>
319320
<Address3rdPartyWidgets
320-
addressType={ data.is_contract ? 'contract' : 'eoa' }
321+
addressType={ addressType }
321322
isLoading={ addressQuery.isPlaceholderData }
322323
/>
323324
</DetailedInfo.ItemValue>
-1.22 KB
Loading
-1.1 KB
Loading
520 Bytes
Loading
413 Bytes
Loading
-857 Bytes
Loading

ui/address/address3rdPartyWidgets/Address3rdPartyWidgetCard.tsx

Lines changed: 46 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Flex, Text, chakra, Separator } from '@chakra-ui/react';
1+
import { Flex, Text, chakra, Separator, Box } from '@chakra-ui/react';
22
import { useCallback } from 'react';
33

44
import type { Address3rdPartyWidget } from 'types/views/address';
@@ -27,10 +27,8 @@ function formatUrl(tpl: string, ctx: Record<string, string>) {
2727
return tpl.replace(/\{\s*(\w+)\s*\}/g, (_, key) => ctx[key] ?? '');
2828
}
2929

30-
const Address3rdPartyWidgetCard = ({ name, config, address, ...props }: Props) => {
31-
const { data, isLoading: isDataLoading } = useWidgetData(name, config?.valuePath, address, props.isLoading);
32-
33-
const isLoading = props.isLoading || isDataLoading;
30+
const Address3rdPartyWidgetCard = ({ name, config, address, isLoading }: Props) => {
31+
const { data, isLoading: isDataLoading } = useWidgetData(name, config?.valuePath, address, isLoading);
3432

3533
const handleClick = useCallback(() => {
3634
mixpanel.logEvent(mixpanel.EventTypes.ADDRESS_WIDGET, { Name: name });
@@ -61,27 +59,29 @@ const Address3rdPartyWidgetCard = ({ name, config, address, ...props }: Props) =
6159
) : (
6260
<>
6361
<LinkOverlay href={ url } external onClick={ handleClick }/>
64-
{ data ? (
65-
<Text
66-
textStyle="heading.xl"
67-
color={ integer === '0' && !decimal ? 'text.secondary' : 'text.primary' }
68-
textOverflow="ellipsis"
69-
whiteSpace="nowrap"
70-
overflow="hidden"
71-
>
72-
{ integer }
73-
{ decimal && (
74-
<>
75-
.
76-
<chakra.span color="text.secondary">
77-
{ decimal }
78-
</chakra.span>
79-
</>
80-
) }
81-
</Text>
82-
) : (
83-
<Text textStyle="heading.xl" color="gray.500" opacity={ 0.2 }>{ ndash }</Text>
84-
) }
62+
<Skeleton loading={ isDataLoading } minW="88px" alignSelf="flex-start">
63+
{ data ? (
64+
<Text
65+
textStyle="heading.xl"
66+
color={ integer === '0' && !decimal ? 'text.secondary' : 'text.primary' }
67+
textOverflow="ellipsis"
68+
whiteSpace="nowrap"
69+
overflow="hidden"
70+
>
71+
{ integer }
72+
{ decimal && (
73+
<>
74+
.
75+
<chakra.span color="text.secondary">
76+
{ decimal }
77+
</chakra.span>
78+
</>
79+
) }
80+
</Text>
81+
) : (
82+
<Text textStyle="heading.xl" color="text.secondary" opacity={ 0.2 }>{ ndash }</Text>
83+
) }
84+
</Skeleton>
8585
<Flex alignItems="center" gap={ 1 } mt={ 1 }>
8686
<Text textStyle="sm">{ config.title }</Text>
8787
{ config.hint && (
@@ -119,24 +119,31 @@ const Address3rdPartyWidgetCard = ({ name, config, address, ...props }: Props) =
119119
);
120120

121121
return (
122-
<LinkBox className="group">
123-
<Flex
124-
flexDirection="column"
125-
p={ 3 }
126-
bgColor={ isLoading ? 'transparent' : { _light: 'blackAlpha.50', _dark: 'whiteAlpha.50' } }
122+
<LinkBox
123+
as={ Flex }
124+
className="group"
125+
flexDirection="column"
126+
p={ 3 }
127+
cursor={ isLoading ? 'default' : 'pointer' }
128+
position="relative"
129+
>
130+
<Box
131+
aria-hidden
132+
position="absolute"
133+
inset={ 0 }
127134
borderRadius="md"
128135
border="1px solid"
129136
borderColor={ isLoading ? { _light: 'blackAlpha.50', _dark: 'whiteAlpha.50' } : 'transparent' }
137+
bgColor={ isLoading ? 'transparent' : { _light: 'blackAlpha.50', _dark: 'whiteAlpha.50' } }
138+
transform="scale(1)"
139+
transition="transform 0.2s ease-in-out, border-color 0.2s ease-in-out"
140+
zIndex={ 0 }
130141
_groupHover={{
131-
borderColor: isLoading ? 'default' : { _light: 'blackAlpha.50', _dark: 'whiteAlpha.100' },
132-
scale: 1.02,
142+
transform: 'scale(1.02)',
143+
borderColor: { _light: 'blackAlpha.50', _dark: 'whiteAlpha.100' },
133144
}}
134-
transition="all 0.2s ease-in-out"
135-
scale={ 1 }
136-
cursor={ isLoading ? 'default' : 'pointer' }
137-
>
138-
{ content }
139-
</Flex>
145+
/>
146+
{ content }
140147
</LinkBox>
141148
);
142149
};

ui/pages/Address.tsx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,8 @@ const AddressPageContent = () => {
131131
addressEnsDomainsQuery.data?.items.find((domain) => domain.name === addressQuery.data?.ens_domain_name) :
132132
undefined;
133133

134-
const address3rdPartyWidgets = useAddress3rdPartyWidgets(
135-
addressQuery.data?.is_contract ? 'contract' : 'eoa',
136-
addressQuery.isPlaceholderData,
137-
areQueriesEnabled,
138-
);
134+
const addressType = addressQuery.data?.is_contract && addressQuery.data?.proxy_type !== 'eip7702' ? 'contract' : 'eoa';
135+
const address3rdPartyWidgets = useAddress3rdPartyWidgets(addressType, addressQuery.isPlaceholderData, areQueriesEnabled);
139136

140137
const isLoading = addressQuery.isPlaceholderData;
141138
const isTabsLoading =
@@ -288,7 +285,7 @@ const AddressPageContent = () => {
288285
count: address3rdPartyWidgets.items.length,
289286
component: (
290287
<Address3rdPartyWidgets
291-
addressType={ addressQuery.data?.is_contract ? 'contract' : 'eoa' }
288+
addressType={ addressType }
292289
isLoading={ addressQuery.isPlaceholderData }
293290
shouldRender={ !isTabsLoading }
294291
isQueryEnabled={ areQueriesEnabled }
@@ -306,6 +303,7 @@ const AddressPageContent = () => {
306303
areQueriesEnabled,
307304
mudTablesCountQuery.data,
308305
address3rdPartyWidgets,
306+
addressType,
309307
]);
310308

311309
const usernameApiTag = userPropfileApiQuery.data?.user_profile?.username;

0 commit comments

Comments
 (0)