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
cf0afa01
Unverified
Commit
cf0afa01
authored
Aug 16, 2022
by
Jordan Frankfurt
Committed by
GitHub
Aug 16, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(widget): light and dark themes (#4367)
feat(widget): light and dark themes:
parent
c5b67ac6
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
50 additions
and
11 deletions
+50
-11
index.tsx
src/pages/TokenDetails/index.tsx
+8
-11
token-details-widget-theme.ts
src/theme/token-details-widget-theme.ts
+34
-0
token-details-widget-config.ts
src/utils/token-details-widget-config.ts
+8
-0
No files found.
src/pages/TokenDetails/index.tsx
View file @
cf0afa01
...
@@ -14,7 +14,6 @@ import TokenDetail from 'components/Explore/TokenDetails/TokenDetail'
...
@@ -14,7 +14,6 @@ import TokenDetail from 'components/Explore/TokenDetails/TokenDetail'
import
TokenSafetyMessage
from
'
components/TokenSafety/TokenSafetyMessage
'
import
TokenSafetyMessage
from
'
components/TokenSafety/TokenSafetyMessage
'
import
{
getChainInfo
}
from
'
constants/chainInfo
'
import
{
getChainInfo
}
from
'
constants/chainInfo
'
import
{
L1_CHAIN_IDS
,
L2_CHAIN_IDS
,
SupportedChainId
,
TESTNET_CHAIN_IDS
}
from
'
constants/chains
'
import
{
L1_CHAIN_IDS
,
L2_CHAIN_IDS
,
SupportedChainId
,
TESTNET_CHAIN_IDS
}
from
'
constants/chains
'
import
{
RPC_URLS
}
from
'
constants/networks
'
import
{
checkWarning
}
from
'
constants/tokenSafety
'
import
{
checkWarning
}
from
'
constants/tokenSafety
'
import
{
useToken
}
from
'
hooks/Tokens
'
import
{
useToken
}
from
'
hooks/Tokens
'
import
{
useActiveLocale
}
from
'
hooks/useActiveLocale
'
import
{
useActiveLocale
}
from
'
hooks/useActiveLocale
'
...
@@ -22,7 +21,10 @@ import { useNetworkTokenBalances } from 'hooks/useNetworkTokenBalances'
...
@@ -22,7 +21,10 @@ import { useNetworkTokenBalances } from 'hooks/useNetworkTokenBalances'
import
useTokenDetailPageQuery
from
'
hooks/useTokenDetailPageQuery
'
import
useTokenDetailPageQuery
from
'
hooks/useTokenDetailPageQuery
'
import
{
useCallback
,
useMemo
}
from
'
react
'
import
{
useCallback
,
useMemo
}
from
'
react
'
import
{
useParams
}
from
'
react-router-dom
'
import
{
useParams
}
from
'
react-router-dom
'
import
{
useIsDarkMode
}
from
'
state/user/hooks
'
import
styled
from
'
styled-components/macro
'
import
styled
from
'
styled-components/macro
'
import
{
DARK_THEME
,
LIGHT_THEME
}
from
'
theme/token-details-widget-theme
'
import
{
ROUTER_URL
,
RPC_URL_MAP
}
from
'
utils/token-details-widget-config
'
const
Footer
=
styled
.
div
`
const
Footer
=
styled
.
div
`
display: none;
display: none;
...
@@ -61,19 +63,13 @@ function NetworkBalances(tokenAddress: string) {
...
@@ -61,19 +63,13 @@ function NetworkBalances(tokenAddress: string) {
return
useNetworkTokenBalances
({
address
:
tokenAddress
})
return
useNetworkTokenBalances
({
address
:
tokenAddress
})
}
}
// widget configuration
const
WIDGET_THEME
=
{}
const
ROUTER_URL
=
'
https://api.uniswap.org/v1/
'
const
WIDGET_URL_MAP
=
Object
.
keys
(
RPC_URLS
).
reduce
(
(
acc
,
cur
)
=>
({
...
acc
,
[
cur
]:
[
RPC_URLS
[
cur
as
unknown
as
SupportedChainId
]]
}),
{}
)
export
default
function
TokenDetails
()
{
export
default
function
TokenDetails
()
{
const
{
tokenAddress
}
=
useParams
<
{
tokenAddress
?:
string
}
>
()
const
{
tokenAddress
}
=
useParams
<
{
tokenAddress
?:
string
}
>
()
const
{
loading
}
=
useTokenDetailPageQuery
(
tokenAddress
)
const
{
loading
}
=
useTokenDetailPageQuery
(
tokenAddress
)
const
tokenSymbol
=
useToken
(
tokenAddress
)?.
symbol
const
tokenSymbol
=
useToken
(
tokenAddress
)?.
symbol
const
darkMode
=
useIsDarkMode
()
const
widgetTheme
=
useMemo
(()
=>
(
darkMode
?
DARK_THEME
:
LIGHT_THEME
),
[
darkMode
])
const
locale
=
useActiveLocale
()
const
locale
=
useActiveLocale
()
const
onTxSubmit
=
useCallback
(()
=>
{
const
onTxSubmit
=
useCallback
(()
=>
{
console
.
log
(
'
onTxSubmit
'
)
console
.
log
(
'
onTxSubmit
'
)
...
@@ -97,6 +93,7 @@ export default function TokenDetails() {
...
@@ -97,6 +93,7 @@ export default function TokenDetails() {
const
tokenWarning
=
tokenAddress
?
checkWarning
(
tokenAddress
)
:
null
const
tokenWarning
=
tokenAddress
?
checkWarning
(
tokenAddress
)
:
null
/* network balance handling */
/* network balance handling */
const
{
data
:
networkData
}
=
tokenAddress
?
NetworkBalances
(
tokenAddress
)
:
{
data
:
null
}
const
{
data
:
networkData
}
=
tokenAddress
?
NetworkBalances
(
tokenAddress
)
:
{
data
:
null
}
const
{
chainId
:
connectedChainId
,
provider
}
=
useWeb3React
()
const
{
chainId
:
connectedChainId
,
provider
}
=
useWeb3React
()
const
totalBalance
=
4.3
// dummy data
const
totalBalance
=
4.3
// dummy data
...
@@ -143,14 +140,14 @@ export default function TokenDetails() {
...
@@ -143,14 +140,14 @@ export default function TokenDetails() {
defaultInputTokenAddress=
{
'
NATIVE
'
}
defaultInputTokenAddress=
{
'
NATIVE
'
}
defaultOutputTokenAddress=
{
tokenAddress
}
defaultOutputTokenAddress=
{
tokenAddress
}
hideConnectionUI
hideConnectionUI
jsonRpcUrlMap=
{
WIDGET
_URL_MAP
}
jsonRpcUrlMap=
{
RPC
_URL_MAP
}
locale=
{
locale
}
locale=
{
locale
}
onTxSubmit=
{
onTxSubmit
}
onTxSubmit=
{
onTxSubmit
}
onTxSuccess=
{
onTxSuccess
}
onTxSuccess=
{
onTxSuccess
}
onTxFail=
{
onTxFail
}
onTxFail=
{
onTxFail
}
provider=
{
provider
}
provider=
{
provider
}
routerUrl=
{
ROUTER_URL
}
routerUrl=
{
ROUTER_URL
}
theme=
{
WIDGET_THEME
}
theme=
{
widgetTheme
}
// tokenList=
{[]}
// tokenList=
{[]}
width=
{
290
}
width=
{
290
}
/>
/>
...
...
src/theme/token-details-widget-theme.ts
0 → 100644
View file @
cf0afa01
import
{
colors
}
from
'
./colors
'
export
const
LIGHT_THEME
=
{
// surface
container
:
'
#EDEFF7
'
,
interactive
:
'
#EDEFF7
'
,
module
:
'
#E1E4EE
'
,
accent
:
colors
.
pink400
,
dialog
:
'
#E1E4EE
'
,
// text
primary
:
colors
.
gray900
,
secondary
:
colors
.
gray500
,
onInteractive
:
colors
.
gray900
,
// state
success
:
colors
.
green400
,
warning
:
colors
.
gold200
,
error
:
colors
.
red400
,
}
export
const
DARK_THEME
=
{
// surface
container
:
colors
.
gray900
,
interactive
:
'
rgba(153, 161, 189, 0.08)
'
,
module
:
'
#191D27
'
,
accent
:
colors
.
blue400
,
dialog
:
'
#191D27
'
,
// text
primary
:
colors
.
white
,
secondary
:
colors
.
gray300
,
onInteractive
:
colors
.
white
,
// state
success
:
colors
.
greenVibrant
,
warning
:
colors
.
gold200
,
error
:
colors
.
red400
,
}
src/utils/token-details-widget-config.ts
0 → 100644
View file @
cf0afa01
import
{
SupportedChainId
}
from
'
constants/chains
'
import
{
RPC_URLS
}
from
'
constants/networks
'
export
const
ROUTER_URL
=
'
https://api.uniswap.org/v1/
'
export
const
RPC_URL_MAP
=
Object
.
keys
(
RPC_URLS
).
reduce
(
(
acc
,
cur
)
=>
({
...
acc
,
[
cur
]:
[
RPC_URLS
[
cur
as
unknown
as
SupportedChainId
]]
}),
{}
)
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