diff options
Diffstat (limited to 'src/components/user_avatar')
| -rw-r--r-- | src/components/user_avatar/user_avatar.js | 28 | ||||
| -rw-r--r-- | src/components/user_avatar/user_avatar.vue | 5 |
2 files changed, 33 insertions, 0 deletions
diff --git a/src/components/user_avatar/user_avatar.js b/src/components/user_avatar/user_avatar.js new file mode 100644 index 00000000..bfa2c2b5 --- /dev/null +++ b/src/components/user_avatar/user_avatar.js @@ -0,0 +1,28 @@ +import StillImage from '../still-image/still-image.vue' +import nsfwImage from '../../assets/nsfw.png' + +const UserAvatar = { + props: [ + 'src' + ], + data () { + return { + showPlaceholder: false + } + }, + components: { + StillImage + }, + computed: { + imgSrc () { + return this.showPlaceholder ? nsfwImage : this.src + } + }, + methods: { + imageLoadError () { + this.showPlaceholder = true + } + } +} + +export default UserAvatar diff --git a/src/components/user_avatar/user_avatar.vue b/src/components/user_avatar/user_avatar.vue new file mode 100644 index 00000000..75a857ac --- /dev/null +++ b/src/components/user_avatar/user_avatar.vue @@ -0,0 +1,5 @@ +<template> + <StillImage class="avatar" :src="imgSrc" :imageLoadError="imageLoadError"/> +</template> + +<script src="./user_avatar.js"></script> |
