blob: acfabe76bb5198792bc81ad5b034b38c433badab [file] [log] [blame]
Derick Montaguea2988f42020-01-17 13:46:30 -06001<template>
Yoshie Muranaka74f86872020-02-10 12:28:37 -08002 <div>
3 <div class="nav-container" :class="{ open: isNavigationOpen }">
Derick Montague68592032020-04-04 14:02:34 -05004 <nav ref="nav" :aria-label="$t('appNavigation.primaryNavigation')">
Yoshie Muranaka7d044352020-07-24 10:45:14 -07005 <b-nav vertical class="mb-4">
Yoshie Muranakad329ec82020-08-11 18:24:59 -07006 <template v-for="(navItem, index) in navigationItems">
7 <!-- Navigation items with no children -->
8 <b-nav-item
9 v-if="!navItem.children"
10 :key="index"
11 :to="navItem.route"
12 :data-test-id="`nav-item-${navItem.id}`"
Derick Montague2d589a72020-07-23 17:43:12 -050013 >
Yoshie Muranakad329ec82020-08-11 18:24:59 -070014 <component :is="navItem.icon" />
15 {{ navItem.label }}
16 </b-nav-item>
Derick Montague42c19892020-01-17 16:10:34 -060017
Yoshie Muranakad329ec82020-08-11 18:24:59 -070018 <!-- Navigation items with children -->
19 <li v-else :key="index" class="nav-item">
20 <b-button
21 v-b-toggle="`${navItem.id}`"
22 variant="link"
23 :data-test-id="`nav-button-${navItem.id}`"
Derick Montague2d589a72020-07-23 17:43:12 -050024 >
Yoshie Muranakad329ec82020-08-11 18:24:59 -070025 <component :is="navItem.icon" />
26 {{ navItem.label }}
27 <icon-expand class="icon-expand" />
28 </b-button>
29 <b-collapse :id="navItem.id" tag="ul" class="nav-item__nav">
Sukanya Pandeyfba4d622020-12-29 13:31:19 +053030 <li class="nav-item">
31 <router-link
32 v-for="(subNavItem, i) of navItem.children"
33 :key="i"
34 :to="subNavItem.route"
35 :data-test-id="`nav-item-${subNavItem.id}`"
36 class="nav-link"
37 >
38 {{ subNavItem.label }}
39 </router-link>
40 </li>
Yoshie Muranakad329ec82020-08-11 18:24:59 -070041 </b-collapse>
42 </li>
43 </template>
Yoshie Muranaka74f86872020-02-10 12:28:37 -080044 </b-nav>
45 </nav>
46 </div>
47 <transition name="fade">
48 <div
49 v-if="isNavigationOpen"
Derick Montaguead2ceb62020-04-24 18:11:04 -050050 id="nav-overlay"
Yoshie Muranaka74f86872020-02-10 12:28:37 -080051 class="nav-overlay"
52 @click="toggleIsOpen"
53 ></div>
54 </transition>
55 </div>
Derick Montaguea2988f42020-01-17 13:46:30 -060056</template>
57
58<script>
Yoshie Muranaka8263d852020-10-16 07:58:06 -070059//Do not change Mixin import.
60//Exact match alias set to support
61//dotenv customizations.
Yoshie Muranakad329ec82020-08-11 18:24:59 -070062import AppNavigationMixin from './AppNavigationMixin';
Derick Montaguea2988f42020-01-17 13:46:30 -060063
64export default {
Derick Montaguee2fd1562019-12-20 13:26:53 -060065 name: 'AppNavigation',
Yoshie Muranakad329ec82020-08-11 18:24:59 -070066 mixins: [AppNavigationMixin],
Yoshie Muranaka74f86872020-02-10 12:28:37 -080067 data() {
68 return {
Derick Montague602e98a2020-10-21 16:20:00 -050069 isNavigationOpen: false,
Yoshie Muranaka74f86872020-02-10 12:28:37 -080070 };
71 },
72 watch: {
Derick Montague602e98a2020-10-21 16:20:00 -050073 $route: function () {
Yoshie Muranaka74f86872020-02-10 12:28:37 -080074 this.isNavigationOpen = false;
75 },
Derick Montague602e98a2020-10-21 16:20:00 -050076 isNavigationOpen: function (isNavigationOpen) {
Sukanya Pandeyedb8a772020-10-29 11:33:42 +053077 this.$root.$emit('change-is-navigation-open', isNavigationOpen);
Derick Montague602e98a2020-10-21 16:20:00 -050078 },
Yoshie Muranaka74f86872020-02-10 12:28:37 -080079 },
80 mounted() {
Sukanya Pandeyedb8a772020-10-29 11:33:42 +053081 this.$root.$on('toggle-navigation', () => this.toggleIsOpen());
Yoshie Muranaka74f86872020-02-10 12:28:37 -080082 },
83 methods: {
84 toggleIsOpen() {
85 this.isNavigationOpen = !this.isNavigationOpen;
Derick Montague602e98a2020-10-21 16:20:00 -050086 },
87 },
Derick Montaguea2988f42020-01-17 13:46:30 -060088};
89</script>
Derick Montague42c19892020-01-17 16:10:34 -060090
Yoshie Muranaka71ac2302019-12-26 11:43:36 -080091<style scoped lang="scss">
92svg {
Derick Montague66f903f2020-02-28 11:22:31 -060093 fill: currentColor;
94 height: 1.2rem;
95 width: 1.2rem;
Yoshie Muranaka71ac2302019-12-26 11:43:36 -080096 margin-left: 0 !important; //!important overriding button specificity
97 vertical-align: text-bottom;
98 &:not(.icon-expand) {
99 margin-right: $spacer;
100 }
101}
102
103.nav {
SurenNeware057232b2020-06-08 20:53:26 +0530104 padding-top: $spacer / 4;
105 @include media-breakpoint-up($responsive-layout-bp) {
106 padding-top: $spacer;
107 }
Yoshie Muranaka71ac2302019-12-26 11:43:36 -0800108}
109
110.nav-item__nav {
Derick Montague42c19892020-01-17 16:10:34 -0600111 list-style: none;
112 padding-left: 0;
Yoshie Muranaka71ac2302019-12-26 11:43:36 -0800113 margin-left: 0;
114
Yoshie Muranaka85358ed2020-05-18 10:05:36 -0700115 .nav-item {
116 outline: none;
117 }
118
Yoshie Muranaka71ac2302019-12-26 11:43:36 -0800119 .nav-link {
120 padding-left: $spacer * 4;
Yoshie Muranaka85358ed2020-05-18 10:05:36 -0700121 outline: none;
Yoshie Muranaka71ac2302019-12-26 11:43:36 -0800122
123 &:not(.nav-link--current) {
124 font-weight: normal;
125 }
126 }
127}
128
129.btn-link {
Dixsie Wolmers30f11f82020-11-10 16:07:56 -0600130 display: inline-block;
Yoshie Muranaka71ac2302019-12-26 11:43:36 -0800131 width: 100%;
132 text-align: left;
133 text-decoration: none !important;
134 border-radius: 0;
135
136 &.collapsed {
137 .icon-expand {
138 transform: rotate(180deg);
139 }
140 }
Yoshie Muranaka71ac2302019-12-26 11:43:36 -0800141}
142
143.icon-expand {
144 float: right;
145 margin-top: $spacer / 4;
146}
147
148.btn-link,
149.nav-link {
150 position: relative;
151 font-weight: $headings-font-weight;
152 padding-left: $spacer; // defining consistent padding for links and buttons
153 padding-right: $spacer;
Yoshie Muranaka01da8182020-07-08 15:46:43 -0700154 color: theme-color('secondary');
Yoshie Muranaka71ac2302019-12-26 11:43:36 -0800155
156 &:hover {
SurenNeware1f8117f2020-09-22 19:28:56 +0530157 background-color: theme-color-level(dark, -10.5);
Yoshie Muranaka01da8182020-07-08 15:46:43 -0700158 color: theme-color('dark');
Yoshie Muranaka71ac2302019-12-26 11:43:36 -0800159 }
Yoshie Muranaka9f5cea82020-02-04 09:30:00 -0800160
161 &:focus {
SurenNeware1f8117f2020-09-22 19:28:56 +0530162 background-color: theme-color-level(light, 0);
163 box-shadow: inset 0 0 0 2px theme-color('primary');
Yoshie Muranaka01da8182020-07-08 15:46:43 -0700164 color: theme-color('dark');
Derick Montague59569d82020-10-26 15:17:31 -0500165 outline: 0;
Yoshie Muranaka9f5cea82020-02-04 09:30:00 -0800166 }
SurenNeware1f8117f2020-09-22 19:28:56 +0530167
168 &:active {
Derick Montague59569d82020-10-26 15:17:31 -0500169 background-color: theme-color('secondary');
SurenNeware1f8117f2020-09-22 19:28:56 +0530170 color: $white;
171 }
Yoshie Muranaka71ac2302019-12-26 11:43:36 -0800172}
173
SurenNeware1f8117f2020-09-22 19:28:56 +0530174.nav-link--current {
Yoshie Muranaka71ac2302019-12-26 11:43:36 -0800175 font-weight: $headings-font-weight;
Yoshie Muranaka01da8182020-07-08 15:46:43 -0700176 background-color: theme-color('secondary');
177 color: theme-color('light');
Derick Montague66f903f2020-02-28 11:22:31 -0600178 cursor: default;
SurenNeware1f8117f2020-09-22 19:28:56 +0530179 box-shadow: none;
Yoshie Muranaka71ac2302019-12-26 11:43:36 -0800180
181 &::before {
182 content: '';
183 position: absolute;
184 top: 0;
185 bottom: 0;
186 left: 0;
187 width: 4px;
Yoshie Muranaka01da8182020-07-08 15:46:43 -0700188 background-color: theme-color('primary');
Yoshie Muranaka71ac2302019-12-26 11:43:36 -0800189 }
Derick Montague59569d82020-10-26 15:17:31 -0500190
191 &:hover,
SurenNeware1f8117f2020-09-22 19:28:56 +0530192 &:focus {
Derick Montague59569d82020-10-26 15:17:31 -0500193 background-color: theme-color('secondary');
194 color: theme-color('light');
SurenNeware1f8117f2020-09-22 19:28:56 +0530195 }
196}
Yoshie Muranaka74f86872020-02-10 12:28:37 -0800197
198.nav-container {
199 position: fixed;
200 width: $navigation-width;
201 top: $header-height;
202 bottom: 0;
203 left: 0;
204 z-index: $zindex-fixed;
205 overflow-y: auto;
Derick Montague59569d82020-10-26 15:17:31 -0500206 background-color: theme-color('light');
Yoshie Muranaka74f86872020-02-10 12:28:37 -0800207 transform: translateX(-$navigation-width);
208 transition: transform $exit-easing--productive $duration--moderate-02;
Derick Montague59569d82020-10-26 15:17:31 -0500209 border-right: 1px solid theme-color-level('light', 2.85);
210
SurenNeware057232b2020-06-08 20:53:26 +0530211 @include media-breakpoint-down(md) {
212 z-index: $zindex-fixed + 2;
213 }
Yoshie Muranaka74f86872020-02-10 12:28:37 -0800214
Derick Montague74466b82020-06-28 10:17:32 -0500215 &.open,
216 &:focus-within {
Yoshie Muranaka74f86872020-02-10 12:28:37 -0800217 transform: translateX(0);
218 transition-timing-function: $entrance-easing--productive;
219 }
220
221 @include media-breakpoint-up($responsive-layout-bp) {
222 transition-duration: $duration--fast-01;
223 transform: translateX(0);
224 }
225}
226
227.nav-overlay {
228 position: fixed;
229 top: $header-height;
230 bottom: 0;
231 left: 0;
232 right: 0;
SurenNeware057232b2020-06-08 20:53:26 +0530233 z-index: $zindex-fixed + 1;
Yoshie Muranaka74f86872020-02-10 12:28:37 -0800234 background-color: $black;
235 opacity: 0.5;
236
237 &.fade-enter-active {
238 transition: opacity $duration--moderate-02 $entrance-easing--productive;
239 }
240
241 &.fade-leave-active {
242 transition: opacity $duration--fast-02 $exit-easing--productive;
243 }
244
SurenNeware151dd242020-11-10 20:15:05 +0530245 &.fade-enter, // Remove this vue2 based only class when switching to vue3
246 &.fade-enter-from, // This is vue3 based only class modified from 'fade-enter'
Yoshie Muranaka74f86872020-02-10 12:28:37 -0800247 &.fade-leave-to {
248 opacity: 0;
249 }
250
251 @include media-breakpoint-up($responsive-layout-bp) {
252 display: none;
253 }
254}
Derick Montague42c19892020-01-17 16:10:34 -0600255</style>