Add option to hide the menu on desktop
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
kolaente 2020-06-25 23:56:41 +02:00
parent efc047ced7
commit d586e15c56
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
3 changed files with 74 additions and 21 deletions

View File

@ -14,8 +14,18 @@
<img src="/images/logo-full-pride.svg" alt="Vikunja" v-if="(new Date()).getMonth() === 5"/> <img src="/images/logo-full-pride.svg" alt="Vikunja" v-if="(new Date()).getMonth() === 5"/>
<img src="/images/logo-full.svg" alt="Vikunja" v-else/> <img src="/images/logo-full.svg" alt="Vikunja" v-else/>
</router-link> </router-link>
<a
@click="menuActive = true"
class="menu-show-button"
:class="{'is-visible': !menuActive}"
>
<icon icon="bars"></icon>
</a>
</div> </div>
<a @click="mobileMenuActive = true" class="mobilemenu-show-button" v-if="!mobileMenuActive"> <a
@click="menuActive = true"
class="menu-show-button"
>
<icon icon="bars"></icon> <icon icon="bars"></icon>
</a> </a>
<div class="list-title" v-if="currentList.id"> <div class="list-title" v-if="currentList.id">
@ -61,7 +71,7 @@
</div> </div>
</nav> </nav>
<div v-if="userAuthenticated && (userInfo && userInfo.type === authTypes.USER)"> <div v-if="userAuthenticated && (userInfo && userInfo.type === authTypes.USER)">
<a @click="mobileMenuActive = false" class="mobilemenu-hide-button" v-if="mobileMenuActive"> <a @click="menuActive = false" class="menu-hide-button" v-if="menuActive">
<icon icon="times"></icon> <icon icon="times"></icon>
</a> </a>
<div <div
@ -69,7 +79,7 @@
:class="{'has-background': background}" :class="{'has-background': background}"
:style="{'background-image': `url(${background})`}" :style="{'background-image': `url(${background})`}"
> >
<div class="namespace-container" :class="{'is-active': mobileMenuActive}"> <div class="namespace-container" :class="{'is-active': menuActive}">
<div class="menu top-menu"> <div class="menu top-menu">
<router-link :to="{name: 'home'}" class="logo"> <router-link :to="{name: 'home'}" class="logo">
<img src="/images/logo-full.svg" alt="Vikunja"/> <img src="/images/logo-full.svg" alt="Vikunja"/>
@ -125,6 +135,7 @@
</li> </li>
</ul> </ul>
</div> </div>
<a @click="menuActive = false" class="collapse-menu-button">Collapse Menu</a>
<aside class="menu namespaces-lists"> <aside class="menu namespaces-lists">
<div class="spinner" :class="{ 'is-loading': namespaceService.loading}"></div> <div class="spinner" :class="{ 'is-loading': namespaceService.loading}"></div>
<template v-for="n in namespaces"> <template v-for="n in namespaces">
@ -193,8 +204,14 @@
</aside> </aside>
<a class="menu-bottom-link" target="_blank" href="https://vikunja.io">Powered by Vikunja</a> <a class="menu-bottom-link" target="_blank" href="https://vikunja.io">Powered by Vikunja</a>
</div> </div>
<div class="app-content" :class="{'fullpage-overlay': fullpage}"> <div
<a class="mobile-overlay" v-if="mobileMenuActive" @click="mobileMenuActive = false"></a> class="app-content"
:class="{
'fullpage-overlay': fullpage,
'is-menu-enabled': menuActive,
}"
>
<a class="mobile-overlay" v-if="menuActive" @click="menuActive = false"></a>
<transition name="fade"> <transition name="fade">
<router-view/> <router-view/>
</transition> </transition>
@ -273,7 +290,7 @@
data() { data() {
return { return {
namespaceService: NamespaceService, namespaceService: NamespaceService,
mobileMenuActive: false, menuActive: true,
currentDate: new Date(), currentDate: new Date(),
userMenuActive: false, userMenuActive: false,
authTypes: authTypes, authTypes: authTypes,
@ -339,6 +356,11 @@
) )
} }
// Hide the menu by default on mobile
if (window.innerWidth < 770) {
this.menuActive = false
}
// Try renewing the token every time vikunja is loaded initially // Try renewing the token every time vikunja is loaded initially
// (When opening the browser the focus event is not fired) // (When opening the browser the focus event is not fired)
this.$store.dispatch('auth/renewToken') this.$store.dispatch('auth/renewToken')
@ -402,9 +424,13 @@
} }
this.loadNamespacesIfNeeded(e) this.loadNamespacesIfNeeded(e)
this.mobileMenuActive = false
this.userMenuActive = false this.userMenuActive = false
// If the menu is active on desktop, don't hide it because that would confuse the user
if (window.innerWidth < 770) {
this.menuActive = false
}
// Reset the current list highlight in menu if the current list is not list related. // Reset the current list highlight in menu if the current list is not list related.
if ( if (
this.$route.name === 'home' || this.$route.name === 'home' ||

View File

@ -7,7 +7,10 @@
.app-content { .app-content {
padding: $navbar-height + 1.5rem 1.5em 0 1.5em; padding: $navbar-height + 1.5rem 1.5em 0 1.5em;
z-index: 2; z-index: 2;
margin-left: 17vw;
&.is-menu-enabled {
margin-left: 17vw;
}
@media screen and (max-width: $tablet) { @media screen and (max-width: $tablet) {
margin-left: 0; margin-left: 0;

View File

@ -14,6 +14,11 @@
box-shadow: $navbar-dropdown-boxed-shadow; box-shadow: $navbar-dropdown-boxed-shadow;
top: 101%; top: 101%;
} }
.navbar-brand {
display: flex;
align-items: center;
}
} }
.navbar.main-theme { .navbar.main-theme {
@ -113,15 +118,30 @@
overflow-x: auto; overflow-x: auto;
width: 17vw; width: 17vw;
@media screen and (max-width: $tablet) { padding: 0 0 1em;
padding: 0 0 1em; left: -147vw;
left: -147vw; bottom: 0;
top: 0;
bottom: 0;
width: 70vw;
&.is-active { @media screen and (max-width: $tablet) {
left: 0; top: 0;
width: 70vw;
}
&.is-active {
left: 0;
}
.collapse-menu-button {
font-size: .75rem;
color: $grey;
text-align: center;
display: block;
width: 100%;
margin: $navbar-padding / 2 0 $navbar-padding;
cursor: pointer;
@media screen and (max-width: $tablet) {
display: none;
} }
} }
@ -270,7 +290,7 @@
} }
.top-menu { .top-menu {
margin: $navbar-padding / 2 0 $navbar-padding; margin-top: $navbar-padding / 2;
.menu-list { .menu-list {
li { li {
@ -326,7 +346,7 @@
} }
} }
.mobilemenu-hide-button, .mobilemenu-show-button { .menu-hide-button, .menu-show-button {
display: none; display: none;
z-index: 31; z-index: 31;
font-weight: bold; font-weight: bold;
@ -339,7 +359,7 @@
} }
} }
.mobilemenu-hide-button { .menu-hide-button {
position: fixed; position: fixed;
&:hover, &:focus { &:hover, &:focus {
@ -361,13 +381,13 @@
} }
@media screen and (max-width: $tablet) { @media screen and (max-width: $tablet) {
.mobilemenu-hide-button { .menu-hide-button {
display: block; display: block;
top: $hamburger-menu-icon-spacing; top: $hamburger-menu-icon-spacing;
right: $hamburger-menu-icon-spacing; right: $hamburger-menu-icon-spacing;
} }
.mobilemenu-show-button { .menu-show-button {
display: block; display: block;
margin-left: $hamburger-menu-icon-spacing; margin-left: $hamburger-menu-icon-spacing;
} }
@ -382,6 +402,10 @@
} }
} }
.menu-show-button.is-visible {
display: block;
}
.logout-icon { .logout-icon {
margin-right: 0.85em !important; margin-right: 0.85em !important;
} }