|
1 | | -import { Flex, Text, chakra, Separator } from '@chakra-ui/react'; |
| 1 | +import { Flex, Text, chakra, Separator, Box } from '@chakra-ui/react'; |
2 | 2 | import { useCallback } from 'react'; |
3 | 3 |
|
4 | 4 | import type { Address3rdPartyWidget } from 'types/views/address'; |
@@ -27,10 +27,8 @@ function formatUrl(tpl: string, ctx: Record<string, string>) { |
27 | 27 | return tpl.replace(/\{\s*(\w+)\s*\}/g, (_, key) => ctx[key] ?? ''); |
28 | 28 | } |
29 | 29 |
|
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); |
34 | 32 |
|
35 | 33 | const handleClick = useCallback(() => { |
36 | 34 | mixpanel.logEvent(mixpanel.EventTypes.ADDRESS_WIDGET, { Name: name }); |
@@ -61,27 +59,29 @@ const Address3rdPartyWidgetCard = ({ name, config, address, ...props }: Props) = |
61 | 59 | ) : ( |
62 | 60 | <> |
63 | 61 | <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> |
85 | 85 | <Flex alignItems="center" gap={ 1 } mt={ 1 }> |
86 | 86 | <Text textStyle="sm">{ config.title }</Text> |
87 | 87 | { config.hint && ( |
@@ -119,24 +119,31 @@ const Address3rdPartyWidgetCard = ({ name, config, address, ...props }: Props) = |
119 | 119 | ); |
120 | 120 |
|
121 | 121 | 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 } |
127 | 134 | borderRadius="md" |
128 | 135 | border="1px solid" |
129 | 136 | 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 } |
130 | 141 | _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' }, |
133 | 144 | }} |
134 | | - transition="all 0.2s ease-in-out" |
135 | | - scale={ 1 } |
136 | | - cursor={ isLoading ? 'default' : 'pointer' } |
137 | | - > |
138 | | - { content } |
139 | | - </Flex> |
| 145 | + /> |
| 146 | + { content } |
140 | 147 | </LinkBox> |
141 | 148 | ); |
142 | 149 | }; |
|
0 commit comments