Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
interface
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
LuckySwap
interface
Commits
37a50372
Unverified
Commit
37a50372
authored
Apr 27, 2021
by
Moody Salem
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
improve responsiveness of header
parent
ab99cc61
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
5 additions
and
319 deletions
+5
-319
index_old.tsx
src/components/CurrencyInputPanel/index_old.tsx
+0
-312
index.tsx
src/components/Header/index.tsx
+1
-3
useWrapCallback.ts
src/hooks/useWrapCallback.ts
+3
-2
App.tsx
src/pages/App.tsx
+1
-1
index.tsx
src/pages/Swap/index.tsx
+0
-1
No files found.
src/components/CurrencyInputPanel/index_old.tsx
deleted
100644 → 0
View file @
ab99cc61
import
{
Pair
}
from
'
@uniswap/v2-sdk
'
import
{
Currency
}
from
'
@uniswap/sdk-core
'
import
React
,
{
useState
,
useCallback
}
from
'
react
'
import
styled
from
'
styled-components
'
import
{
darken
}
from
'
polished
'
import
{
useCurrencyBalance
}
from
'
../../state/wallet/hooks
'
import
CurrencySearchModal
from
'
../SearchModal/CurrencySearchModal
'
import
CurrencyLogo
from
'
../CurrencyLogo
'
import
DoubleCurrencyLogo
from
'
../DoubleLogo
'
import
{
RowBetween
,
RowFixed
}
from
'
../Row
'
import
{
TYPE
}
from
'
../../theme
'
import
{
Input
as
NumericalInput
}
from
'
../NumericalInput
'
import
{
ReactComponent
as
DropDown
}
from
'
../../assets/images/dropdown.svg
'
import
useUSDCPrice
from
'
../../hooks/useUSDCPrice
'
import
Logo
from
'
../Logo
'
import
{
useActiveWeb3React
}
from
'
../../hooks
'
import
{
useTranslation
}
from
'
react-i18next
'
import
useTheme
from
'
../../hooks/useTheme
'
import
{
Lock
}
from
'
react-feather
'
import
{
AutoColumn
}
from
'
components/Column
'
const
InputPanel
=
styled
.
div
<
{
hideInput
?:
boolean
}
>
`
${({
theme
})
=>
theme
.
flexColumnNoWrap
}
position: relative;
border-radius:
${({
hideInput
})
=>
(
hideInput
?
'
12px
'
:
'
20px
'
)}
;
background-color:
${({
theme
})
=>
theme
.
bg2
}
;
z-index: 1;
width:
${({
hideInput
})
=>
(
hideInput
?
'
100%
'
:
'
initial
'
)}
;
`
const
FixedContainer
=
styled
.
div
`
width: 100%;
height: 100%;
position: absolute;
border-radius: 20px;
background-color:
${({
theme
})
=>
theme
.
bg1
}
;
opacity: 0.95;
display: flex;
align-items: center;
justify-content: center;
z-index: 2;
`
const
Container
=
styled
.
div
<
{
hideInput
:
boolean
}
>
`
border-radius:
${({
hideInput
})
=>
(
hideInput
?
'
12px
'
:
'
20px
'
)}
;
border: 1px solid
${({
theme
})
=>
theme
.
bg2
}
;
background-color:
${({
theme
})
=>
theme
.
bg1
}
;
width:
${({
hideInput
})
=>
(
hideInput
?
'
100%
'
:
'
initial
'
)}
;
:focus,
:hover {
border: 1px solid
${({
theme
})
=>
theme
.
bg3
}
;
}
`
const
CurrencySelect
=
styled
.
button
<
{
selected
:
boolean
;
hideInput
?:
boolean
}
>
`
align-items: center;
font-size: 20px;
font-weight: 500;
background-color:
${({
selected
,
theme
})
=>
(
selected
?
theme
.
bg2
:
theme
.
primary1
)}
;
color:
${({
selected
,
theme
})
=>
(
selected
?
theme
.
text1
:
theme
.
white
)}
;
border-radius: 12px;
box-shadow:
${({
selected
})
=>
(
selected
?
'
none
'
:
'
0px 6px 10px rgba(0, 0, 0, 0.075)
'
)}
;
outline: none;
cursor: pointer;
user-select: none;
border: none;
height:
${({
hideInput
})
=>
(
hideInput
?
'
2.8rem
'
:
'
2.2rem
'
)}
;
width:
${({
hideInput
})
=>
(
hideInput
?
'
100%
'
:
'
initial
'
)}
;
:focus,
:hover {
background-color:
${({
selected
,
theme
})
=>
(
selected
?
theme
.
bg3
:
darken
(
0.05
,
theme
.
primary1
))}
;
}
`
const
InputRow
=
styled
.
div
<
{
selected
:
boolean
}
>
`
${({
theme
})
=>
theme
.
flexRowNoWrap
}
align-items: center;
padding:
${({
selected
})
=>
(
selected
?
'
0.75rem 0.5rem 0.75rem 1rem
'
:
'
0.75rem 0.75rem 0.75rem 1rem
'
)}
;
`
const
LabelRow
=
styled
.
div
`
${({
theme
})
=>
theme
.
flexRowNoWrap
}
align-items: center;
color:
${({
theme
})
=>
theme
.
text1
}
;
font-size: 0.75rem;
line-height: 1rem;
padding: 0rem 1rem 0.75rem 1rem;
span:hover {
cursor: pointer;
color:
${({
theme
})
=>
darken
(
0.2
,
theme
.
text2
)}
;
}
`
const
DollarRow
=
styled
(
LabelRow
)
`
/* margin-top: -8px; */
`
const
Aligner
=
styled
.
span
`
display: flex;
align-items: center;
justify-content: space-between;
`
const
StyledDropDown
=
styled
(
DropDown
)
<
{
selected
:
boolean
}
>
`
margin: 0 0.25rem 0 0.5rem;
height: 35%;
path {
stroke:
${({
selected
,
theme
})
=>
(
selected
?
theme
.
text1
:
theme
.
white
)}
;
stroke-width: 1.5px;
}
`
const
StyledTokenName
=
styled
.
span
<
{
active
?:
boolean
}
>
`
${({
active
})
=>
(
active
?
'
margin: 0 0.25rem 0 0.25rem;
'
:
'
margin: 0 0.25rem 0 0.25rem;
'
)}
font-size:
${({
active
})
=>
(
active
?
'
20px
'
:
'
16px
'
)}
;
`
const
StyledBalanceMax
=
styled
.
button
`
height: 28px;
background-color:
${({
theme
})
=>
theme
.
primary5
}
;
border: 1px solid
${({
theme
})
=>
theme
.
primary5
}
;
border-radius: 0.5rem;
font-size: 0.875rem;
font-weight: 500;
cursor: pointer;
margin-right: 0.5rem;
color:
${({
theme
})
=>
theme
.
primaryText1
}
;
:hover {
border: 1px solid
${({
theme
})
=>
theme
.
primary1
}
;
}
:focus {
border: 1px solid
${({
theme
})
=>
theme
.
primary1
}
;
outline: none;
}
${({
theme
})
=>
theme
.
mediaWidth
.
upToExtraSmall
`
margin-right: 0.5rem;
`
}
;
`
const
EmptyLogo
=
styled
.
div
<
{
size
:
string
}
>
`
width:
${({
size
})
=>
size
}
;
height:
${({
size
})
=>
size
}
;
border-radius:
${({
size
})
=>
size
}
;
box-shadow: 0px 6px 10px rgba(0, 0, 0, 0.075);
background:
${({
theme
})
=>
theme
.
bg3
}
;
`
interface
CurrencyInputPanelProps
{
value
:
string
onUserInput
:
(
value
:
string
)
=>
void
onMax
?:
()
=>
void
showMaxButton
:
boolean
label
?:
string
onCurrencySelect
?:
(
currency
:
Currency
)
=>
void
currency
?:
Currency
|
null
disableCurrencySelect
?:
boolean
hideBalance
?:
boolean
pair
?:
Pair
|
null
hideInput
?:
boolean
otherCurrency
?:
Currency
|
null
id
:
string
showCommonBases
?:
boolean
customBalanceText
?:
string
locked
?:
boolean
}
export
default
function
CurrencyInputPanel
({
value
,
onUserInput
,
onMax
,
showMaxButton
,
label
=
'
Input
'
,
onCurrencySelect
,
currency
,
otherCurrency
,
id
,
showCommonBases
,
customBalanceText
,
disableCurrencySelect
=
false
,
hideBalance
=
false
,
pair
=
null
,
// used for double token logo
hideInput
=
false
,
locked
=
false
,
...
rest
}:
CurrencyInputPanelProps
)
{
const
{
t
}
=
useTranslation
()
const
[
modalOpen
,
setModalOpen
]
=
useState
(
false
)
const
{
account
}
=
useActiveWeb3React
()
const
selectedCurrencyBalance
=
useCurrencyBalance
(
account
??
undefined
,
currency
??
undefined
)
const
theme
=
useTheme
()
const
handleDismissSearch
=
useCallback
(()
=>
{
setModalOpen
(
false
)
},
[
setModalOpen
])
return
(
<
InputPanel
id=
{
id
}
hideInput=
{
hideInput
}
{
...
rest
}
>
{
locked
&&
(
<
FixedContainer
>
<
AutoColumn
gap=
"sm"
justify=
"center"
>
<
Lock
/>
<
TYPE
.
label
fontSize=
"12px"
>
Single-asset deposit only, price out of range.
</
TYPE
.
label
>
</
AutoColumn
>
</
FixedContainer
>
)
}
<
Container
hideInput=
{
hideInput
}
>
{
!
hideInput
&&
(
<
LabelRow
style=
{
{
padding
:
'
1rem 1rem 0rem 1rem
'
}
}
>
<
RowBetween
>
<
TYPE
.
body
color=
{
theme
.
text3
}
fontWeight=
{
500
}
fontSize=
{
14
}
>
{
label
}
</
TYPE
.
body
>
{
account
&&
(
<
TYPE
.
body
onClick=
{
onMax
}
color=
{
theme
.
text3
}
fontWeight=
{
500
}
fontSize=
{
14
}
style=
{
{
display
:
'
inline
'
,
cursor
:
'
pointer
'
}
}
>
{
!
hideBalance
&&
!!
currency
&&
selectedCurrencyBalance
?
(
customBalanceText
??
'
Balance:
'
)
+
selectedCurrencyBalance
?.
toSignificant
(
4
)
:
'
'
}
</
TYPE
.
body
>
)
}
</
RowBetween
>
</
LabelRow
>
)
}
<
InputRow
style=
{
hideInput
?
{
padding
:
'
0
'
,
borderRadius
:
'
8px
'
}
:
{}
}
selected=
{
disableCurrencySelect
}
>
{
!
hideInput
&&
(
<>
{
pair
?
(
<
span
style=
{
{
marginRight
:
'
0.75rem
'
}
}
>
<
DoubleCurrencyLogo
currency0=
{
pair
.
token0
}
currency1=
{
pair
.
token1
}
size=
{
24
}
margin=
{
true
}
/>
</
span
>
)
:
currency
?
(
<
CurrencyLogo
style=
{
{
marginRight
:
'
0.75rem
'
}
}
currency=
{
currency
}
size=
{
'
24px
'
}
/>
)
:
(
<
EmptyLogo
style=
{
{
marginRight
:
'
0.75rem
'
}
}
size=
{
'
24px
'
}
/>
)
}
<
NumericalInput
className=
"token-amount-input"
value=
{
value
}
onUserInput=
{
(
val
)
=>
{
onUserInput
(
val
)
}
}
/>
{
account
&&
currency
&&
showMaxButton
&&
label
!==
'
To
'
&&
(
<
StyledBalanceMax
onClick=
{
onMax
}
>
MAX
</
StyledBalanceMax
>
)
}
</>
)
}
<
CurrencySelect
selected=
{
!!
currency
}
hideInput=
{
hideInput
}
className=
"open-currency-select-button"
onClick=
{
()
=>
{
if
(
!
disableCurrencySelect
)
{
setModalOpen
(
true
)
}
}
}
>
<
Aligner
>
<
RowFixed
>
{
pair
?
(
<
StyledTokenName
className=
"pair-name-container"
>
{
pair
?.
token0
.
symbol
}
:
{
pair
?.
token1
.
symbol
}
</
StyledTokenName
>
)
:
(
<
StyledTokenName
className=
"token-symbol-container"
active=
{
Boolean
(
currency
&&
currency
.
symbol
)
}
>
{
(
currency
&&
currency
.
symbol
&&
currency
.
symbol
.
length
>
20
?
currency
.
symbol
.
slice
(
0
,
4
)
+
'
...
'
+
currency
.
symbol
.
slice
(
currency
.
symbol
.
length
-
5
,
currency
.
symbol
.
length
)
:
currency
?.
symbol
)
||
t
(
'
selectToken
'
)
}
</
StyledTokenName
>
)
}
</
RowFixed
>
{
!
disableCurrencySelect
&&
<
StyledDropDown
selected=
{
!!
currency
}
/>
}
</
Aligner
>
</
CurrencySelect
>
</
InputRow
>
{
/* {!hideInput && (
<DollarRow>
<RowBetween>
<TYPE.body color={theme.text3} fontWeight={400} fontSize={14}>
{'~ $2000.224'}
</TYPE.body>
</RowBetween>
</DollarRow>
)} */
}
</
Container
>
{
!
disableCurrencySelect
&&
onCurrencySelect
&&
(
<
CurrencySearchModal
isOpen=
{
modalOpen
}
onDismiss=
{
handleDismissSearch
}
onCurrencySelect=
{
onCurrencySelect
}
selectedCurrency=
{
currency
}
otherSelectedCurrency=
{
otherCurrency
}
showCommonBases=
{
showCommonBases
}
/>
)
}
</
InputPanel
>
)
}
src/components/Header/index.tsx
View file @
37a50372
...
@@ -46,10 +46,8 @@ const HeaderFrame = styled.div`
...
@@ -46,10 +46,8 @@ const HeaderFrame = styled.div`
background-color:
${({
theme
})
=>
theme
.
bg0
}
;
background-color:
${({
theme
})
=>
theme
.
bg0
}
;
${({
theme
})
=>
theme
.
mediaWidth
.
upToMedium
`
${({
theme
})
=>
theme
.
mediaWidth
.
upToMedium
`
grid-template-columns: 1fr
;
display: flex
;
padding: 0 1rem;
padding: 0 1rem;
width: calc(100%);
position: relative;
`
}
;
`
}
;
${({
theme
})
=>
theme
.
mediaWidth
.
upToExtraSmall
`
${({
theme
})
=>
theme
.
mediaWidth
.
upToExtraSmall
`
...
...
src/hooks/useWrapCallback.ts
View file @
37a50372
...
@@ -34,6 +34,7 @@ export default function useWrapCallback(
...
@@ -34,6 +34,7 @@ export default function useWrapCallback(
return
useMemo
(()
=>
{
return
useMemo
(()
=>
{
if
(
!
wethContract
||
!
chainId
||
!
inputCurrency
||
!
outputCurrency
)
return
NOT_APPLICABLE
if
(
!
wethContract
||
!
chainId
||
!
inputCurrency
||
!
outputCurrency
)
return
NOT_APPLICABLE
const
hasInputAmount
=
Boolean
(
inputAmount
?.
greaterThan
(
'
0
'
))
const
sufficientBalance
=
inputAmount
&&
balance
&&
!
balance
.
lessThan
(
inputAmount
)
const
sufficientBalance
=
inputAmount
&&
balance
&&
!
balance
.
lessThan
(
inputAmount
)
if
(
inputCurrency
===
ETHER
&&
currencyEquals
(
WETH9
[
chainId
],
outputCurrency
))
{
if
(
inputCurrency
===
ETHER
&&
currencyEquals
(
WETH9
[
chainId
],
outputCurrency
))
{
...
@@ -50,7 +51,7 @@ export default function useWrapCallback(
...
@@ -50,7 +51,7 @@ export default function useWrapCallback(
}
}
}
}
:
undefined
,
:
undefined
,
inputError
:
sufficientBalance
?
undefined
:
'
Insufficient ETH balance
'
,
inputError
:
sufficientBalance
?
undefined
:
hasInputAmount
?
'
Insufficient ETH balance
'
:
'
Enter ETH amount
'
,
}
}
}
else
if
(
currencyEquals
(
WETH9
[
chainId
],
inputCurrency
)
&&
outputCurrency
===
ETHER
)
{
}
else
if
(
currencyEquals
(
WETH9
[
chainId
],
inputCurrency
)
&&
outputCurrency
===
ETHER
)
{
return
{
return
{
...
@@ -66,7 +67,7 @@ export default function useWrapCallback(
...
@@ -66,7 +67,7 @@ export default function useWrapCallback(
}
}
}
}
:
undefined
,
:
undefined
,
inputError
:
sufficientBalance
?
undefined
:
'
Insufficient WETH balance
'
,
inputError
:
sufficientBalance
?
undefined
:
hasInputAmount
?
'
Insufficient WETH balance
'
:
'
Enter WETH amount
'
,
}
}
}
else
{
}
else
{
return
NOT_APPLICABLE
return
NOT_APPLICABLE
...
...
src/pages/App.tsx
View file @
37a50372
...
@@ -50,7 +50,7 @@ const BodyWrapper = styled.div`
...
@@ -50,7 +50,7 @@ const BodyWrapper = styled.div`
${({
theme
})
=>
theme
.
mediaWidth
.
upToSmall
`
${({
theme
})
=>
theme
.
mediaWidth
.
upToSmall
`
padding: 16px;
padding: 16px;
padding-top:
2
rem;
padding-top:
6
rem;
`
}
;
`
}
;
`
`
...
...
src/pages/Swap/index.tsx
View file @
37a50372
...
@@ -94,7 +94,6 @@ export default function Swap({ history }: RouteComponentProps) {
...
@@ -94,7 +94,6 @@ export default function Swap({ history }: RouteComponentProps) {
parsedAmount
,
parsedAmount
,
currencies
,
currencies
,
inputError
:
swapInputError
,
inputError
:
swapInputError
,
// v3Trade,
}
=
useDerivedSwapInfo
()
}
=
useDerivedSwapInfo
()
const
{
wrapType
,
execute
:
onWrap
,
inputError
:
wrapInputError
}
=
useWrapCallback
(
const
{
wrapType
,
execute
:
onWrap
,
inputError
:
wrapInputError
}
=
useWrapCallback
(
...
...
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