Skip to content

Commit fb57823

Browse files
Add Asset-Icons to Asset-List Page
1 parent 047fe9d commit fb57823

File tree

7 files changed

+44
-3
lines changed

7 files changed

+44
-3
lines changed

client/.DS_Store

6 KB
Binary file not shown.

client/src/.DS_Store

6 KB
Binary file not shown.

client/src/app.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,10 @@ export default function main({ DOM, HTTP, route, storage, scanner: scan$, search
207207
// In elements, we block rendering until the assetMap is loaded. Otherwise, we can start immediately.
208208
, isReady$ = process.env.ASSET_MAP_URL ? assetMap$.mapTo(true).startWith(false) : O.of(true)
209209

210+
// Asset Icons Response
211+
, assetIcons$ = !process.env.ASSET_MAP_URL ? O.of({}) :
212+
reply('asset-icons')
213+
210214
// Currently visible view
211215
, view$ = O.merge(page$.mapTo(null)
212216
, goHome$.mapTo('recentBlocks')
@@ -241,7 +245,7 @@ export default function main({ DOM, HTTP, route, storage, scanner: scan$, search
241245
, mempool$, mempoolRecent$, feeEst$
242246
, tx$, txAnalysis$, openTx$
243247
, goAddr$, addr$, addrTxs$, addrQR$
244-
, assetMap$, goAsset$, asset$, assetTxs$
248+
, assetMap$, assetIcons$, goAsset$, asset$, assetTxs$
245249
, isReady$, loading$, page$, view$, title$, theme$
246250
})
247251

@@ -334,6 +338,11 @@ export default function main({ DOM, HTTP, route, storage, scanner: scan$, search
334338
? { category: 'asset-txs', method: 'GET', path: `/asset/${d.asset_id}/txs/chain/${last(d.last_txids)}` }
335339
: { category: 'asset-txs', method: 'GET', path: `/asset/${d.asset_id}/txs` }])
336340

341+
// Fetch Asset Icons
342+
, !process.env.ASSET_MAP_URL ? O.empty() : O.of(
343+
{ category: 'asset-icons', method: 'GET', path: `https://assets.blockstream.info/icons.json` })
344+
345+
337346
// fetch more txs for asset page
338347
, moreSTxs$.map(d => ({ category: 'asset-txs-more', method: 'GET', path: `/asset/${d.asset_id}/txs/chain/${d.last_txid}` }))
339348
).map(setBase)

client/src/views/asset-list.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import Snabbdom from 'snabbdom-pragma'
22

33
import layout from './layout'
44

5-
export default ({ assetMap, t, ...S }) => {
5+
export default ({ assetMap, assetIcons, t, ...S }) => {
66

77
const assets = Object.entries(assetMap)
88
.map(([ asset_id, [ domain, ticker, name ] ]) => ({ asset_id, domain, ticker, name }))
@@ -28,7 +28,15 @@ export default ({ assetMap, t, ...S }) => {
2828
{assets.map(asset =>
2929
<div className="assets-table-link-row">
3030
<a className="assets-table-row asset-data" href={`asset/${asset.asset_id}`}>
31-
<div className="assets-table-cell" data-label={t`Name`}>{asset.name}</div>
31+
<div className="assets-table-cell" data-label={t`Name`}>
32+
<div className="assets-table-name">
33+
{assetIcons === null ? "" :
34+
assetIcons[`${asset.asset_id}`] === undefined ?
35+
<div className="asset-icon-placeholder"></div> :
36+
<img src={`data:image/png;base64,${assetIcons[`${asset.asset_id}`]}`} className="asset-icon"/>}
37+
<span>{asset.name}</span>
38+
</div>
39+
</div>
3240
<div className="assets-table-cell ticker" data-label={t`Ticker`}>{asset.ticker || <em>None</em>}</div>
3341
<div className="assets-table-cell" data-label={t`Issuer domain`}>{asset.domain}</div>
3442
<div className="assets-table-cell asset-id highlighted-text" data-label={t`Asset ID`}>{asset.asset_id}</div>

flavors/liquid-mainnet/extras.css

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,28 @@
2121
background-image: linear-gradient(-90deg, rgba(13, 141, 119, 1) 0%, rgba(17, 103, 97, 1) 16%, rgba(25, 68, 74, 1) 35%, rgba(29, 42, 48, 1) 57%, rgba(14, 16, 17, 1) 100%);
2222
}
2323

24+
/* Asset List Icons*/
25+
26+
.assets-table-cell .asset-icon-placeholder{
27+
width: 25px;
28+
height: 25px;
29+
float: left;
30+
margin-right: 10px;
31+
background: url(img/icons/asset_unknown.png);
32+
background-size: cover;
33+
}
34+
35+
.assets-table-cell .asset-icon{
36+
width: 25px;
37+
height: 25px;
38+
float: left;
39+
margin-right: 10px;
40+
}
41+
42+
.assets-table-name span{
43+
word-break: break-all;
44+
}
45+
2446
.assets-table .assets-table-row {
2547
display: table;
2648
table-layout: fixed;
@@ -68,6 +90,7 @@
6890

6991
.assets-table .assets-table-row > div:nth-child(1) {
7092
padding-left: 12px;
93+
padding-right: 15px;
7194
}
7295

7396
.assets-table-row {
2.67 KB
Loading

www/assets.minimal.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)