Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
frontend
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vicotor
frontend
Commits
8d03a98b
Commit
8d03a98b
authored
Dec 08, 2022
by
tom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix loader
parent
38cb449a
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
50 additions
and
42 deletions
+50
-42
TokenSelect.tsx
ui/address/tokenSelect/TokenSelect.tsx
+17
-23
TokenSelectButton.tsx
ui/address/tokenSelect/TokenSelectButton.tsx
+27
-15
TokenSelectDesktop.tsx
ui/address/tokenSelect/TokenSelectDesktop.tsx
+3
-2
TokenSelectMobile.tsx
ui/address/tokenSelect/TokenSelectMobile.tsx
+3
-2
No files found.
ui/address/tokenSelect/TokenSelect.tsx
View file @
8d03a98b
...
@@ -62,7 +62,20 @@ const TokenSelect = () => {
...
@@ -62,7 +62,20 @@ const TokenSelect = () => {
handler: handleTokenBalanceMessage,
handler: handleTokenBalanceMessage,
});
});
const button = (
if (isLoading) {
return <Skeleton h={ 8 } w="160px"/>;
}
if (isError || data.length === 0) {
return <Box py="6px">0</Box>;
}
return (
<>
{ isMobile ?
<TokenSelectMobile data={ data } isLoading={ balancesIsFetching === 1 }/> :
<TokenSelectDesktop data={ data } isLoading={ balancesIsFetching === 1 }/>
}
<Tooltip label="Show all tokens">
<Tooltip label="Show all tokens">
<IconButton
<IconButton
aria-label="Show all tokens"
aria-label="Show all tokens"
...
@@ -74,25 +87,6 @@ const TokenSelect = () => {
...
@@ -74,25 +87,6 @@ const TokenSelect = () => {
icon={ <Icon as={ walletIcon } boxSize={ 5 }/> }
icon={ <Icon as={ walletIcon } boxSize={ 5 }/> }
/>
/>
</Tooltip>
</Tooltip>
);
if (isLoading || balancesIsFetching === 1) {
return (
<>
<Skeleton h={ 8 } w="160px"/>
{ data && data.length > 0 && button }
</>
);
}
if (isError || data.length === 0) {
return <Box py="6px">0</Box>;
}
return (
<>
{ isMobile ? <TokenSelectMobile data={ data }/> : <TokenSelectDesktop data={ data }/> }
{ button }
</>
</>
);
);
};
};
...
...
ui/address/tokenSelect/TokenSelectButton.tsx
View file @
8d03a98b
import
{
B
utton
,
Icon
,
Text
}
from
'
@chakra-ui/react
'
;
import
{
B
ox
,
Button
,
Icon
,
Skeleton
,
Text
,
useColorModeValue
}
from
'
@chakra-ui/react
'
;
import
BigNumber
from
'
bignumber.js
'
;
import
BigNumber
from
'
bignumber.js
'
;
import
React
from
'
react
'
;
import
React
from
'
react
'
;
...
@@ -10,20 +10,30 @@ import type { EnhancedData } from './utils';
...
@@ -10,20 +10,30 @@ import type { EnhancedData } from './utils';
interface
Props
{
interface
Props
{
isOpen
:
boolean
;
isOpen
:
boolean
;
isLoading
:
boolean
;
onClick
:
()
=>
void
;
onClick
:
()
=>
void
;
data
:
Array
<
EnhancedData
>
;
data
:
Array
<
EnhancedData
>
;
}
}
const
TokenSelectButton
=
({
isOpen
,
onClick
,
data
}:
Props
,
ref
:
React
.
ForwardedRef
<
HTMLButtonElement
>
)
=>
{
const
TokenSelectButton
=
({
isOpen
,
isLoading
,
onClick
,
data
}:
Props
,
ref
:
React
.
ForwardedRef
<
HTMLButtonElement
>
)
=>
{
const
totalBn
=
data
.
reduce
((
result
,
item
)
=>
!
item
.
usd
?
result
:
result
.
plus
(
BigNumber
(
item
.
usd
)),
ZERO
);
const
totalBn
=
data
.
reduce
((
result
,
item
)
=>
!
item
.
usd
?
result
:
result
.
plus
(
BigNumber
(
item
.
usd
)),
ZERO
);
const
skeletonBgColor
=
useColorModeValue
(
'
white
'
,
'
black
'
);
const
handleClick
=
React
.
useCallback
(()
=>
{
if
(
isLoading
&&
!
isOpen
)
{
return
;
}
onClick
();
},
[
isLoading
,
isOpen
,
onClick
]);
return
(
return
(
<
Box
position=
"relative"
>
<
Button
<
Button
ref=
{
ref
}
ref=
{
ref
}
size=
"sm"
size=
"sm"
variant=
"outline"
variant=
"outline"
colorScheme=
"gray"
colorScheme=
"gray"
onClick=
{
on
Click
}
onClick=
{
handle
Click
}
aria
-
label=
"Token select"
aria
-
label=
"Token select"
>
>
<
Icon
as=
{
tokensIcon
}
boxSize=
{
4
}
mr=
{
2
}
/>
<
Icon
as=
{
tokensIcon
}
boxSize=
{
4
}
mr=
{
2
}
/>
...
@@ -31,6 +41,8 @@ const TokenSelectButton = ({ isOpen, onClick, data }: Props, ref: React.Forwarde
...
@@ -31,6 +41,8 @@ const TokenSelectButton = ({ isOpen, onClick, data }: Props, ref: React.Forwarde
<
Text
whiteSpace=
"pre"
variant=
"secondary"
fontWeight=
{
400
}
>
($
{
totalBn
.
toFormat
(
2
)
}
)
</
Text
>
<
Text
whiteSpace=
"pre"
variant=
"secondary"
fontWeight=
{
400
}
>
($
{
totalBn
.
toFormat
(
2
)
}
)
</
Text
>
<
Icon
as=
{
arrowIcon
}
transform=
{
isOpen
?
'
rotate(90deg)
'
:
'
rotate(-90deg)
'
}
transitionDuration=
"faster"
boxSize=
{
5
}
ml=
{
3
}
/>
<
Icon
as=
{
arrowIcon
}
transform=
{
isOpen
?
'
rotate(90deg)
'
:
'
rotate(-90deg)
'
}
transitionDuration=
"faster"
boxSize=
{
5
}
ml=
{
3
}
/>
</
Button
>
</
Button
>
{
isLoading
&&
!
isOpen
&&
<
Skeleton
h=
"100%"
w=
"100%"
position=
"absolute"
top=
{
0
}
left=
{
0
}
bgColor=
{
skeletonBgColor
}
/>
}
</
Box
>
);
);
};
};
...
...
ui/address/tokenSelect/TokenSelectDesktop.tsx
View file @
8d03a98b
...
@@ -9,9 +9,10 @@ import useTokenSelect from './useTokenSelect';
...
@@ -9,9 +9,10 @@ import useTokenSelect from './useTokenSelect';
interface
Props
{
interface
Props
{
data
:
Array
<
AddressTokenBalance
>
;
data
:
Array
<
AddressTokenBalance
>
;
isLoading
:
boolean
;
}
}
const
TokenSelectDesktop
=
({
data
}:
Props
)
=>
{
const
TokenSelectDesktop
=
({
data
,
isLoading
}:
Props
)
=>
{
const
{
isOpen
,
onToggle
,
onClose
}
=
useDisclosure
();
const
{
isOpen
,
onToggle
,
onClose
}
=
useDisclosure
();
const
bgColor
=
useColorModeValue
(
'
white
'
,
'
gray.900
'
);
const
bgColor
=
useColorModeValue
(
'
white
'
,
'
gray.900
'
);
...
@@ -21,7 +22,7 @@ const TokenSelectDesktop = ({ data }: Props) => {
...
@@ -21,7 +22,7 @@ const TokenSelectDesktop = ({ data }: Props) => {
return
(
return
(
<
Popover
isOpen=
{
isOpen
}
onClose=
{
onClose
}
placement=
"bottom-start"
isLazy
>
<
Popover
isOpen=
{
isOpen
}
onClose=
{
onClose
}
placement=
"bottom-start"
isLazy
>
<
PopoverTrigger
>
<
PopoverTrigger
>
<
TokenSelectButton
isOpen=
{
isOpen
}
onClick=
{
onToggle
}
data=
{
result
.
modifiedData
}
/>
<
TokenSelectButton
isOpen=
{
isOpen
}
onClick=
{
onToggle
}
data=
{
result
.
modifiedData
}
isLoading=
{
isLoading
}
/>
</
PopoverTrigger
>
</
PopoverTrigger
>
<
PopoverContent
w=
"355px"
maxH=
"450px"
overflowY=
"scroll"
>
<
PopoverContent
w=
"355px"
maxH=
"450px"
overflowY=
"scroll"
>
<
PopoverBody
px=
{
4
}
py=
{
6
}
bgColor=
{
bgColor
}
boxShadow=
"2xl"
>
<
PopoverBody
px=
{
4
}
py=
{
6
}
bgColor=
{
bgColor
}
boxShadow=
"2xl"
>
...
...
ui/address/tokenSelect/TokenSelectMobile.tsx
View file @
8d03a98b
...
@@ -9,15 +9,16 @@ import useTokenSelect from './useTokenSelect';
...
@@ -9,15 +9,16 @@ import useTokenSelect from './useTokenSelect';
interface
Props
{
interface
Props
{
data
:
Array
<
AddressTokenBalance
>
;
data
:
Array
<
AddressTokenBalance
>
;
isLoading
:
boolean
;
}
}
const
TokenSelectMobile
=
({
data
}:
Props
)
=>
{
const
TokenSelectMobile
=
({
data
,
isLoading
}:
Props
)
=>
{
const
{
isOpen
,
onToggle
,
onClose
}
=
useDisclosure
();
const
{
isOpen
,
onToggle
,
onClose
}
=
useDisclosure
();
const
result
=
useTokenSelect
(
data
);
const
result
=
useTokenSelect
(
data
);
return
(
return
(
<>
<>
<
TokenSelectButton
isOpen=
{
isOpen
}
onClick=
{
onToggle
}
data=
{
result
.
modifiedData
}
/>
<
TokenSelectButton
isOpen=
{
isOpen
}
onClick=
{
onToggle
}
data=
{
result
.
modifiedData
}
isLoading=
{
isLoading
}
/>
<
Modal
isOpen=
{
isOpen
}
onClose=
{
onClose
}
size=
"full"
>
<
Modal
isOpen=
{
isOpen
}
onClose=
{
onClose
}
size=
"full"
>
<
ModalContent
>
<
ModalContent
>
<
ModalCloseButton
/>
<
ModalCloseButton
/>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment