File tree Expand file tree Collapse file tree 4 files changed +29
-4
lines changed Expand file tree Collapse file tree 4 files changed +29
-4
lines changed Original file line number Diff line number Diff line change @@ -54,7 +54,7 @@ An object that defines your app:
54
54
type AppMetadata = {
55
55
// app name
56
56
name: string
57
- // SVG icon string, with height or width (whichever is larger) set to 100%
57
+ // SVG icon string, with height or width (whichever is larger) set to 100% or a valid image URL
58
58
icon: string
59
59
// description of app
60
60
description? : string
Original file line number Diff line number Diff line change @@ -43,3 +43,16 @@ export function validEnsChain(chainId: ChainId): boolean {
43
43
return false
44
44
}
45
45
}
46
+
47
+ export function isUrl ( str : string ) : boolean {
48
+ let url
49
+
50
+ try {
51
+ url = new URL ( str )
52
+ } catch ( _ ) {
53
+ console . log ( false )
54
+ return false
55
+ }
56
+ console . log ( url . protocol === 'http:' || url . protocol === 'https:' )
57
+ return url . protocol === 'http:' || url . protocol === 'https:'
58
+ }
Original file line number Diff line number Diff line change 4
4
import { internalState$ } from ' ../../streams'
5
5
import en from ' ../../i18n/en.json'
6
6
import type { i18n } from ' ../../types'
7
+ import { isUrl } from ' ../../utils'
7
8
8
9
export let step: keyof i18n [' connect' ]
9
10
118
119
<div class =" inner-container" >
119
120
<div class =" icon-container" >
120
121
{#if icon }
121
- {@html icon }
122
+ {#if isUrl (icon )}
123
+ <img height ="100%" src ={icon } alt =" logo" />
124
+ {:else }
125
+ {@html icon }
126
+ {/if }
122
127
{:else }
123
128
{@html blocknative }
124
129
{/if }
Original file line number Diff line number Diff line change 1
1
<script lang =" ts" >
2
2
import { fade } from ' svelte/transition'
3
+ import { isUrl } from ' ../../utils'
3
4
import Spinner from ' ./Spinner.svelte'
4
5
export let size: number // px
5
- export let icon: Promise <string > | string // svg string
6
+ export let icon: Promise <string > | string // svg string or url string
6
7
export let loading = false
7
8
8
9
export let border:
148
149
<div class =" placeholder-icon" />
149
150
{:then iconLoaded }
150
151
<div in:fade class =" icon" >
151
- {@html iconLoaded }
152
+ {#if isUrl (iconLoaded )}
153
+ <!-- load img url -->
154
+ <img height ="100%" src ={iconLoaded } alt =" logo" />
155
+ {:else }
156
+ <!-- render svg string -->
157
+ {@html iconLoaded }
158
+ {/if }
152
159
</div >
153
160
{/await }
154
161
{/if }
You can’t perform that action at this time.
0 commit comments