2021-07-25 13:03:34 +02:00
|
|
|
<template>
|
|
|
|
<div id="nav">
|
2023-07-12 18:14:17 +02:00
|
|
|
<Modal
|
|
|
|
v-show="displayModal"
|
|
|
|
:title="$t('common.CONFIRMATION')"
|
|
|
|
:message="$t('user.LOGOUT_CONFIRMATION')"
|
|
|
|
@confirmAction="logout"
|
|
|
|
@cancelAction="updateDisplayModal(false)"
|
|
|
|
@keydown.esc="updateDisplayModal(false)"
|
|
|
|
/>
|
2021-08-07 18:10:32 +02:00
|
|
|
<div class="nav-container">
|
2021-08-04 09:10:00 +02:00
|
|
|
<div class="nav-app-name">
|
2023-07-02 17:19:10 +02:00
|
|
|
<router-link class="nav-item app-name" to="/">FitTrackee</router-link>
|
2021-07-25 17:08:22 +02:00
|
|
|
</div>
|
2021-08-04 09:10:00 +02:00
|
|
|
<div class="nav-icon-open" :class="{ 'menu-open': isMenuOpen }">
|
2023-07-13 09:14:00 +02:00
|
|
|
<button class="menu-button transparent" @click="openMenu()">
|
|
|
|
<i class="fa fa-bars hamburger-icon"></i>
|
|
|
|
</button>
|
2021-07-25 17:08:22 +02:00
|
|
|
</div>
|
2021-08-04 09:10:00 +02:00
|
|
|
<div class="nav-items" :class="{ 'menu-open': isMenuOpen }">
|
|
|
|
<div class="nav-items-close">
|
2021-08-04 13:59:51 +02:00
|
|
|
<div class="app-name">FitTrackee</div>
|
2023-07-13 09:14:00 +02:00
|
|
|
<button class="menu-button transparent" @click="closeMenu()">
|
|
|
|
<i
|
|
|
|
class="fa fa-close close-icon nav-item"
|
|
|
|
:class="{ 'menu-closed': !isMenuOpen }"
|
|
|
|
/>
|
|
|
|
</button>
|
2021-08-04 09:10:00 +02:00
|
|
|
</div>
|
|
|
|
<div class="nav-items-app-menu" @click="closeMenu()">
|
2021-08-04 20:22:08 +02:00
|
|
|
<div class="nav-items-group" v-if="isAuthenticated">
|
2021-10-31 19:48:49 +01:00
|
|
|
<router-link class="nav-item" to="/">
|
|
|
|
{{ $t('dashboard.DASHBOARD') }}
|
|
|
|
</router-link>
|
2021-10-05 15:23:41 +02:00
|
|
|
<router-link class="nav-item" to="/workouts">
|
2021-10-20 17:38:25 +02:00
|
|
|
{{ capitalize($t('workouts.WORKOUT', 2)) }}
|
2021-10-05 15:23:41 +02:00
|
|
|
</router-link>
|
2021-10-03 19:23:17 +02:00
|
|
|
<router-link class="nav-item" to="/statistics">
|
2021-10-20 17:38:25 +02:00
|
|
|
{{ $t('statistics.STATISTICS') }}
|
2021-10-03 19:23:17 +02:00
|
|
|
</router-link>
|
2021-09-29 11:32:05 +02:00
|
|
|
<router-link class="nav-item" to="/workouts/add">
|
2021-10-20 17:38:25 +02:00
|
|
|
{{ $t('workouts.ADD_WORKOUT') }}
|
2021-09-29 11:32:05 +02:00
|
|
|
</router-link>
|
2021-10-23 21:34:02 +02:00
|
|
|
<router-link
|
|
|
|
class="nav-item"
|
|
|
|
v-if="isAuthenticated && authUser.admin"
|
|
|
|
to="/admin"
|
|
|
|
>
|
|
|
|
{{ $t('admin.ADMIN') }}
|
|
|
|
</router-link>
|
2021-08-14 19:59:22 +02:00
|
|
|
<div class="nav-item nav-separator" />
|
2021-08-04 20:22:08 +02:00
|
|
|
</div>
|
2021-08-04 09:10:00 +02:00
|
|
|
</div>
|
|
|
|
<div class="nav-items-user-menu">
|
2021-08-04 20:22:08 +02:00
|
|
|
<div class="nav-items-group" v-if="isAuthenticated">
|
2021-08-14 19:59:22 +02:00
|
|
|
<div class="nav-item nav-profile-img">
|
2021-10-17 21:01:14 +02:00
|
|
|
<UserPicture :user="authUser" />
|
2021-08-14 18:06:50 +02:00
|
|
|
</div>
|
2021-10-13 17:29:12 +02:00
|
|
|
<router-link class="nav-item" to="/profile" @click="closeMenu">
|
|
|
|
{{ authUser.username }}
|
|
|
|
</router-link>
|
2023-07-12 18:14:17 +02:00
|
|
|
<button
|
|
|
|
class="logout-button transparent"
|
|
|
|
@click="updateDisplayModal(true)"
|
2023-07-13 09:34:16 +02:00
|
|
|
:aria-label="$t('user.LOGOUT')"
|
2023-07-12 18:14:17 +02:00
|
|
|
>
|
|
|
|
<i class="fa fa-sign-out logout-fa" aria-hidden="true" />
|
|
|
|
<span class="logout-text">{{ $t('user.LOGOUT') }}</span>
|
|
|
|
</button>
|
2021-08-04 20:22:08 +02:00
|
|
|
</div>
|
|
|
|
<div class="nav-items-group" v-else>
|
2021-10-31 19:48:49 +01:00
|
|
|
<router-link class="nav-item" to="/login" @click="closeMenu">
|
|
|
|
{{ $t('user.LOGIN') }}
|
|
|
|
</router-link>
|
|
|
|
<router-link class="nav-item" to="/register" @click="closeMenu">
|
|
|
|
{{ $t('user.REGISTER') }}
|
|
|
|
</router-link>
|
2021-08-04 20:22:08 +02:00
|
|
|
</div>
|
2021-08-04 13:59:51 +02:00
|
|
|
<Dropdown
|
|
|
|
v-if="availableLanguages && language"
|
|
|
|
class="nav-item"
|
|
|
|
:options="availableLanguages"
|
|
|
|
:selected="language"
|
|
|
|
@selected="updateLanguage"
|
|
|
|
>
|
|
|
|
<i class="fa fa-language"></i>
|
|
|
|
</Dropdown>
|
2021-08-04 09:10:00 +02:00
|
|
|
</div>
|
2021-07-25 17:08:22 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
2021-07-25 13:03:34 +02:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
2021-11-10 21:19:27 +01:00
|
|
|
<script setup lang="ts">
|
2023-07-12 18:14:17 +02:00
|
|
|
import { ComputedRef, Ref, computed, ref, capitalize } from 'vue'
|
2021-08-04 13:59:51 +02:00
|
|
|
|
2021-10-17 21:01:14 +02:00
|
|
|
import UserPicture from '@/components/User/UserPicture.vue'
|
2021-11-03 10:41:53 +01:00
|
|
|
import { AUTH_USER_STORE, ROOT_STORE } from '@/store/constants'
|
2021-08-21 18:36:44 +02:00
|
|
|
import { IDropdownOption } from '@/types/forms'
|
2022-03-13 09:50:09 +01:00
|
|
|
import { IAuthUserProfile } from '@/types/user'
|
2021-08-11 22:21:26 +02:00
|
|
|
import { useStore } from '@/use/useStore'
|
2021-10-31 19:48:49 +01:00
|
|
|
import { availableLanguages } from '@/utils/locales'
|
2021-07-25 13:03:34 +02:00
|
|
|
|
2021-11-10 21:19:27 +01:00
|
|
|
const emit = defineEmits(['menuInteraction'])
|
2021-08-14 18:06:50 +02:00
|
|
|
|
2021-11-10 21:19:27 +01:00
|
|
|
const store = useStore()
|
2021-08-14 18:06:50 +02:00
|
|
|
|
2022-03-13 09:50:09 +01:00
|
|
|
const authUser: ComputedRef<IAuthUserProfile> = computed(
|
2021-11-10 21:19:27 +01:00
|
|
|
() => store.getters[AUTH_USER_STORE.GETTERS.AUTH_USER_PROFILE]
|
|
|
|
)
|
|
|
|
const isAuthenticated: ComputedRef<boolean> = computed(
|
|
|
|
() => store.getters[AUTH_USER_STORE.GETTERS.IS_AUTHENTICATED]
|
|
|
|
)
|
|
|
|
const language: ComputedRef<string> = computed(
|
|
|
|
() => store.getters[ROOT_STORE.GETTERS.LANGUAGE]
|
|
|
|
)
|
2023-07-12 18:14:17 +02:00
|
|
|
const isMenuOpen: Ref<boolean> = ref(false)
|
|
|
|
const displayModal: Ref<boolean> = ref(false)
|
2021-08-04 13:59:51 +02:00
|
|
|
|
2021-11-10 21:19:27 +01:00
|
|
|
function openMenu() {
|
|
|
|
isMenuOpen.value = true
|
|
|
|
emit('menuInteraction', true)
|
|
|
|
}
|
|
|
|
function closeMenu() {
|
|
|
|
isMenuOpen.value = false
|
|
|
|
emit('menuInteraction', false)
|
|
|
|
}
|
|
|
|
function updateLanguage(option: IDropdownOption) {
|
2022-06-29 16:27:00 +02:00
|
|
|
store.dispatch(
|
|
|
|
ROOT_STORE.ACTIONS.UPDATE_APPLICATION_LANGUAGE,
|
|
|
|
option.value.toString()
|
|
|
|
)
|
2021-11-10 21:19:27 +01:00
|
|
|
}
|
|
|
|
function logout() {
|
|
|
|
store.dispatch(AUTH_USER_STORE.ACTIONS.LOGOUT)
|
2023-07-12 18:14:17 +02:00
|
|
|
displayModal.value = false
|
|
|
|
}
|
|
|
|
function updateDisplayModal(display: boolean) {
|
|
|
|
displayModal.value = display
|
|
|
|
if (display) {
|
2023-07-13 12:54:45 +02:00
|
|
|
const button = document.getElementById('modal-cancel-button')
|
2023-07-12 18:14:17 +02:00
|
|
|
if (button) {
|
|
|
|
button.focus()
|
|
|
|
}
|
|
|
|
}
|
2021-11-10 21:19:27 +01:00
|
|
|
}
|
2021-07-25 13:03:34 +02:00
|
|
|
</script>
|
|
|
|
|
2021-07-25 17:08:22 +02:00
|
|
|
<style scoped lang="scss">
|
2021-11-29 11:23:21 +01:00
|
|
|
@import '~@/scss/fonts.scss';
|
|
|
|
@import '~@/scss/colors.scss';
|
|
|
|
@import '~@/scss/vars.scss';
|
2021-08-04 09:10:00 +02:00
|
|
|
|
2021-07-25 17:08:22 +02:00
|
|
|
#nav {
|
2021-08-04 09:10:00 +02:00
|
|
|
background: var(--nav-bar-background-color);
|
2021-07-25 17:08:22 +02:00
|
|
|
display: flex;
|
2021-08-04 09:10:00 +02:00
|
|
|
padding: 15px 10px;
|
2021-07-25 17:08:22 +02:00
|
|
|
|
2021-08-07 18:10:32 +02:00
|
|
|
.nav-container {
|
|
|
|
display: flex;
|
|
|
|
|
|
|
|
margin-left: auto;
|
|
|
|
margin-right: auto;
|
|
|
|
padding: 0 15px 15px 15px;
|
|
|
|
max-width: $container-width;
|
|
|
|
width: 100%;
|
|
|
|
|
|
|
|
border-bottom: solid 1px var(--nav-border-color);
|
|
|
|
}
|
|
|
|
|
2021-07-25 17:08:22 +02:00
|
|
|
a {
|
|
|
|
&.router-link-exact-active {
|
2021-08-04 09:10:00 +02:00
|
|
|
color: var(--nav-bar-link-active);
|
2021-08-14 19:59:22 +02:00
|
|
|
font-weight: bold;
|
2021-07-25 17:08:22 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.app-name {
|
|
|
|
font-size: 1.2em;
|
|
|
|
font-weight: bold;
|
2021-08-04 09:10:00 +02:00
|
|
|
margin-right: 10px;
|
2023-07-12 19:53:37 +02:00
|
|
|
line-height: 1.6em;
|
2021-07-25 17:08:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
.fa {
|
|
|
|
font-size: 1.2em;
|
|
|
|
}
|
|
|
|
|
|
|
|
.nav-icon-open {
|
|
|
|
display: none;
|
|
|
|
}
|
2021-08-04 13:59:51 +02:00
|
|
|
|
2021-07-25 17:08:22 +02:00
|
|
|
.hamburger-icon,
|
|
|
|
.close-icon {
|
|
|
|
display: none;
|
|
|
|
}
|
2023-07-13 09:14:00 +02:00
|
|
|
.menu-button {
|
|
|
|
padding: 0;
|
|
|
|
}
|
2021-07-25 17:08:22 +02:00
|
|
|
|
|
|
|
.nav-items {
|
|
|
|
display: flex;
|
|
|
|
flex: 1;
|
|
|
|
justify-content: space-between;
|
2023-07-12 19:53:37 +02:00
|
|
|
line-height: 2em;
|
2021-07-25 17:08:22 +02:00
|
|
|
width: 100%;
|
|
|
|
|
|
|
|
.nav-items-close {
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
|
2021-08-04 13:59:51 +02:00
|
|
|
.nav-items-app-menu,
|
|
|
|
.nav-items-user-menu {
|
|
|
|
display: flex;
|
|
|
|
margin: 0;
|
|
|
|
padding: 0;
|
|
|
|
}
|
|
|
|
|
2021-08-04 20:22:08 +02:00
|
|
|
.nav-items-group {
|
|
|
|
display: flex;
|
|
|
|
}
|
2021-07-25 17:08:22 +02:00
|
|
|
.nav-item {
|
2021-08-04 13:59:51 +02:00
|
|
|
padding: 0 10px;
|
2023-07-12 19:53:37 +02:00
|
|
|
&.dropdown-wrapper {
|
|
|
|
padding: 0;
|
|
|
|
margin-left: 2px;
|
|
|
|
::v-deep(.dropdown-list) {
|
|
|
|
z-index: 1000;
|
|
|
|
margin-left: -150px !important;
|
|
|
|
width: 180px !important;
|
|
|
|
}
|
2021-08-04 13:59:51 +02:00
|
|
|
}
|
2021-07-25 17:08:22 +02:00
|
|
|
}
|
2021-08-14 18:06:50 +02:00
|
|
|
|
2021-08-14 18:58:59 +02:00
|
|
|
.nav-link {
|
|
|
|
color: var(--app-a-color);
|
|
|
|
cursor: pointer;
|
|
|
|
}
|
|
|
|
|
2021-08-14 18:06:50 +02:00
|
|
|
.nav-profile-img {
|
|
|
|
margin-bottom: -$default-padding;
|
2021-10-17 21:01:14 +02:00
|
|
|
::v-deep(.user-picture) {
|
|
|
|
img {
|
|
|
|
height: 32px;
|
|
|
|
width: 32px;
|
|
|
|
object-fit: cover;
|
|
|
|
}
|
|
|
|
.no-picture {
|
|
|
|
font-size: 1.7em;
|
|
|
|
}
|
2021-08-14 19:59:22 +02:00
|
|
|
}
|
2021-08-14 18:06:50 +02:00
|
|
|
}
|
2021-08-14 19:59:22 +02:00
|
|
|
|
|
|
|
.nav-separator {
|
|
|
|
display: none;
|
2021-08-14 18:06:50 +02:00
|
|
|
}
|
2023-07-12 18:14:17 +02:00
|
|
|
.logout-button {
|
|
|
|
padding: $default-padding * 0.5 $default-padding * 0.75;
|
|
|
|
margin-left: 2px;
|
|
|
|
.logout-fa {
|
|
|
|
display: block;
|
|
|
|
}
|
|
|
|
.logout-text {
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
}
|
2021-07-25 17:08:22 +02:00
|
|
|
}
|
|
|
|
|
2021-08-04 09:10:00 +02:00
|
|
|
@media screen and (max-width: $medium-limit) {
|
2021-07-25 17:08:22 +02:00
|
|
|
.hamburger-icon {
|
|
|
|
display: block;
|
|
|
|
}
|
|
|
|
.nav-icon-open {
|
|
|
|
display: block;
|
|
|
|
text-align: right;
|
|
|
|
width: 100%;
|
|
|
|
}
|
|
|
|
.nav-icon-open.menu-open {
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
|
|
|
|
.close-icon {
|
|
|
|
display: block;
|
|
|
|
}
|
|
|
|
.close-icon.menu-closed {
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
|
|
|
|
.nav-items {
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
.nav-items.menu-open {
|
|
|
|
display: flex;
|
|
|
|
flex-direction: column;
|
|
|
|
justify-content: flex-start;
|
2021-09-27 12:50:26 +02:00
|
|
|
z-index: 1001;
|
2021-07-25 17:08:22 +02:00
|
|
|
|
|
|
|
position: absolute;
|
|
|
|
top: 0;
|
|
|
|
right: 0;
|
|
|
|
bottom: 0;
|
|
|
|
left: 0;
|
|
|
|
|
2021-08-04 09:10:00 +02:00
|
|
|
background: var(--nav-bar-background-color);
|
2021-07-25 17:08:22 +02:00
|
|
|
|
|
|
|
.nav-items-close,
|
|
|
|
.nav-items-app-menu,
|
|
|
|
.nav-items-user-menu {
|
|
|
|
display: flex;
|
|
|
|
flex-direction: column;
|
|
|
|
}
|
|
|
|
|
|
|
|
.nav-items-close {
|
|
|
|
align-items: center;
|
|
|
|
display: flex;
|
|
|
|
flex-direction: row;
|
|
|
|
justify-content: space-between;
|
|
|
|
|
|
|
|
.app-name {
|
2021-08-04 13:59:51 +02:00
|
|
|
padding: 15px 25px;
|
2021-07-25 17:08:22 +02:00
|
|
|
}
|
|
|
|
}
|
2021-08-04 13:59:51 +02:00
|
|
|
|
2021-08-04 20:22:08 +02:00
|
|
|
.nav-items-group {
|
|
|
|
display: flex;
|
|
|
|
flex-direction: column;
|
2023-07-12 18:14:17 +02:00
|
|
|
|
|
|
|
.logout-button {
|
|
|
|
padding: $default-padding $default-padding $default-padding
|
|
|
|
$default-padding * 2.4;
|
|
|
|
color: var(--app-a-color);
|
|
|
|
text-align: left;
|
|
|
|
.logout-fa {
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
.logout-text {
|
|
|
|
display: block;
|
|
|
|
}
|
|
|
|
}
|
2021-08-04 20:22:08 +02:00
|
|
|
}
|
|
|
|
|
2021-08-04 13:59:51 +02:00
|
|
|
.nav-item {
|
|
|
|
padding: 7px 25px;
|
2023-07-12 19:53:37 +02:00
|
|
|
&.dropdown-wrapper {
|
2023-07-13 09:25:42 +02:00
|
|
|
padding-left: $default-padding * 2;
|
2023-07-12 19:53:37 +02:00
|
|
|
::v-deep(.dropdown-list) {
|
|
|
|
margin-left: initial !important;
|
|
|
|
width: auto !important;
|
2023-07-13 09:25:42 +02:00
|
|
|
height: 200px;
|
|
|
|
overflow-y: scroll;
|
2023-07-12 19:53:37 +02:00
|
|
|
}
|
2022-11-30 10:44:19 +01:00
|
|
|
}
|
2021-08-04 13:59:51 +02:00
|
|
|
}
|
2021-08-14 19:59:22 +02:00
|
|
|
|
|
|
|
.nav-profile-img {
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
|
|
|
|
.nav-separator {
|
|
|
|
display: flex;
|
|
|
|
border-top: solid 1px var(--nav-border-color);
|
|
|
|
margin: 0 $default-margin * 2;
|
|
|
|
padding: 0;
|
|
|
|
}
|
2021-07-25 17:08:22 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|