Files
freeplanet/src/layouts/drawer/menuOne.vue

113 lines
3.0 KiB
Vue
Raw Normal View History

2018-10-12 16:42:54 +02:00
<template>
2018-10-13 19:14:58 +02:00
<div class="list no-border platform-delimiter light-paragraph">
<q-icon name="action"/>
<template v-for="(parent, index) in links">
<q-list>
<div class="list-label cursor-pointer" @click="parent.show = !parent.show">
{{replaceUnderlineToSpace(index)}} <div class="menu_freccina"><i aria-hidden="true" class="v-icon material-icons theme--light">keyboard_arrow_down</i></div>
2018-10-13 19:14:58 +02:00
</div>
<template v-for="child in parent.routes">
<q-slide-transition duration="200">
2018-10-13 19:14:58 +02:00
<div v-show="parent.show">
<q-item link :to="child.route" exact
class="item item-link drawer-closer cursor-pointer">
<i :class="child.faIcon" class="item-primary"></i>
<div class="item-content">{{$t(child.name)}}</div>
</q-item>
2018-10-13 19:14:58 +02:00
</div>
</q-slide-transition>
2018-10-13 19:14:58 +02:00
</template>
</q-list>
</template>
</div>
2018-10-12 16:42:54 +02:00
</template>
<script>
export default {
props: ['links'],
watch: {
2018-10-13 19:14:58 +02:00
'$route.path'() {
Object.keys(this.links).forEach(parentName => {
this.setParentVisibilityBasedOnRoute(this.links[parentName])
})
2018-10-12 16:42:54 +02:00
}
},
computed: {
2018-10-13 19:14:58 +02:00
currentRoutePath() {
2018-10-12 16:42:54 +02:00
return this.$route.path
}
},
methods: {
2018-10-13 19:14:58 +02:00
created() {
console.log("MENUONE CREATED!");
},
setParentVisibilityBasedOnRoute(parent) {
2018-10-12 16:42:54 +02:00
parent.routes.forEach(item => {
if (this.$route.path === item.route) {
parent.show = true
return
}
})
},
2018-10-13 19:14:58 +02:00
replaceUnderlineToSpace(text) {
2018-10-12 16:42:54 +02:00
while (text.indexOf('_') !== -1) {
text = text.replace('_', ' ')
}
return text
}
}
}
</script>
<style scoped>
2018-10-13 19:14:58 +02:00
.menu-hr{
border-color: #dedede;
height: 0.5px;
}
2018-10-13 19:14:58 +02:00
.router-link-active {
color: #027be3;
background-color: #dadada !important;
border-right: 2px solid #027be3;
}
.list-label:first-child {
line-height: 20px;
padding: 5px;
margin: 1px;
2018-10-13 19:14:58 +02:00
}
/*
2018-10-13 19:14:58 +02:00
.menu-enter-active, .scale-enter {
-webkit-animation: moveFromTopFade .5s ease both;
animation: moveFromTopFade .5s ease both;
2018-10-13 19:14:58 +02:00
}
.menu-leave-to, .scale-leave-active {
-webkit-animation: moveToBottom .5s ease both;
animation: moveToBottom .5s ease both;
2018-10-13 19:14:58 +02:00
}
*/
2018-10-13 19:14:58 +02:00
.router-link-active {
color: #027be3;
background-color: #dadada !important;
border-right: 2px solid #027be3;
}
.router-link-active .item-primary {
color: #027be3;
}
.menu_freccina {
position: absolute;
right: 10px;
display: inline-block;
padding: 0 0px 0px 0px;
-webkit-transform: rotate(-180deg);
transform: rotate(-180deg);
}
2018-10-12 16:42:54 +02:00
</style>