Skip to content

Commit ee10249

Browse files
committed
feat(transition): adds basic route transition
1 parent fae2d7c commit ee10249

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

src/components/AppComponent.vue

+17-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<script setup lang="ts">
2+
import { Transition } from 'vue';
23
import { RouterView } from 'vue-router';
34
45
import { NavbarComponent } from '~/components/common';
@@ -14,7 +15,11 @@ const { isAuthenticated } = useSettingsStoreRefs();
1415
<NavbarComponent />
1516
</header>
1617
<main>
17-
<RouterView />
18+
<RouterView v-slot="{ Component, route }">
19+
<Transition name="scale" mode="out-in">
20+
<component :is="Component" :key="route.path" />
21+
</Transition>
22+
</RouterView>
1823
</main>
1924
</template>
2025

@@ -44,4 +49,15 @@ main {
4449
justify-content: center;
4550
padding: 0 2rem;
4651
}
52+
53+
.scale-enter-active,
54+
.scale-leave-active {
55+
transition: all 0.25s ease;
56+
}
57+
58+
.scale-enter-from,
59+
.scale-leave-to {
60+
transform: scale(0.95);
61+
opacity: 0;
62+
}
4763
</style>

src/components/common/navbar/NavbarComponent.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const routes = [Route.Progress, Route.Calendar, Route.History, Route.List, Route
1818

1919
<template>
2020
<nav>
21-
<NTabs :value="route.name" class="tabs" type="segment" justify-content="space-evenly" animated>
21+
<NTabs :value="route.name?.toString()" class="tabs" type="segment" justify-content="space-evenly" animated>
2222
<template v-for="_route in routes" :key="_route">
2323
<NTab class="tab" :name="_route.toLowerCase()" type="segment" @click="navigate(_route)">
2424
{{ i18n(_route.toLowerCase()) }}

0 commit comments

Comments
 (0)