forked from cybrespace/pinafore
37 lines
701 B
HTML
37 lines
701 B
HTML
{{#await imagePromise}}
|
|
<svg>
|
|
<use xlink:href="#fa-user" />
|
|
</svg>
|
|
{{then src}}
|
|
<img alt="Profile picture for @{{account.acct}}" src="{{account.avatar}}" />
|
|
{{catch error}}
|
|
<svg>
|
|
<use xlink:href="#fa-user" />
|
|
</svg>
|
|
{{/await}}
|
|
|
|
<style>
|
|
img, svg {
|
|
width: 48px;
|
|
height: 48px;
|
|
margin: 0 auto;
|
|
border-radius: 4px;
|
|
}
|
|
|
|
svg {
|
|
fill: var(--deemphasized-text-color);
|
|
}
|
|
</style>
|
|
<script>
|
|
export default {
|
|
computed: {
|
|
imageSrc: (account) => account.avatar,
|
|
imagePromise: (imageSrc) => new Promise((resolve, reject) => {
|
|
let img = new Image()
|
|
img.onload = resolve
|
|
img.onerror = reject
|
|
img.src = imageSrc
|
|
})
|
|
}
|
|
}
|
|
</script> |