2017-09-10 17:25:29 +05:30
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
props: {
|
|
|
|
entityId: {
|
|
|
|
type: Number,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
entityName: {
|
|
|
|
type: String,
|
|
|
|
required: true,
|
|
|
|
},
|
2018-03-17 18:26:18 +05:30
|
|
|
sizeClass: {
|
|
|
|
type: String,
|
|
|
|
required: false,
|
|
|
|
default: 's40',
|
|
|
|
},
|
2017-09-10 17:25:29 +05:30
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
/**
|
2018-05-09 12:01:36 +05:30
|
|
|
* This method is based on app/helpers/avatars_helper.rb#project_identicon
|
2017-09-10 17:25:29 +05:30
|
|
|
*/
|
|
|
|
identiconStyles() {
|
|
|
|
const allowedColors = [
|
|
|
|
'#FFEBEE',
|
|
|
|
'#F3E5F5',
|
|
|
|
'#E8EAF6',
|
|
|
|
'#E3F2FD',
|
|
|
|
'#E0F2F1',
|
|
|
|
'#FBE9E7',
|
|
|
|
'#EEEEEE',
|
|
|
|
];
|
|
|
|
|
|
|
|
const backgroundColor = allowedColors[this.entityId % 7];
|
|
|
|
|
|
|
|
return `background-color: ${backgroundColor}; color: #555;`;
|
|
|
|
},
|
|
|
|
identiconTitle() {
|
|
|
|
return this.entityName.charAt(0).toUpperCase();
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<div
|
2018-03-17 18:26:18 +05:30
|
|
|
class="avatar identicon"
|
|
|
|
:class="sizeClass"
|
2017-09-10 17:25:29 +05:30
|
|
|
:style="identiconStyles">
|
2018-03-17 18:26:18 +05:30
|
|
|
{{ identiconTitle }}
|
2017-09-10 17:25:29 +05:30
|
|
|
</div>
|
|
|
|
</template>
|