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: {
|
|
|
|
/**
|
|
|
|
* This method is based on app/helpers/application_helper.rb#project_identicon
|
|
|
|
*/
|
|
|
|
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">
|
|
|
|
{{identiconTitle}}
|
|
|
|
</div>
|
|
|
|
</template>
|