Add StyledLink
This commit is contained in:
parent
6d7cd2573d
commit
46c2a4eceb
16
vue/src/components/StyledLink.vue
Normal file
16
vue/src/components/StyledLink.vue
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<template>
|
||||||
|
<router-link :to="to" :class="{ selected }">
|
||||||
|
<slot></slot>
|
||||||
|
</router-link>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
|
||||||
|
import { computed, defineProps } from 'vue'
|
||||||
|
import { useRoute } from 'vue-router'
|
||||||
|
|
||||||
|
const route = useRoute()
|
||||||
|
const props = defineProps(['to'])
|
||||||
|
const selected = computed(() => props.to !== '/' ? route.path.startsWith(props.to) : route.path === props.to, [route.path])
|
||||||
|
|
||||||
|
</script>
|
@ -24,7 +24,7 @@ const routes = [
|
|||||||
path: '/user',
|
path: '/user',
|
||||||
component: UserView,
|
component: UserView,
|
||||||
children: [
|
children: [
|
||||||
{ path: '', name: 'user', component: UserHome },
|
{ path: 'settings', name: 'user', component: UserHome },
|
||||||
{ path: 'invoices', name: 'invoices', component: UserInvoices }
|
{ path: 'invoices', name: 'invoices', component: UserInvoices }
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
@ -11,8 +11,8 @@
|
|||||||
<!-- eslint-enable -->
|
<!-- eslint-enable -->
|
||||||
<header class="flex flex-row text-center justify-center pt-1">
|
<header class="flex flex-row text-center justify-center pt-1">
|
||||||
<nav>
|
<nav>
|
||||||
<router-link to="/user">settings</router-link>
|
<StyledLink to="/user/settings">settings</StyledLink>
|
||||||
<router-link to="/user/invoices">invoices</router-link>
|
<StyledLink to="/user/invoices">invoices</StyledLink>
|
||||||
</nav>
|
</nav>
|
||||||
</header>
|
</header>
|
||||||
<Suspense>
|
<Suspense>
|
||||||
@ -20,6 +20,10 @@
|
|||||||
</Suspense>
|
</Suspense>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import StyledLink from '@/components/StyledLink'
|
||||||
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
nav {
|
nav {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user