Skip to content

Commit

Permalink
refactor(App): extract common component tree
Browse files Browse the repository at this point in the history
Signed-off-by: Fernando Fernández <[email protected]>
  • Loading branch information
ferferga committed May 8, 2024
1 parent 231ddd8 commit 3264021
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 14 deletions.
19 changes: 5 additions & 14 deletions frontend/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,17 @@
:name="route.meta.layout.transition.enter ?? defaultTransition"
:mode="defaultTransitionMode ?? route.meta.layout.transition.mode">
<Suspense @resolve="apploaded = true">
<div
<AppComp
:key="route.meta.layout.name ?? 'default'"
class="uno-h-full j-transition">
<component
:is="getLayoutComponent(route.meta.layout.name)"
:key="route.meta.layout.name ?? 'default'">
:comp="getLayoutComponent(route.meta.layout.name)">
<JTransition
:name="route.meta.layout.transition.enter ?? defaultTransition"
:mode="defaultTransitionMode ?? route.meta.layout.transition.mode">
<Suspense suspensible>
<div
:key="route.name ?? route.path"
class="uno-h-full j-transition">
<component
:is="Component"
:key="route.name ?? route.path" />
</div>
<AppComp :key="route.path" :comp="Component" />
</Suspense>
</JTransition>
</component>
</div>
</AppComp>
<template v-if="!apploaded" #fallback>
<JSplashscreen />
</template>
Expand All @@ -50,6 +40,7 @@ import type { RouteMeta } from 'vue-router/auto';
import DefaultLayout from '@/layouts/default.vue';
import FullPageLayout from '@/layouts/fullpage.vue';
import ServerLayout from '@/layouts/server.vue';
import AppComp from '@/AppComp.vue';
const apploaded = shallowRef(false);
const defaultTransition = 'slide-x-reverse';
Expand Down
17 changes: 17 additions & 0 deletions frontend/src/AppComp.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<template>
<div
class="uno-h-full j-transition">
<component
:is="comp">
<slot />
</component>
</div>
</template>

<script setup lang="ts">
import type { Component } from 'vue';
defineProps<{
comp: Component;
}>();
</script>

0 comments on commit 3264021

Please sign in to comment.