summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/vue_shared/components/identicon.vue
diff options
context:
space:
mode:
authorkushalpandya <kushal@gitlab.com>2017-08-30 11:21:43 +0530
committerkushalpandya <kushal@gitlab.com>2017-08-30 11:21:43 +0530
commitee0fae8eaf81b267f487abd4bd9c6dc8b704449f (patch)
tree4261624187377a8914fe3f2e754fc20e320e7dba /app/assets/javascripts/vue_shared/components/identicon.vue
parent499b640679c0dca5b5d93da945da0ca26db8e58e (diff)
downloadgitlab-ce-ee0fae8eaf81b267f487abd4bd9c6dc8b704449f.tar.gz
Renamed to `identicon` and make shared component
Diffstat (limited to 'app/assets/javascripts/vue_shared/components/identicon.vue')
-rw-r--r--app/assets/javascripts/vue_shared/components/identicon.vue45
1 files changed, 45 insertions, 0 deletions
diff --git a/app/assets/javascripts/vue_shared/components/identicon.vue b/app/assets/javascripts/vue_shared/components/identicon.vue
new file mode 100644
index 00000000000..0edd820743f
--- /dev/null
+++ b/app/assets/javascripts/vue_shared/components/identicon.vue
@@ -0,0 +1,45 @@
+<script>
+export default {
+ props: {
+ entityId: {
+ type: Number,
+ required: true,
+ },
+ entityName: {
+ type: String,
+ required: true,
+ },
+ },
+ computed: {
+ /**
+ * This method is based on app/helpers/application_helper.rb#project_identicon
+ */
+ 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
+ class="avatar s40 identicon"
+ :style="identiconStyles">
+ {{identiconTitle}}
+ </div>
+</template>