update user and room icons
parent
d192046f85
commit
6e18eab9f8
@ -1,46 +1,50 @@
|
||||
<template>
|
||||
<img v-if="mxcURL" :src="thumbnailUrl()" class="userThumbnail" />
|
||||
<div v-else class="userThumbnail">
|
||||
{{username?username.substr(0,2):userId.substr(1,2)}}
|
||||
</div>
|
||||
<img v-if="mxcURL" :src="thumbnailUrl()" class="image"/>
|
||||
<Identicon v-else :value="fallback" :theme="'jdenticon'" :size="this.getFontSize()*this.size" class="identicon"/>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import parseMXC from '@modular-matrix/parse-mxc';
|
||||
import {matrix} from "@/main";
|
||||
import Identicon from '@vue-polkadot/vue-identicon';
|
||||
|
||||
export default {
|
||||
name: "userThumbnail.vue",
|
||||
components: {
|
||||
Identicon
|
||||
},
|
||||
props: {
|
||||
mxcURL: String,
|
||||
username: String,
|
||||
userId: String,
|
||||
width: String,
|
||||
height: String,
|
||||
resizeMethod: String,
|
||||
homeserver: String
|
||||
fallback: String,
|
||||
homeserver: String,
|
||||
size: Number
|
||||
},
|
||||
methods: {
|
||||
thumbnailUrl(){
|
||||
let mxc = parseMXC.parse(this.mxcURL);
|
||||
return `${this.homeserver||matrix.baseUrl}/_matrix/media/v1/thumbnail/${mxc.homeserver}/${mxc.id}?width=${this.width}&height=${this.height}&method=${this.resizeMethod}`;
|
||||
return `${this.homeserver||matrix.baseUrl}/_matrix/media/v1/thumbnail/${
|
||||
mxc.homeserver}/${mxc.id}?width=${this.imageSize}&height=${this.imageSize}&method=${this.resizeMethod}`;
|
||||
},
|
||||
getFontSize(){
|
||||
return window.getComputedStyle(document.body,null).fontSize.split("px", 1)||16;
|
||||
}
|
||||
},
|
||||
data(){
|
||||
return {
|
||||
resizeMethod: 'scale',
|
||||
imageSize: 128
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
<style scoped lang="scss">
|
||||
.userThumbnail{
|
||||
background-color: #42a7b9;
|
||||
width: 3rem;
|
||||
height: 3rem;
|
||||
border-radius: 1.5rem;
|
||||
}
|
||||
img.userThumbnail{
|
||||
background-color: unset;
|
||||
.image{
|
||||
border-radius: 10rem;
|
||||
background-color: unset;
|
||||
}
|
||||
}
|
||||
</style>
|
Loading…
Reference in New Issue