Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Mobile Navbar Click Outside #598

Merged
merged 3 commits into from
Nov 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/Course/CourseBaseTooltip.vue
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export default defineComponent({
border-width: 0.313rem;
border-style: solid;
border-color: transparent transparent white transparent;
z-index: 3;
z-index: 4;
}

/** The element that produces a gray triangle */
Expand Down
2 changes: 1 addition & 1 deletion src/components/Modals/TeleportModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export default defineComponent({
width: 100vw;
min-height: 100vh;
background-color: rgba(0, 0, 0, 0.7);
z-index: 3;
z-index: 4;
padding: 1rem;

&-simple {
Expand Down
141 changes: 77 additions & 64 deletions src/components/NavBar.vue
Original file line number Diff line number Diff line change
@@ -1,62 +1,65 @@
<template>
<nav class="navbar">
<div
class="navbar-iconWrapper hamburger full-opacity-on-hover"
data-cyId="navbar-menuButton"
@click="menuOpen = !menuOpen"
></div>
<div class="navbar-top">
<div class="navbar-iconWrapper course-plan-logo no-hover">
<img class="navbar-icon" src="@/assets/images/branding/logo.svg" alt="Courseplan logo" />
<div>
<nav class="navbar" v-click-outside="closeMenuIfOpen">
<div
class="navbar-iconWrapper hamburger full-opacity-on-hover"
data-cyId="navbar-menuButton"
@click="menuOpen = !menuOpen"
></div>
<div class="navbar-top">
<div class="navbar-iconWrapper course-plan-logo no-hover">
<img class="navbar-icon" src="@/assets/images/branding/logo.svg" alt="Courseplan logo" />
</div>
<button
class="navbar-iconWrapper desktop profile-icon full-opacity-on-hover"
@click="editProfile"
data-cyId="editProfile"
></button>
</div>
<button
class="navbar-iconWrapper desktop profile-icon full-opacity-on-hover"
@click="editProfile"
data-cyId="editProfile"
></button>
</div>
<div class="navbar-bottom">
<button
class="navbar-iconWrapper desktop logout-icon full-opacity-on-hover"
@click="logout"
/>
</div>
<div v-if="menuOpen" class="navbar-menu-background-shadow" @click="editProfile" />
<div v-if="menuOpen" class="navbar-menu" data-cyId="navbar-menu">
<button
class="nav-mobile-button"
data-cyId="navbar-viewRequirements"
@click="toggleRequirementsMobile"
>
<div class="navbar-iconWrapper requirements-bar" />
<span class="nav-mobile-button-text">
{{ isDisplayingRequirementsMobile ? 'View Schedule' : 'View Requirements' }}
</span>
</button>
<button class="nav-mobile-button" data-cyId="navbar-editProfile" @click="editProfile">
<div class="navbar-iconWrapper profile-mobile-icon" />
<span class="nav-mobile-button-text">Edit Profile</span>
</button>
<button class="nav-mobile-button" @click="logout">
<div class="navbar-iconWrapper logout-mobile-icon" />
<span class="nav-mobile-button-text">Log Out</span>
</button>
<div class="nav-menu-spacing" />
<a
class="nav-menu-dti-link"
href="https://www.cornelldti.org/projects/courseplan/"
target="_black"
rel="noopener noreferrer"
>Cornell DTI @ 2021</a
>
</div>
</nav>
<div class="navbar-bottom">
<button
class="navbar-iconWrapper desktop logout-icon full-opacity-on-hover"
@click="logout"
/>
</div>
<div v-if="menuOpen" class="navbar-menu" data-cyId="navbar-menu">
<button
class="nav-mobile-button"
data-cyId="navbar-viewRequirements"
@click="toggleRequirementsMobile"
>
<div class="navbar-iconWrapper requirements-bar" />
<span class="nav-mobile-button-text">
{{ isDisplayingRequirementsMobile ? 'View Schedule' : 'View Requirements' }}
</span>
</button>
<button class="nav-mobile-button" data-cyId="navbar-editProfile" @click="editProfile">
<div class="navbar-iconWrapper profile-mobile-icon" />
<span class="nav-mobile-button-text">Edit Profile</span>
</button>
<button class="nav-mobile-button" @click="logout">
<div class="navbar-iconWrapper logout-mobile-icon" />
<span class="nav-mobile-button-text">Log Out</span>
</button>
<div class="nav-menu-spacing" />
<a
class="nav-menu-dti-link"
href="https://www.cornelldti.org/projects/courseplan/"
target="_black"
rel="noopener noreferrer"
>Cornell DTI @ 2021</a
>
</div>
</nav>
<div v-if="menuOpen" class="navbar-menu-background-shadow" />
</div>
</template>

<script lang="ts">
import { defineComponent } from 'vue';
import firebase from 'firebase/app';
import { GTagEvent } from '@/gtag';
import { clickOutside } from '@/utilities';

export default defineComponent({
props: {
Expand Down Expand Up @@ -84,6 +87,12 @@ export default defineComponent({
this.menuOpen = false;
this.$emit('toggleRequirementsMobile');
},
closeMenuIfOpen() {
this.menuOpen = false;
},
},
directives: {
'click-outside': clickOutside,
},
});
</script>
Expand Down Expand Up @@ -156,17 +165,6 @@ $mobile-navbar-height: 4.5rem;
}
}

.navbar-menu-background-shadow {
display: none;
position: fixed;
z-index: 2;
left: 0;
right: 0;
top: $mobile-navbar-height;
bottom: 0;
background: rgba(0, 0, 0, 0.5);
}

.navbar-menu {
position: fixed;
z-index: 3;
Expand Down Expand Up @@ -206,6 +204,17 @@ $mobile-navbar-height: 4.5rem;
cursor: default;
}

.navbar-menu-background-shadow {
display: none;
position: fixed;
z-index: 2;
left: 0;
right: 0;
top: $mobile-navbar-height;
bottom: 0;
background: rgba(0, 0, 0, 0.5);
}

@media only screen and (max-width: $medium-breakpoint) {
.navbar {
width: 100%;
Expand All @@ -216,6 +225,7 @@ $mobile-navbar-height: 4.5rem;
display: flex;
position: fixed;
flex-direction: row;
z-index: 3;

.nav-mobile-button {
border: 0;
Expand Down Expand Up @@ -256,8 +266,7 @@ $mobile-navbar-height: 4.5rem;
}

.hamburger,
.requirements-bar,
.navbar-menu-background-shadow {
.requirements-bar {
display: block;
}

Expand All @@ -267,6 +276,10 @@ $mobile-navbar-height: 4.5rem;
}
}

.navbar-menu-background-shadow {
display: block;
}

.desktop {
display: none;
}
Expand Down
2 changes: 1 addition & 1 deletion src/containers/Dashboard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ export default defineComponent({
/* The Modal (background) */
&-onboarding {
position: fixed; /* Stay in place */
z-index: 3; /* Sit on top */
z-index: 4; /* Sit on top */
left: 0;
top: 0;
width: 100%; /* Full width */
Expand Down