Skip to content

Commit 635c8b4

Browse files
committed
feat(Menu): add highlighting of current link
1 parent be85bd2 commit 635c8b4

File tree

1 file changed

+50
-6
lines changed

1 file changed

+50
-6
lines changed

components/Menu.vue

Lines changed: 50 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
Bibliothèque
3737
</nuxt-link>
3838

39-
<nuxt-link class="cta-link cta-link-with-arrow" tag="li" to="/tutoriel/introduction">
39+
<nuxt-link class="cta-link cta-link-with-arrow" tag="li" :class="isTutorialLink" to="/tutoriel/introduction">
4040
<div class="logo-link-wrapper">
4141
<Icon type="info" theme="theme--white"/>
4242
</div>
@@ -47,19 +47,19 @@
4747
<template v-if="isAuthenticated && (role === 'admin' || role === 'super_admin')">
4848
<span>Administration</span>
4949
<ul>
50-
<nuxt-link class="cta-link cta-link-with-arrow" tag="li" to="/administration/exercices">
50+
<nuxt-link class="cta-link cta-link-with-arrow" tag="li" :class="isAdministrationExerciseLink" to="/administration/exercices">
5151
<div class="logo-link-wrapper">
5252
<Icon type="document" theme="theme--white"/>
5353
</div>
5454
Exercices
5555
</nuxt-link>
56-
<nuxt-link class="cta-link cta-link-with-arrow" tag="li" to="/administration/categories">
56+
<nuxt-link class="cta-link cta-link-with-arrow" tag="li" :class="isAdministrationCategoryLink" to="/administration/categories">
5757
<div class="logo-link-wrapper">
5858
<Icon type="bookmark" theme="theme--white"/>
5959
</div>
6060
Catégories
6161
</nuxt-link>
62-
<nuxt-link class="cta-link cta-link-with-arrow" tag="li" to="/administration/tags">
62+
<nuxt-link class="cta-link cta-link-with-arrow" tag="li" :class="isAdministrationTagLink" to="/administration/tags">
6363
<div class="logo-link-wrapper">
6464
<Icon type="tags" theme="theme--white"/>
6565
</div>
@@ -77,13 +77,13 @@
7777
<template v-if="isAuthenticated">
7878
<span>Gestion</span>
7979
<ul>
80-
<nuxt-link class="cta-link cta-link-with-arrow" tag="li" to="/gestion/mes-exercices">
80+
<nuxt-link class="cta-link cta-link-with-arrow" :class="isGestionLink" tag="li" to="/gestion/mes-exercices">
8181
<div class="logo-link-wrapper">
8282
<Icon type="document" theme="theme--white"/>
8383
</div>
8484
Mes exercices
8585
</nuxt-link>
86-
<nuxt-link class="cta-link cta-link-with-arrow" tag="li" to="/gestion/mes-favoris">
86+
<nuxt-link class="cta-link cta-link-with-arrow" :class="isFavoriteLink" tag="li" to="/gestion/mes-favoris">
8787
<div class="logo-link-wrapper">
8888
<Icon type="star" theme="theme--white"/>
8989
</div>
@@ -142,9 +142,53 @@
142142
}
143143
144144
get role(): UserRole {
145+
console.log(this.$route.path);
146+
145147
return this.$auth.user.role
146148
}
147149
150+
get isAdministrationExerciseLink() {
151+
const regex = new RegExp(/^(\/administration\/exercices)/gm);
152+
if(this.$route.path.match(regex)) return 'nuxt-link-exact-active';
153+
return '';
154+
}
155+
156+
get isAdministrationTagLink() {
157+
const regex = new RegExp(/^(\/administration\/tags)/gm);
158+
if(this.$route.path.match(regex)) return 'nuxt-link-exact-active';
159+
return '';
160+
}
161+
162+
get isAdministrationCategoryLink() {
163+
const regex = new RegExp(/^(\/administration\/categories)/gm);
164+
if(this.$route.path.match(regex)) return 'nuxt-link-exact-active';
165+
return '';
166+
}
167+
168+
get isGestionLink() {
169+
const regex = new RegExp(/^(\/gestion\/mes-exercices)/gm);
170+
if(this.$route.path.match(regex)) return 'nuxt-link-exact-active';
171+
return '';
172+
}
173+
174+
get isFavoriteLink() {
175+
const regex = new RegExp(/^(\/gestion\/mes-favoris)/gm);
176+
if(this.$route.path.match(regex)) return 'nuxt-link-exact-active';
177+
return '';
178+
}
179+
180+
get isTutorialLink() {
181+
const regex = new RegExp(/^(\/tutoriel)/gm);
182+
if(this.$route.path.match(regex)) return 'nuxt-link-exact-active';
183+
return '';
184+
}
185+
186+
get routeLol() {
187+
console.log(this.$route);
188+
189+
return this.$route;
190+
}
191+
148192
async logout() {
149193
this.$accessor.favorites.RESET();
150194
this.$accessor.historical.RESET();

0 commit comments

Comments
 (0)