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