Derick Montague | a2988f4 | 2020-01-17 13:46:30 -0600 | [diff] [blame] | 1 | <template> |
Yoshie Muranaka | 74f8687 | 2020-02-10 12:28:37 -0800 | [diff] [blame] | 2 | <div> |
| 3 | <div class="nav-container" :class="{ open: isNavigationOpen }"> |
Derick Montague | 6859203 | 2020-04-04 14:02:34 -0500 | [diff] [blame] | 4 | <nav ref="nav" :aria-label="$t('appNavigation.primaryNavigation')"> |
Yoshie Muranaka | 7d04435 | 2020-07-24 10:45:14 -0700 | [diff] [blame] | 5 | <b-nav vertical class="mb-4"> |
Ed Tanous | 9c72979 | 2024-03-23 14:56:34 -0700 | [diff] [blame] | 6 | <template v-for="navItem in navigationItems"> |
Yoshie Muranaka | d329ec8 | 2020-08-11 18:24:59 -0700 | [diff] [blame] | 7 | <!-- Navigation items with no children --> |
| 8 | <b-nav-item |
| 9 | v-if="!navItem.children" |
Ed Tanous | 9c72979 | 2024-03-23 14:56:34 -0700 | [diff] [blame] | 10 | :key="navItem.index" |
Yoshie Muranaka | d329ec8 | 2020-08-11 18:24:59 -0700 | [diff] [blame] | 11 | :to="navItem.route" |
| 12 | :data-test-id="`nav-item-${navItem.id}`" |
Derick Montague | 2d589a7 | 2020-07-23 17:43:12 -0500 | [diff] [blame] | 13 | > |
Yoshie Muranaka | d329ec8 | 2020-08-11 18:24:59 -0700 | [diff] [blame] | 14 | <component :is="navItem.icon" /> |
| 15 | {{ navItem.label }} |
| 16 | </b-nav-item> |
Derick Montague | 42c1989 | 2020-01-17 16:10:34 -0600 | [diff] [blame] | 17 | |
Yoshie Muranaka | d329ec8 | 2020-08-11 18:24:59 -0700 | [diff] [blame] | 18 | <!-- Navigation items with children --> |
Ed Tanous | 9c72979 | 2024-03-23 14:56:34 -0700 | [diff] [blame] | 19 | <li v-else :key="navItem.index" class="nav-item"> |
Yoshie Muranaka | d329ec8 | 2020-08-11 18:24:59 -0700 | [diff] [blame] | 20 | <b-button |
| 21 | v-b-toggle="`${navItem.id}`" |
| 22 | variant="link" |
| 23 | :data-test-id="`nav-button-${navItem.id}`" |
Derick Montague | 2d589a7 | 2020-07-23 17:43:12 -0500 | [diff] [blame] | 24 | > |
Yoshie Muranaka | d329ec8 | 2020-08-11 18:24:59 -0700 | [diff] [blame] | 25 | <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 Pandey | fba4d62 | 2020-12-29 13:31:19 +0530 | [diff] [blame] | 30 | <li class="nav-item"> |
| 31 | <router-link |
Damian Celico | aeb1981 | 2022-11-24 02:00:53 +0100 | [diff] [blame] | 32 | v-for="(subNavItem, i) of filteredNavItem(navItem.children)" |
Sukanya Pandey | fba4d62 | 2020-12-29 13:31:19 +0530 | [diff] [blame] | 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 Muranaka | d329ec8 | 2020-08-11 18:24:59 -0700 | [diff] [blame] | 41 | </b-collapse> |
| 42 | </li> |
| 43 | </template> |
Yoshie Muranaka | 74f8687 | 2020-02-10 12:28:37 -0800 | [diff] [blame] | 44 | </b-nav> |
| 45 | </nav> |
| 46 | </div> |
| 47 | <transition name="fade"> |
| 48 | <div |
| 49 | v-if="isNavigationOpen" |
Derick Montague | ad2ceb6 | 2020-04-24 18:11:04 -0500 | [diff] [blame] | 50 | id="nav-overlay" |
Yoshie Muranaka | 74f8687 | 2020-02-10 12:28:37 -0800 | [diff] [blame] | 51 | class="nav-overlay" |
| 52 | @click="toggleIsOpen" |
| 53 | ></div> |
| 54 | </transition> |
| 55 | </div> |
Derick Montague | a2988f4 | 2020-01-17 13:46:30 -0600 | [diff] [blame] | 56 | </template> |
| 57 | |
| 58 | <script> |
Yoshie Muranaka | 8263d85 | 2020-10-16 07:58:06 -0700 | [diff] [blame] | 59 | //Do not change Mixin import. |
| 60 | //Exact match alias set to support |
| 61 | //dotenv customizations. |
Yoshie Muranaka | d329ec8 | 2020-08-11 18:24:59 -0700 | [diff] [blame] | 62 | import AppNavigationMixin from './AppNavigationMixin'; |
Ed Tanous | dbd37e0 | 2024-03-23 14:56:34 -0700 | [diff] [blame] | 63 | import { useI18n } from 'vue-i18n'; |
Derick Montague | a2988f4 | 2020-01-17 13:46:30 -0600 | [diff] [blame] | 64 | |
| 65 | export default { |
Derick Montague | e2fd156 | 2019-12-20 13:26:53 -0600 | [diff] [blame] | 66 | name: 'AppNavigation', |
Yoshie Muranaka | d329ec8 | 2020-08-11 18:24:59 -0700 | [diff] [blame] | 67 | mixins: [AppNavigationMixin], |
Yoshie Muranaka | 74f8687 | 2020-02-10 12:28:37 -0800 | [diff] [blame] | 68 | data() { |
| 69 | return { |
Ed Tanous | dbd37e0 | 2024-03-23 14:56:34 -0700 | [diff] [blame] | 70 | $t: useI18n().t, |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 71 | isNavigationOpen: false, |
Damian Celico | aeb1981 | 2022-11-24 02:00:53 +0100 | [diff] [blame] | 72 | currentUserRole: null, |
Yoshie Muranaka | 74f8687 | 2020-02-10 12:28:37 -0800 | [diff] [blame] | 73 | }; |
| 74 | }, |
| 75 | watch: { |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 76 | $route: function () { |
Yoshie Muranaka | 74f8687 | 2020-02-10 12:28:37 -0800 | [diff] [blame] | 77 | this.isNavigationOpen = false; |
| 78 | }, |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 79 | isNavigationOpen: function (isNavigationOpen) { |
Sukanya Pandey | edb8a77 | 2020-10-29 11:33:42 +0530 | [diff] [blame] | 80 | this.$root.$emit('change-is-navigation-open', isNavigationOpen); |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 81 | }, |
Yoshie Muranaka | 74f8687 | 2020-02-10 12:28:37 -0800 | [diff] [blame] | 82 | }, |
| 83 | mounted() { |
Damian Celico | aeb1981 | 2022-11-24 02:00:53 +0100 | [diff] [blame] | 84 | this.getPrivilege(); |
Sukanya Pandey | edb8a77 | 2020-10-29 11:33:42 +0530 | [diff] [blame] | 85 | this.$root.$on('toggle-navigation', () => this.toggleIsOpen()); |
Yoshie Muranaka | 74f8687 | 2020-02-10 12:28:37 -0800 | [diff] [blame] | 86 | }, |
| 87 | methods: { |
| 88 | toggleIsOpen() { |
| 89 | this.isNavigationOpen = !this.isNavigationOpen; |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 90 | }, |
Damian Celico | aeb1981 | 2022-11-24 02:00:53 +0100 | [diff] [blame] | 91 | getPrivilege() { |
| 92 | this.currentUserRole = this.$store?.getters['global/userPrivilege']; |
| 93 | }, |
| 94 | filteredNavItem(navItem) { |
| 95 | if (this.currentUserRole) { |
| 96 | return navItem.filter(({ exclusiveToRoles }) => { |
| 97 | if (!exclusiveToRoles?.length) return true; |
| 98 | return exclusiveToRoles.includes(this.currentUserRole); |
| 99 | }); |
| 100 | } else return navItem; |
| 101 | }, |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 102 | }, |
Derick Montague | a2988f4 | 2020-01-17 13:46:30 -0600 | [diff] [blame] | 103 | }; |
| 104 | </script> |
Derick Montague | 42c1989 | 2020-01-17 16:10:34 -0600 | [diff] [blame] | 105 | |
Ed Tanous | 9c72979 | 2024-03-23 14:56:34 -0700 | [diff] [blame] | 106 | <style lang="scss" scoped> |
| 107 | @import '@/assets/styles/bmc/helpers/_index.scss'; |
| 108 | @import '@/assets/styles/bootstrap/_helpers.scss'; |
| 109 | |
Yoshie Muranaka | 71ac230 | 2019-12-26 11:43:36 -0800 | [diff] [blame] | 110 | svg { |
Derick Montague | 66f903f | 2020-02-28 11:22:31 -0600 | [diff] [blame] | 111 | fill: currentColor; |
| 112 | height: 1.2rem; |
| 113 | width: 1.2rem; |
Yoshie Muranaka | 71ac230 | 2019-12-26 11:43:36 -0800 | [diff] [blame] | 114 | margin-left: 0 !important; //!important overriding button specificity |
| 115 | vertical-align: text-bottom; |
| 116 | &:not(.icon-expand) { |
| 117 | margin-right: $spacer; |
| 118 | } |
| 119 | } |
| 120 | |
| 121 | .nav { |
SurenNeware | 057232b | 2020-06-08 20:53:26 +0530 | [diff] [blame] | 122 | padding-top: $spacer / 4; |
| 123 | @include media-breakpoint-up($responsive-layout-bp) { |
| 124 | padding-top: $spacer; |
| 125 | } |
Yoshie Muranaka | 71ac230 | 2019-12-26 11:43:36 -0800 | [diff] [blame] | 126 | } |
| 127 | |
| 128 | .nav-item__nav { |
Derick Montague | 42c1989 | 2020-01-17 16:10:34 -0600 | [diff] [blame] | 129 | list-style: none; |
| 130 | padding-left: 0; |
Yoshie Muranaka | 71ac230 | 2019-12-26 11:43:36 -0800 | [diff] [blame] | 131 | margin-left: 0; |
| 132 | |
Yoshie Muranaka | 85358ed | 2020-05-18 10:05:36 -0700 | [diff] [blame] | 133 | .nav-item { |
| 134 | outline: none; |
| 135 | } |
| 136 | |
Yoshie Muranaka | 71ac230 | 2019-12-26 11:43:36 -0800 | [diff] [blame] | 137 | .nav-link { |
| 138 | padding-left: $spacer * 4; |
Yoshie Muranaka | 85358ed | 2020-05-18 10:05:36 -0700 | [diff] [blame] | 139 | outline: none; |
Yoshie Muranaka | 71ac230 | 2019-12-26 11:43:36 -0800 | [diff] [blame] | 140 | |
| 141 | &:not(.nav-link--current) { |
| 142 | font-weight: normal; |
| 143 | } |
| 144 | } |
| 145 | } |
| 146 | |
| 147 | .btn-link { |
Dixsie Wolmers | 30f11f8 | 2020-11-10 16:07:56 -0600 | [diff] [blame] | 148 | display: inline-block; |
Yoshie Muranaka | 71ac230 | 2019-12-26 11:43:36 -0800 | [diff] [blame] | 149 | width: 100%; |
| 150 | text-align: left; |
| 151 | text-decoration: none !important; |
| 152 | border-radius: 0; |
| 153 | |
| 154 | &.collapsed { |
| 155 | .icon-expand { |
| 156 | transform: rotate(180deg); |
| 157 | } |
| 158 | } |
Yoshie Muranaka | 71ac230 | 2019-12-26 11:43:36 -0800 | [diff] [blame] | 159 | } |
| 160 | |
| 161 | .icon-expand { |
| 162 | float: right; |
| 163 | margin-top: $spacer / 4; |
| 164 | } |
| 165 | |
| 166 | .btn-link, |
| 167 | .nav-link { |
| 168 | position: relative; |
| 169 | font-weight: $headings-font-weight; |
| 170 | padding-left: $spacer; // defining consistent padding for links and buttons |
| 171 | padding-right: $spacer; |
Yoshie Muranaka | 01da818 | 2020-07-08 15:46:43 -0700 | [diff] [blame] | 172 | color: theme-color('secondary'); |
Yoshie Muranaka | 71ac230 | 2019-12-26 11:43:36 -0800 | [diff] [blame] | 173 | |
| 174 | &:hover { |
SurenNeware | 1f8117f | 2020-09-22 19:28:56 +0530 | [diff] [blame] | 175 | background-color: theme-color-level(dark, -10.5); |
Yoshie Muranaka | 01da818 | 2020-07-08 15:46:43 -0700 | [diff] [blame] | 176 | color: theme-color('dark'); |
Yoshie Muranaka | 71ac230 | 2019-12-26 11:43:36 -0800 | [diff] [blame] | 177 | } |
Yoshie Muranaka | 9f5cea8 | 2020-02-04 09:30:00 -0800 | [diff] [blame] | 178 | |
| 179 | &:focus { |
SurenNeware | 1f8117f | 2020-09-22 19:28:56 +0530 | [diff] [blame] | 180 | background-color: theme-color-level(light, 0); |
| 181 | box-shadow: inset 0 0 0 2px theme-color('primary'); |
Yoshie Muranaka | 01da818 | 2020-07-08 15:46:43 -0700 | [diff] [blame] | 182 | color: theme-color('dark'); |
Derick Montague | 59569d8 | 2020-10-26 15:17:31 -0500 | [diff] [blame] | 183 | outline: 0; |
Yoshie Muranaka | 9f5cea8 | 2020-02-04 09:30:00 -0800 | [diff] [blame] | 184 | } |
SurenNeware | 1f8117f | 2020-09-22 19:28:56 +0530 | [diff] [blame] | 185 | |
| 186 | &:active { |
Derick Montague | 59569d8 | 2020-10-26 15:17:31 -0500 | [diff] [blame] | 187 | background-color: theme-color('secondary'); |
SurenNeware | 1f8117f | 2020-09-22 19:28:56 +0530 | [diff] [blame] | 188 | color: $white; |
| 189 | } |
Yoshie Muranaka | 71ac230 | 2019-12-26 11:43:36 -0800 | [diff] [blame] | 190 | } |
| 191 | |
SurenNeware | 1f8117f | 2020-09-22 19:28:56 +0530 | [diff] [blame] | 192 | .nav-link--current { |
Yoshie Muranaka | 71ac230 | 2019-12-26 11:43:36 -0800 | [diff] [blame] | 193 | font-weight: $headings-font-weight; |
Yoshie Muranaka | 01da818 | 2020-07-08 15:46:43 -0700 | [diff] [blame] | 194 | background-color: theme-color('secondary'); |
| 195 | color: theme-color('light'); |
Derick Montague | 66f903f | 2020-02-28 11:22:31 -0600 | [diff] [blame] | 196 | cursor: default; |
SurenNeware | 1f8117f | 2020-09-22 19:28:56 +0530 | [diff] [blame] | 197 | box-shadow: none; |
Yoshie Muranaka | 71ac230 | 2019-12-26 11:43:36 -0800 | [diff] [blame] | 198 | |
| 199 | &::before { |
| 200 | content: ''; |
| 201 | position: absolute; |
| 202 | top: 0; |
| 203 | bottom: 0; |
| 204 | left: 0; |
| 205 | width: 4px; |
Yoshie Muranaka | 01da818 | 2020-07-08 15:46:43 -0700 | [diff] [blame] | 206 | background-color: theme-color('primary'); |
Yoshie Muranaka | 71ac230 | 2019-12-26 11:43:36 -0800 | [diff] [blame] | 207 | } |
Derick Montague | 59569d8 | 2020-10-26 15:17:31 -0500 | [diff] [blame] | 208 | |
| 209 | &:hover, |
SurenNeware | 1f8117f | 2020-09-22 19:28:56 +0530 | [diff] [blame] | 210 | &:focus { |
Derick Montague | 59569d8 | 2020-10-26 15:17:31 -0500 | [diff] [blame] | 211 | background-color: theme-color('secondary'); |
| 212 | color: theme-color('light'); |
SurenNeware | 1f8117f | 2020-09-22 19:28:56 +0530 | [diff] [blame] | 213 | } |
| 214 | } |
Yoshie Muranaka | 74f8687 | 2020-02-10 12:28:37 -0800 | [diff] [blame] | 215 | |
| 216 | .nav-container { |
| 217 | position: fixed; |
| 218 | width: $navigation-width; |
| 219 | top: $header-height; |
| 220 | bottom: 0; |
| 221 | left: 0; |
| 222 | z-index: $zindex-fixed; |
| 223 | overflow-y: auto; |
Derick Montague | 59569d8 | 2020-10-26 15:17:31 -0500 | [diff] [blame] | 224 | background-color: theme-color('light'); |
Yoshie Muranaka | 74f8687 | 2020-02-10 12:28:37 -0800 | [diff] [blame] | 225 | transform: translateX(-$navigation-width); |
| 226 | transition: transform $exit-easing--productive $duration--moderate-02; |
Derick Montague | 59569d8 | 2020-10-26 15:17:31 -0500 | [diff] [blame] | 227 | border-right: 1px solid theme-color-level('light', 2.85); |
| 228 | |
SurenNeware | 057232b | 2020-06-08 20:53:26 +0530 | [diff] [blame] | 229 | @include media-breakpoint-down(md) { |
| 230 | z-index: $zindex-fixed + 2; |
| 231 | } |
Yoshie Muranaka | 74f8687 | 2020-02-10 12:28:37 -0800 | [diff] [blame] | 232 | |
Derick Montague | 74466b8 | 2020-06-28 10:17:32 -0500 | [diff] [blame] | 233 | &.open, |
| 234 | &:focus-within { |
Yoshie Muranaka | 74f8687 | 2020-02-10 12:28:37 -0800 | [diff] [blame] | 235 | transform: translateX(0); |
| 236 | transition-timing-function: $entrance-easing--productive; |
| 237 | } |
| 238 | |
| 239 | @include media-breakpoint-up($responsive-layout-bp) { |
| 240 | transition-duration: $duration--fast-01; |
| 241 | transform: translateX(0); |
| 242 | } |
| 243 | } |
| 244 | |
| 245 | .nav-overlay { |
| 246 | position: fixed; |
| 247 | top: $header-height; |
| 248 | bottom: 0; |
| 249 | left: 0; |
| 250 | right: 0; |
SurenNeware | 057232b | 2020-06-08 20:53:26 +0530 | [diff] [blame] | 251 | z-index: $zindex-fixed + 1; |
Yoshie Muranaka | 74f8687 | 2020-02-10 12:28:37 -0800 | [diff] [blame] | 252 | background-color: $black; |
| 253 | opacity: 0.5; |
| 254 | |
| 255 | &.fade-enter-active { |
| 256 | transition: opacity $duration--moderate-02 $entrance-easing--productive; |
| 257 | } |
| 258 | |
| 259 | &.fade-leave-active { |
| 260 | transition: opacity $duration--fast-02 $exit-easing--productive; |
| 261 | } |
| 262 | |
SurenNeware | 151dd24 | 2020-11-10 20:15:05 +0530 | [diff] [blame] | 263 | &.fade-enter, // Remove this vue2 based only class when switching to vue3 |
| 264 | &.fade-enter-from, // This is vue3 based only class modified from 'fade-enter' |
Yoshie Muranaka | 74f8687 | 2020-02-10 12:28:37 -0800 | [diff] [blame] | 265 | &.fade-leave-to { |
| 266 | opacity: 0; |
| 267 | } |
| 268 | |
| 269 | @include media-breakpoint-up($responsive-layout-bp) { |
| 270 | display: none; |
| 271 | } |
| 272 | } |
Derick Montague | 42c1989 | 2020-01-17 16:10:34 -0600 | [diff] [blame] | 273 | </style> |