Stackedit/src/components/UserImage.vue
2018-09-19 09:59:22 +01:00

37 lines
713 B
Vue

<template>
<div class="user-image" :style="{backgroundImage: url}">
</div>
</template>
<script>
import userSvc from '../services/userSvc';
import store from '../store';
export default {
props: ['userId'],
computed: {
url() {
const userInfo = store.state.userInfo.itemsById[this.userId];
return userInfo && userInfo.imageUrl && `url('${userInfo.imageUrl}')`;
},
},
watch: {
userId: {
handler: userId => userSvc.getInfo(userId),
immediate: true,
},
},
};
</script>
<style lang="scss">
.user-image {
width: 100%;
height: 100%;
background-color: #fff;
background-repeat: no-repeat;
background-position: center;
background-size: contain;
}
</style>