Skip to content
Snippets Groups Projects
Commit 039d98f4 authored by Trygve Jørgensen's avatar Trygve Jørgensen
Browse files

refactor(navbar): navbar cleanup

parent aed305d7
No related branches found
No related tags found
3 merge requests!66Final merge,!24UI cleanup,!4Pipeline fix
<script setup lang="ts"> <script setup lang="ts">
import NavBarComponent from '@/components/NavBarComponent.vue' import NavBarComponent from '@/components/NavBarComponent.vue'
import { RouterView, useRoute } from 'vue-router'
import { computed } from 'vue'
const route = useRoute()
const showNavBar = computed(() => {
return !(
route.path == '/' ||
route.path == '/registrer' ||
route.path == '/logginn' ||
route.path == '/forgotPassword'
)
})
</script> </script>
<template> <template>
<NavBarComponent /> <NavBarComponent v-if="showNavBar" />
<main>
<RouterView />
</main>
</template> </template>
<template> <template>
<nav v-if="showNavBar" class="flex justify-center items-center mt-10 text-xl w-full"> <nav class="flex justify-between items-center min-h-32 text-xl w-full px-3">
<div> <div>
<img <router-link to="/hjem" @click="hamburgerOpen = false">
src="@/assets/spareSti.png" <img
alt="logo" alt="logo"
class="absolute left-0 top-8 w-48 h-15 cursor-pointer transition-transform duration-300 ease-in-out hover:scale-110 hover:opacity-90" class="w-40 cursor-pointer transition-transform duration-300 ease-in-out hover:scale-110 hover:opacity-90"
@click="goToHome" src="@/assets/spareSti.png"
/> />
<div class="absolute left-6 top-24 flex-1 sm:flex justify-start items-center"> </router-link>
<div class="flex md:left-80 md:top-20 right-28 top-20 items-center">
<img src="@/assets/streakFlame.png" alt="streak" class="w-8 h-8" /> <div class="flex flex-row justify-center">
<p class="font-bold">Streak</p> <img alt="streak" class="w-8 h-8" src="@/assets/streakFlame.png" />
</div> <p class="font-bold">Streak</p>
</div> </div>
</div> </div>
<div class="navcontainer flex space-x-10 justify-center"> <div v-if="!isHamburger" class="flex flex-row gap-10">
<router-link to="/hjem" class="nav-link" active-class="border-b-2">🏠Hjem</router-link> <router-link active-class="border-b-2" to="/hjem">🏠Hjem</router-link>
<router-link to="/sparemaal" class="nav-link" active-class="border-b-2" <router-link active-class="border-b-2" to="/sparemaal">🎯Sparemål</router-link>
>🎯Sparemål</router-link <router-link active-class="border-b-2" to="/spareutfordringer"
>
<router-link to="/spareutfordringer" class="nav-link" active-class="border-b-2"
>💰Spareutfordringer</router-link >💰Spareutfordringer</router-link
> >
<router-link to="/profil" class="nav-link" active-class="border-b-2" <router-link active-class="border-b-2" to="/profil">🤭Profil</router-link>
>🤭Profil</router-link
>
<router-link to="/konfigurasjonSteg1" class="nav-link" active-class="border-b-2"
>🛠️Konfigurasjon</router-link
>
<button
@click="logout"
class="hidden sm:flex absolute right-10 py-2 px-6 rounded-full focus:outline-none focus:ring focus:ring-black-300"
>
Logg ut
</button>
</div> </div>
<button class="hamburger-menu sm:hidden absolute right-10 top-10" @click="toggleMenu">
<p></p> <div v-if="!isHamburger" class="flex justify-center w-40">
</button> <button class="focus:ring focus:ring-black-300" @click="logout">Logg ut</button>
</div>
<button v-if="isHamburger" @click="toggleMenu"></button>
</nav> </nav>
<div <div
v-if="menuOpen" v-if="hamburgerOpen"
class="sm:hidden flex flex-col bg-white absolute border border-slate-300 top-10 w-full mt-10 z-50 rounded-xl" class="flex flex-col bg-white absolute border border-slate-300 top-10 w-full mt-10 z-50"
> >
<router-link to="/hjem" @click="menuOpen = false">🏠Hjem</router-link> <router-link to="/hjem" @click="hamburgerOpen = false">🏠Hjem</router-link>
<router-link to="/sparemaal" @click="menuOpen = false">🎯Sparemål</router-link> <router-link to="/sparemaal" @click="hamburgerOpen = false">🎯Sparemål</router-link>
<router-link to="/spareutfordringer" @click="menuOpen = false" <router-link to="/spareutfordringer" @click="hamburgerOpen = false"
>💰Spareutfordringer</router-link >💰Spareutfordringer</router-link
> >
<router-link to="/profil" @click="menuOpen = false">🤭Profil</router-link> <router-link to="/profil" @click="hamburgerOpen = false">🤭Profil</router-link>
<router-link to="/konfigurasjonSteg1" @click="menuOpen = false" <button class="focus:ring focus:ring-black-300 bg-transparent" @click="logout">
>🛠️Konfigurasjon</router-link
>
<button
@click="logout"
class="py-2 px-6 mx-auto rounded-full focus:outline-none focus:ring focus:ring-black-300 bg-transparent"
>
Logg ut Logg ut
</button> </button>
</div> </div>
<main>
<RouterView />
</main>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { RouterLink, RouterView, useRoute, useRouter } from 'vue-router' import { RouterLink, useRouter } from 'vue-router'
import { computed, onMounted, ref } from 'vue' import { onMounted, ref } from 'vue'
const route = useRoute()
const router = useRouter() const router = useRouter()
const windowWidth = ref(window.innerWidth)
const menuOpen = ref(false)
const showNavBar = computed(() => { const windowWidth = ref(window.innerWidth)
return ( const hamburgerOpen = ref(false)
route.path == '/hjem' || const isHamburger = ref(false)
route.path == '/sparemaal' ||
route.path == '/spareutfordringer' ||
route.path == '/profil' ||
route.path == '/konfigurasjonSteg1'
)
})
const logout = () => { const logout = () => {
router.push('/login') router.push('/login')
menuOpen.value = false hamburgerOpen.value = false
} }
const goToHome = () => { const toggleMenu = () => {
router.push('/hjem') hamburgerOpen.value = !hamburgerOpen.value
menuOpen.value = false
} }
const toggleMenu = () => { const updateWindowWidth = () => {
menuOpen.value = !menuOpen.value windowWidth.value = window.innerWidth
if (windowWidth.value < 1150) {
isHamburger.value = true
} else {
isHamburger.value = false
hamburgerOpen.value = false
}
} }
onMounted(() => { onMounted(() => {
const updateWindowWidth = () => {
windowWidth.value = window.innerWidth
}
window.addEventListener('resize', updateWindowWidth) window.addEventListener('resize', updateWindowWidth)
updateWindowWidth()
}) })
</script> </script>
<style scoped> <style scoped></style>
@media (max-width: 1150px) { \ No newline at end of file
.hamburger-menu {
display: block;
cursor: pointer;
}
.navcontainer {
display: none;
}
}
</style>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment