summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/super_sidebar/components/context_switcher_toggle.vue
blob: cfb7e7732e97f37c5c3b542ce6bacacf55090fac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<script>
import { GlTruncate, GlAvatar, GlIcon } from '@gitlab/ui';

export default {
  components: {
    GlTruncate,
    GlAvatar,
    GlIcon,
  },
  props: {
    /*
     * Contains metadata about the current view, e.g. `id`, `title` and `avatar`
     */
    context: {
      type: Object,
      required: true,
    },
    expanded: {
      type: Boolean,
      required: true,
    },
  },
  computed: {
    collapseIcon() {
      return this.expanded ? 'chevron-up' : 'chevron-down';
    },
    avatarShape() {
      return this.context.avatar_shape || 'rect';
    },
  },
};
</script>

<template>
  <button
    type="button"
    class="context-switcher-toggle gl-p-0 gl-bg-transparent gl-hover-bg-t-gray-a-08 gl-focus-bg-t-gray-a-08 gl-border-0 border-top border-bottom gl-border-gray-a-08 gl-box-shadow-none gl-display-flex gl-align-items-center gl-font-weight-bold gl-w-full gl-h-8 gl-flex-shrink-0"
    data-qa-selector="context_switcher"
  >
    <span
      v-if="context.icon"
      class="gl-avatar avatar-container gl-bg-t-gray-a-08 icon-avatar rect-avatar s24 gl-mr-3 gl-ml-4"
    >
      <gl-icon class="gl-text-gray-700" :name="context.icon" :size="16" />
    </span>
    <gl-avatar
      v-else
      :size="24"
      :shape="avatarShape"
      :entity-name="context.title"
      :entity-id="context.id"
      :src="context.avatar"
      class="gl-mr-3 gl-ml-4"
    />
    <div class="gl-overflow-auto gl-text-gray-900">
      <gl-truncate :text="context.title" />
    </div>
    <span class="gl-flex-grow-1 gl-text-right gl-mr-4">
      <gl-icon class="gl-text-gray-400" :name="collapseIcon" />
    </span>
  </button>
</template>