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
29ae755f
Unverified
Commit
29ae755f
authored
Mar 04, 2022
by
Jordan Frankfurt
Committed by
GitHub
Mar 04, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add new token image to widget (#3433)
parent
27b831b3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
6 deletions
+15
-6
missing-token-image.png
src/lib/assets/missing-token-image.png
+0
-0
TokenImg.tsx
src/lib/components/TokenImg.tsx
+7
-6
index.tsx
src/lib/icons/index.tsx
+8
-0
No files found.
src/lib/assets/missing-token-image.png
0 → 100644
View file @
29ae755f
2.46 KB
src/lib/components/TokenImg.tsx
View file @
29ae755f
import
{
Currency
}
from
'
@uniswap/sdk-core
'
import
useCurrencyLogoURIs
from
'
lib/hooks/useCurrencyLogoURIs
'
import
{
Slash
}
from
'
lib/icons
'
import
{
MissingToken
}
from
'
lib/icons
'
import
styled
from
'
lib/theme
'
import
{
useCallback
,
useEffect
,
useState
}
from
'
react
'
const
badSrcs
=
new
Set
<
string
>
()
interface
TokenImgProps
{
className
?:
string
interface
BaseProps
{
token
:
Currency
}
function
TokenImg
({
className
,
token
}:
TokenImgProps
)
{
type
TokenImgProps
=
BaseProps
&
Omit
<
React
.
ImgHTMLAttributes
<
HTMLImageElement
>
,
keyof
BaseProps
>
function
TokenImg
({
token
,
...
rest
}:
TokenImgProps
)
{
const
srcs
=
useCurrencyLogoURIs
(
token
)
const
[
src
,
setSrc
]
=
useState
<
string
|
undefined
>
()
useEffect
(()
=>
{
...
...
@@ -23,9 +24,9 @@ function TokenImg({ className, token }: TokenImgProps) {
},
[
src
,
srcs
])
if
(
src
)
{
return
<
img
className=
{
className
}
src=
{
src
}
alt=
{
token
.
name
||
token
.
symbol
}
onError=
{
onError
}
/>
return
<
img
src=
{
src
}
alt=
{
token
.
name
||
token
.
symbol
}
onError=
{
onError
}
{
...
rest
}
/>
}
return
<
Slash
className=
{
className
}
color=
"secondary"
/>
return
<
MissingToken
color=
"secondary"
{
...
rest
}
/>
}
export
default
styled
(
TokenImg
)
<
{
size
?:
number
}
>
`
...
...
src/lib/icons/index.tsx
View file @
29ae755f
import
MissingTokenIcon
from
'
lib/assets/missing-token-image.png
'
import
{
ReactComponent
as
RouterIcon
}
from
'
lib/assets/svg/auto_router.svg
'
import
{
ReactComponent
as
CheckIcon
}
from
'
lib/assets/svg/check.svg
'
import
{
ReactComponent
as
ExpandoIcon
}
from
'
lib/assets/svg/expando.svg
'
...
...
@@ -31,6 +32,10 @@ import {
type
SVGIcon
=
FunctionComponent
<
SVGProps
<
SVGSVGElement
>>
const
StyledImage
=
styled
.
img
`
height: 1em;
width: 1em;
`
function
icon
(
Icon
:
FeatherIcon
|
SVGIcon
)
{
return
styled
(
Icon
)
<
{
color
?:
Color
}
>
`
clip-path: stroke-box;
...
...
@@ -91,6 +96,9 @@ export const Trash2 = icon(Trash2Icon)
export
const
Wallet
=
icon
(
WalletIcon
)
export
const
X
=
icon
(
XIcon
)
export
const
XOctagon
=
icon
(
XOctagonIcon
)
export
const
MissingToken
=
(
props
:
React
.
ImgHTMLAttributes
<
HTMLImageElement
>
)
=>
(
<
StyledImage
src=
{
MissingTokenIcon
}
alt=
"Missing token"
{
...
props
}
/>
)
export
const
Check
=
styled
(
icon
(
CheckIcon
))
`
circle {
...
...
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