diff --git a/components/NavBar.vue b/components/NavBar.vue index 8233c1b..f55ee1e 100644 --- a/components/NavBar.vue +++ b/components/NavBar.vue @@ -6,6 +6,9 @@ + +

{{ pages[this?.$route?.name] }}

+
@@ -29,7 +32,16 @@ export default { config: {api: this.$config.API_URL, pronote: this.$config.PRONOTE_API_URL}, errors: [], isSidebarOpen: false, - isShadowed: false + isShadowed: false, + pages: { + 'index': "Asbences", + 'cantine': "Cantine", + 'shop': "Boutique", + 'params': "Paramètres", + 'user-profile': 'Profile', + 'admin-users': "Users" + }, + isHiddenTitle: true } }, methods: { @@ -37,17 +49,17 @@ export default { this.$emit('toggle-sidebar'); }, onScroll() { - // Get the current scroll position const scrollPosition = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0; - // Set isShadowed to true if scroll position is greater than 0, otherwise set it to false this.isShadowed = scrollPosition > 0; + if (scrollPosition > 28) this.isHiddenTitle = false + else this.isHiddenTitle = true } }, beforeUnmount() { - window.removeEventListener('scroll', this.onScroll); // Remove scroll event listener before component unmount + window.removeEventListener('scroll', this.onScroll) }, async mounted() { - window.addEventListener('scroll', this.onScroll); // Add scroll event listener on component mount + window.addEventListener('scroll', this.onScroll) this.userInfos = JSON.parse(window.localStorage.getItem("user")) let user = await getUser(this.config.api, this.userInfos.id) if (!user) return this.errors.push({message: "Impossible de charger l'utilisateur", color: "danger"}) diff --git a/components/SideBar.vue b/components/SideBar.vue index bdffbd3..0ec5269 100644 --- a/components/SideBar.vue +++ b/components/SideBar.vue @@ -1,5 +1,5 @@