diff --git a/example/browser.js b/example/browser.js index 1f0a334..f986d29 100644 --- a/example/browser.js +++ b/example/browser.js @@ -64,10 +64,12 @@ function fadeImg() { this.style.opacity = '1'; } -function setImage(ens, avatarUri = notFoundImage, warn = false) { +function setImage(ens, avatarUri = notFoundImage, warn = false, headerUri) { const elem = document.getElementById('queryImage'); + const headerContainer = document.getElementById('headerContainer'); elem.setAttribute('src', avatarUri); elem.setAttribute('alt', ens); + headerContainer.style.backgroundImage = headerUri ? `url("${headerUri}")` : 'none'; const warnText = document.getElementById('warnText'); if (warn) { if (warnText) return; @@ -112,7 +114,9 @@ document.getElementById('queryInput').addEventListener('change', event => { .getMetadata(ens) .then(metadata => { const avatar = avtUtils.getImageURI({ metadata }); - setImage(ens, avatar); + avt.getHeader(ens).then(header => { + setImage(ens, avatar, false, header); + }); elem.style.filter = 'none'; }) .catch(error => { diff --git a/example/node.js b/example/node.js index b3c98d8..e43067f 100644 --- a/example/node.js +++ b/example/node.js @@ -15,7 +15,10 @@ const IPFS = 'https://cf-ipfs.com'; const provider = new StaticJsonRpcProvider( `https://mainnet.infura.io/v3/${process.env.INFURA_KEY}` ); -const avt = new AvatarResolver(provider, { ipfs: IPFS, apiKey: { opensea: process.env.OPENSEA_KEY }}); +const avt = new AvatarResolver(provider, { + ipfs: IPFS, + apiKey: { opensea: process.env.OPENSEA_KEY }, +}); avt .getMetadata(ensName) .then(metadata => { @@ -30,6 +33,13 @@ avt }, jsdomWindow: jsdom, }); - console.log(avatar); + console.log('avatar: ', avatar); + }) + .catch(console.log); + +avt + .getHeader(ensName) + .then(header => { + console.log('header: ', header); }) .catch(console.log); diff --git a/index.html b/index.html index 4efa5be..828e45d 100644 --- a/index.html +++ b/index.html @@ -9,20 +9,28 @@