Mobile menu navigation and cosmetics

pull/12/head
cagataycivici 2018-12-26 12:36:00 +03:00
parent 269faced48
commit 5858f9cee3
4 changed files with 48 additions and 15 deletions

View File

@ -1,7 +1,8 @@
<template> <template>
<div class="layout-wrapper"> <div class="layout-wrapper">
<app-topbar /> <app-topbar @menubutton-click="onMenuButtonClick"/>
<app-menu /> <app-menu :active="sidebarActive" @menuitem-click="onMenuItemClick" />
<div :class="['layout-mask', {'layout-mask-active': sidebarActive}]" @click="onMaskClick"></div>
<div class="layout-content"> <div class="layout-content">
<router-view/> <router-view/>
<app-footer /> <app-footer />
@ -15,11 +16,27 @@ import AppMenu from '@/AppMenu.vue';
import AppFooter from '@/AppFooter.vue'; import AppFooter from '@/AppFooter.vue';
export default { export default {
data() {
return {
sidebarActive: false
}
},
methods: {
onMenuButtonClick() {
this.sidebarActive = !this.sidebarActive;
},
onMenuItemClick(event) {
this.sidebarActive = false;
},
onMaskClick(event) {
this.sidebarActive = false;
}
},
components: { components: {
'app-topbar': AppTopBar, 'app-topbar': AppTopBar,
'app-menu': AppMenu, 'app-menu': AppMenu,
'app-footer': AppFooter 'app-footer': AppFooter
} },
} }
</script> </script>

View File

@ -1,5 +1,5 @@
<template> <template>
<div class="layout-sidebar"> <div :class="['layout-sidebar', {'active': active}]" @click="onClick">
<div class="layout-menu"> <div class="layout-menu">
<a @click="toggleMenu($event, 0)" :class="{'active-menuitem': activeMenuIndex === 0}"> <a @click="toggleMenu($event, 0)" :class="{'active-menuitem': activeMenuIndex === 0}">
<img alt="input" class="layout-menu-icon-inactive" src="./assets/images/menu/input.svg" /> <img alt="input" class="layout-menu-icon-inactive" src="./assets/images/menu/input.svg" />
@ -146,6 +146,9 @@
<script> <script>
export default { export default {
props: {
active: false
},
data() { data() {
return { return {
activeMenuIndex: null activeMenuIndex: null
@ -154,6 +157,11 @@ export default {
methods: { methods: {
toggleMenu(event, index) { toggleMenu(event, index) {
this.activeMenuIndex = (this.activeMenuIndex === index) ? null : index; this.activeMenuIndex = (this.activeMenuIndex === index) ? null : index;
},
onClick(event) {
if (event.target.nodeName === 'A') {
this.$emit('menuitem-click');
}
} }
} }
} }

View File

@ -1,6 +1,8 @@
<template> <template>
<div class="layout-topbar"> <div class="layout-topbar">
<a class="menu-button"><i class="pi pi-bars"></i></a> <a class="menu-button" @click="$emit('menubutton-click')">
<i class="pi pi-bars"></i>
</a>
<router-link to="/" class="logo"> <router-link to="/" class="logo">
<img alt="logo" src="./assets/images/primevue-logo.png"> <img alt="logo" src="./assets/images/primevue-logo.png">
</router-link> </router-link>

View File

@ -62,7 +62,7 @@ body {
top: 0; top: 0;
left: 0; left: 0;
width: 100%; width: 100%;
z-index: 999; z-index: 997;
@include shadow(0 0 4px rgba(0,0,0,0.25)); @include shadow(0 0 4px rgba(0,0,0,0.25));
.menu-button { .menu-button {
@ -72,15 +72,15 @@ body {
position: absolute; position: absolute;
left: 0; left: 0;
top: 0; top: 0;
width: 60px; width: 70px;
height: 60px; height: 70px;
line-height: 60px; line-height: 70px;
text-align: center; text-align: center;
cursor: pointer; cursor: pointer;
@include transition(background-color .2s); @include transition(background-color .2s);
&:hover { &:hover {
background-color: #363c3f; background-color: #eeeeee;
} }
i { i {
@ -117,7 +117,7 @@ body {
text-align: center; text-align: center;
padding-bottom: 8px; padding-bottom: 8px;
border-bottom: 4px solid transparent; border-bottom: 4px solid transparent;
@include transition(border-bottom-color .2s); @include transition(background-color .2s);
&:hover { &:hover {
border-bottom-color: #41b883; border-bottom-color: #41b883;
@ -240,6 +240,7 @@ body {
color: #484848; color: #484848;
cursor: pointer; cursor: pointer;
user-select: none; user-select: none;
transition: background-color .2s;
&:hover { &:hover {
background-color: #eeeeee; background-color: #eeeeee;
@ -368,14 +369,19 @@ body {
} }
.layout-mask { .layout-mask {
opacity: .1;
}
.layout-mask-active {
z-index: 998; z-index: 998;
width: 100%; width: 100%;
height: 100%; height: 100%;
position: fixed; position: fixed;
top: 98px; top: 70px;
left: 0; left: 0;
background-color: #4c5254; background-color: #4c5254;
opacity: .7; opacity: .7;
@include transition(opacity .5s);
} }
.layout-content { .layout-content {
@ -958,10 +964,10 @@ body {
.layout-sidebar { .layout-sidebar {
top: 98px; top: 70px;
left: -300px; left: -300px;
@include transition(left .2s);
z-index: 999; z-index: 999;
@include transition(left .2s);
&.active { &.active {
left: 0; left: 0;
@ -980,7 +986,7 @@ body {
} }
.home{ .home {
.introduction > div { .introduction > div {
width: 100%; width: 100%;
} }