WorkshopTasker/components/navigation/navigation.vue

42 lines
1.4 KiB
Vue
Raw Permalink Normal View History

2023-05-11 06:03:22 +02:00
<script setup>
import { useDisplay, useTheme } from "vuetify/lib/framework.mjs";
import { ref, watch } from "vue";
import { navigateTo, useRouter } from "#app";
const route = useRouter().currentRoute;
2023-05-11 06:03:22 +02:00
const { mobile } = useDisplay();
const navOpen = ref(!mobile.value);
const navSelected = ref([route.value.path]);
watch(route, (v) => {
navSelected.value = [v.path];
});
const theme = useTheme();
function switchTheme() {
theme.global.name.value = theme.global.current.value.dark ? 'light' : 'dark';
}
2023-05-11 06:03:22 +02:00
</script>
<template>
<VAppBar v-if="mobile" order="5">
<VAppBarNavIcon @click.end="navOpen = !navOpen" />
<VToolbarTitle>Database Project</VToolbarTitle>
</VAppBar>
<VNavigationDrawer v-model="navOpen" :temporary="mobile">
<VList v-model:selected="navSelected" density="compact" nav>
2023-05-24 09:40:45 +02:00
<VListItem prepend-icon="mdi-account" title="Clients" value="/clients" @click="navigateTo('/clients')" />
<VListItem prepend-icon="mdi-receipt-text" title="Orders" value="/orders" @click="navigateTo('/orders')" />
2023-05-24 09:40:45 +02:00
<VDivider />
2023-05-11 06:03:22 +02:00
</VList>
<template #append>
<VList v-model:selected="navSelected" density="compact" nav>
<VDivider />
<VListItem prepend-icon="mdi-theme-light-dark" title="Switch theme" class="mx-auto" @click="switchTheme()" />
<VListItem prepend-icon="mdi-login" title="My account" value="/login" @click="navigateTo('/login')" />
</VList>
</template>
2023-05-11 06:03:22 +02:00
</VNavigationDrawer>
</template>