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
Hide 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,27 +62,8 @@ const TokenSelect = () => {
...
@@ -62,27 +62,8 @@ const TokenSelect = () => {
handler: handleTokenBalanceMessage,
handler: handleTokenBalanceMessage,
});
});
const button = (
if (isLoading) {
<Tooltip label="Show all tokens">
return <Skeleton h={ 8 } w="160px"/>;
<IconButton
aria-label="Show all tokens"
variant="outline"
size="sm"
pl="6px"
pr="6px"
ml={ 3 }
icon={ <Icon as={ walletIcon } boxSize={ 5 }/> }
/>
</Tooltip>
);
if (isLoading || balancesIsFetching === 1) {
return (
<>
<Skeleton h={ 8 } w="160px"/>
{ data && data.length > 0 && button }
</>
);
}
}
if (isError || data.length === 0) {
if (isError || data.length === 0) {
...
@@ -91,8 +72,21 @@ const TokenSelect = () => {
...
@@ -91,8 +72,21 @@ const TokenSelect = () => {
return (
return (
<>
<>
{ isMobile ? <TokenSelectMobile data={ data }/> : <TokenSelectDesktop data={ data }/> }
{ isMobile ?
{ button }
<TokenSelectMobile data={ data } isLoading={ balancesIsFetching === 1 }/> :
<TokenSelectDesktop data={ data } isLoading={ balancesIsFetching === 1 }/>
}
<Tooltip label="Show all tokens">
<IconButton
aria-label="Show all tokens"
variant="outline"
size="sm"
pl="6px"
pr="6px"
ml={ 3 }
icon={ <Icon as={ walletIcon } boxSize={ 5 }/> }
/>
</Tooltip>
</>
</>
);
);
};
};
...
...
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,27 +10,39 @@ import type { EnhancedData } from './utils';
...
@@ -10,27 +10,39 @@ 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
(
<
Button
<
Box
position=
"relative"
>
ref=
{
ref
}
<
Button
size=
"sm"
ref=
{
ref
}
variant=
"outline"
size=
"sm"
colorScheme=
"gray"
variant=
"outline"
onClick=
{
onClick
}
colorScheme=
"gray"
aria
-
label=
"Token select"
onClick=
{
handleClick
}
>
aria
-
label=
"Token select"
<
Icon
as=
{
tokensIcon
}
boxSize=
{
4
}
mr=
{
2
}
/>
>
<
Text
fontWeight=
{
600
}
>
{
data
.
length
}
</
Text
>
<
Icon
as=
{
tokensIcon
}
boxSize=
{
4
}
mr=
{
2
}
/>
<
Text
whiteSpace=
"pre"
variant=
"secondary"
fontWeight=
{
400
}
>
($
{
totalBn
.
toFormat
(
2
)
}
)
</
Text
>
<
Text
fontWeight=
{
600
}
>
{
data
.
length
}
</
Text
>
<
Icon
as=
{
arrowIcon
}
transform=
{
isOpen
?
'
rotate(90deg)
'
:
'
rotate(-90deg)
'
}
transitionDuration=
"faster"
boxSize=
{
5
}
ml=
{
3
}
/>
<
Text
whiteSpace=
"pre"
variant=
"secondary"
fontWeight=
{
400
}
>
($
{
totalBn
.
toFormat
(
2
)
}
)
</
Text
>
</
Button
>
<
Icon
as=
{
arrowIcon
}
transform=
{
isOpen
?
'
rotate(90deg)
'
:
'
rotate(-90deg)
'
}
transitionDuration=
"faster"
boxSize=
{
5
}
ml=
{
3
}
/>
</
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