2017-07-31 06:33:39 -04:00
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
props: {
|
2017-08-01 05:08:54 -04:00
|
|
|
entityId: {
|
|
|
|
type: Number,
|
2017-07-31 06:33:39 -04:00
|
|
|
required: true,
|
|
|
|
},
|
2017-08-01 05:08:54 -04:00
|
|
|
entityName: {
|
2017-07-31 06:33:39 -04:00
|
|
|
type: String,
|
|
|
|
required: true,
|
|
|
|
},
|
2017-09-04 11:42:27 -04:00
|
|
|
sizeClass: {
|
|
|
|
type: String,
|
|
|
|
required: false,
|
|
|
|
default: 's40',
|
|
|
|
},
|
2017-07-31 06:33:39 -04:00
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
/**
|
2018-04-25 11:32:47 -04:00
|
|
|
* This method is based on app/helpers/avatars_helper.rb#project_identicon
|
2017-07-31 06:33:39 -04:00
|
|
|
*/
|
|
|
|
identiconStyles() {
|
|
|
|
const allowedColors = [
|
|
|
|
'#FFEBEE',
|
|
|
|
'#F3E5F5',
|
|
|
|
'#E8EAF6',
|
|
|
|
'#E3F2FD',
|
|
|
|
'#E0F2F1',
|
|
|
|
'#FBE9E7',
|
|
|
|
'#EEEEEE',
|
|
|
|
];
|
|
|
|
|
2017-08-01 05:08:54 -04:00
|
|
|
const backgroundColor = allowedColors[this.entityId % 7];
|
2017-07-31 06:33:39 -04:00
|
|
|
|
|
|
|
return `background-color: ${backgroundColor}; color: #555;`;
|
|
|
|
},
|
|
|
|
identiconTitle() {
|
2017-08-01 05:08:54 -04:00
|
|
|
return this.entityName.charAt(0).toUpperCase();
|
|
|
|
},
|
|
|
|
},
|
2017-07-31 06:33:39 -04:00
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<div
|
2017-09-04 11:42:27 -04:00
|
|
|
class="avatar identicon"
|
|
|
|
:class="sizeClass"
|
2017-07-31 06:33:39 -04:00
|
|
|
:style="identiconStyles">
|
2018-01-04 19:18:35 -05:00
|
|
|
{{ identiconTitle }}
|
2017-07-31 06:33:39 -04:00
|
|
|
</div>
|
|
|
|
</template>
|