This repository has been archived on 2024-07-22. You can view files and clone it, but cannot push or open issues or pull requests.
Zaimki/components/Submenu.vue

44 lines
1.7 KiB
Vue
Raw Normal View History

2021-08-30 02:36:57 -07:00
<template>
<section class="mt-4 mt-lg-0">
<div class="d-none d-md-inline-flex btn-group btn-block mb-2 w-100">
<router-link v-for="{name, icon, route, condition} in links" :key="name"
v-if="condition === undefined || condition === true"
:to="buildRoute(route)"
:class="['btn', isActiveRoute(route) ? 'btn-primary' : 'btn-outline-primary']">
<Icon :v="icon"/>
<T>{{name}}</T>
</router-link>
</div>
<div class="d-block d-md-none btn-group-vertical btn-block mb-2 w-100">
<router-link v-for="{name, icon, route, condition} in links" :key="name"
v-if="condition === undefined || condition === true"
2021-08-30 02:36:57 -07:00
:to="buildRoute(route)"
:class="['btn', isActiveRoute(route) ? 'btn-primary' : 'btn-outline-primary']">
<Icon :v="icon"/>
<T>{{name}}</T>
</router-link>
</div>
</section>
</template>
<script>
export default {
props: {
prefix: {'default': ''},
links: {required: true},
},
methods: {
buildRoute(route) {
return `${this.prefix}/${route}`;
},
isActiveRoute(route) {
let current = decodeURIComponent(this.$route.fullPath).replace(/\/$/, '');
if (current.includes('#')) {
current = current.substring(0, current.indexOf('#'));
}
return current === this.buildRoute(route).replace(/\/$/, '');
},
},
}
</script>