Created
December 15, 2022 03:28
-
-
Save wolfadex/77a74a3e668329058037ba70580a0bf7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
customElements.define( | |
"custom-image", | |
class extends HTMLElement { | |
constructor() { | |
this.imgEl = document.createElement("img"); | |
this.appendChild(this.imgEl); | |
} | |
connectedCallback() { | |
this.render(); | |
} | |
attributeChangeCallback(name, newValue, oldValue) { | |
if (name === "uri" && newValue !== oldValue) { | |
this.render(); | |
} | |
} | |
set mint(val) { | |
this._mint = mint; | |
this.render(); | |
} | |
async render() { | |
const uri = this.getAttribute("uri"); | |
const metaData = await getMetaData(uri); | |
const imageData = await getLogo(this._mint, metaData); | |
this.imgEl.setAttribute("src", imageData); | |
} | |
}, | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment