aboutsummaryrefslogtreecommitdiff
path: root/src/components/navigation/navigation_entry.vue
blob: ac4a0c4775b6708b3064066926f191d9a16881eb (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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
<template>
  <OptionalRouterLink
    v-slot="{ isActive, href, navigate } = {}"
    :to="routeTo"
  >
    <li
      class="NavigationEntry menu-item"
      :class="{ '-active': isActive }"
      v-bind="$attrs"
    >
      <component
        :is="routeTo ? 'a' : 'button'"
        class="main-link"
        :href="href"
        @click="navigate"
      >
        <span>
          <FAIcon
            v-if="item.icon"
            fixed-width
            class="fa-scale-110 menu-icon"
            :icon="item.icon"
          />
        </span>
        <span
          v-if="item.iconLetter"
          class="icon iconLetter fa-scale-110 menu-icon"
        >{{ item.iconLetter }}
        </span>
        <span class="label">
          {{ item.labelRaw || $t(item.label) }}
        </span>
      </component>
      <slot />
      <div
        v-if="item.badgeGetter && getters[item.badgeGetter]"
        class="badge -notification"
      >
        {{ getters[item.badgeGetter] }}
      </div>
      <button
        v-if="showPin && currentUser"
        type="button"
        class="button-unstyled extra-button"
        :title="$t(isPinned ? 'general.unpin' : 'general.pin' )"
        :aria-pressed="!!isPinned"
        @click.stop.prevent="togglePin(item.name)"
      >
        <FAIcon
          v-if="showPin && currentUser"
          fixed-width
          class="fa-scale-110"
          :class="{ 'veryfaint': !isPinned(item.name) }"
          :transform="!isPinned(item.name) ? 'rotate-45' : ''"
          icon="thumbtack"
        />
      </button>
    </li>
  </OptionalRouterLink>
</template>

<script src="./navigation_entry.js"></script>

<style lang="scss">
@import "../../variables";

.NavigationEntry {
  display: flex;
  box-sizing: border-box;
  align-items: baseline;
  height: 3.5em;
  line-height: 3.5em;
  padding: 0;
  width: 100%;
  color: $fallback--link;
  color: var(--link, $fallback--link);

  &[aria-expanded] {
    padding-right: 1em;
  }

  .timelines-chevron {
    margin-right: 0;
  }

  .main-link {
    background: none;
    border: none;
    outline: none;
    display: inline;
    text-align: initial;
    font-size: 100%;
    font-family: inherit;
    line-height: unset;
    cursor: pointer;
    box-sizing: content-box;
    color: var(--text);
    flex: 1;
    padding: 0 1em;
  }

  .menu-icon {
    color: var(--icon);
    margin-right: 0.8em;
  }

  .extra-button {
    width: 3em;
    text-align: center;

    &:last-child {
      margin-right: -0.8em;
    }
  }

  .badge {
     margin: 0 0.8em;
  }
}
</style>