miracle/components/NavItem.vue

43 lines
931 B
Vue
Raw Normal View History

2020-01-30 06:11:24 +00:00
<template>
<div :class="getCurrentClasses()">
<a :href="link" v-if="external">
<i class="material-icons md-24">{{ icon }}</i>
<p class="header-link">{{ text }}</p>
</a>
<nuxt-link :to="link" v-else>
<i class="material-icons md-24">{{ icon }}</i>
2020-02-01 20:26:13 +00:00
<p>{{ text }}</p>
2020-01-30 06:11:24 +00:00
</nuxt-link>
</div>
</template>
<script>
export default {
props: [ 'link', 'text','external', 'icon' ],
methods: {
getCurrentClasses() {
2020-02-01 20:26:13 +00:00
if(this.$nuxt.$route.path.startsWith(this.link)) {
2020-06-23 21:37:09 +00:00
return ['nav-item','selected'];
2020-01-30 06:11:24 +00:00
}
2020-06-23 21:37:09 +00:00
return ['nav-item'];
2020-01-30 06:11:24 +00:00
}
},
}
</script>
<style>
2020-06-23 21:37:09 +00:00
.nav-item {
@apply text-white h-12 flex flex-row items-center transition duration-300 ease-in-out;
2020-01-30 06:11:24 +00:00
}
2020-06-23 21:37:09 +00:00
.nav-item:hover {
@apply bg-yuika-blue-500
2020-01-30 06:11:24 +00:00
}
2020-06-23 21:37:09 +00:00
.nav-item a {
@apply flex flex-row items-center h-full w-full;
2020-01-30 06:11:24 +00:00
}
2020-06-23 21:37:09 +00:00
.nav-item a i {
@apply px-4;
}
.nav-item a p {
@apply inline-block flex-grow;
2020-01-30 06:11:24 +00:00
}
</style>