Skip to content

Commit

Permalink
Add layout transitions
Browse files Browse the repository at this point in the history
  • Loading branch information
Dobefu committed May 18, 2024
1 parent 7a0d6aa commit c5dec52
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 17 deletions.
7 changes: 0 additions & 7 deletions frontend/base/app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,6 @@ useSeoMeta({

<NuxtPage
:transition="{
enterFromClass: 'opacity-0',
enterToClass: 'opacity-100',
leaveFromClass: 'opacity-100',
leaveToClass: 'opacity-0',
enterActiveClass: 'transition-opacity',
leaveActiveClass: 'transition-opacity',
mode: 'out-in',
onBeforeEnter,
}"
/>
Expand Down
15 changes: 15 additions & 0 deletions frontend/base/assets/css/tailwind.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,18 @@
#app {
@apply flex flex-col flex-1;
}

.fade-enter-active,
.fade-leave-active {
@apply transition-opacity;
}

.fade-enter-from,
.fade-leave-to {
@apply opacity-0;
}

.fade-enter-to,
.fade-leave-from {
@apply opacity-100;
}
18 changes: 17 additions & 1 deletion frontend/base/loading/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,19 @@ body::before {
}

.logo {
animation: pulse-shadow 1s infinite alternate;
filter: drop-shadow(2px 2px 0.2rem rgba(0, 0, 0, 0.5));
max-width: 16rem;
}

.throbber {
animation: spin 1s infinite;
animation: spin 1s infinite linear;
border: 0.25rem solid transparent;
border-top-color: #000;
border-radius: 50%;
flex-shrink: 0;
height: 2.5rem;
top: 0;
transform-origin: center;
width: 2.5rem;
}
Expand All @@ -38,6 +41,12 @@ body::before {
}
}

@keyframes pulse-shadow {
to {
filter: drop-shadow(2px 2px 1rem rgba(0, 0, 0, 0.5));
}
}

@media (prefers-color-scheme: dark) {
body {
background-color: #1c1917;
Expand All @@ -49,6 +58,13 @@ body::before {

.throbber {
border-top-color: #fff;
filter: drop-shadow(2px 2px 0.1rem rgba(128, 128, 128, 0.5));
}

@keyframes pulse-shadow {
to {
filter: drop-shadow(2px 2px 1rem rgba(128, 128, 128, 0.5));
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion frontend/base/loading/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export default (data: Data) => {
<div class="flex flex-col h-full items-center justify-center">
<a
href="https://github.com/Dobefu/nuxtify"
href="https://github.com/Nuxtify-drupal/Nuxtify"
target="_blank"
rel="noopener"
>
Expand Down
8 changes: 8 additions & 0 deletions frontend/base/nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@ export default defineNuxtConfig({

app: {
rootId: 'app',
pageTransition: {
name: 'fade',
mode: 'out-in',
},
layoutTransition: {
name: 'fade',
mode: 'out-in',
},
},

site: {
Expand Down
16 changes: 9 additions & 7 deletions frontend/base/pages/[...slug].vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const { locale } = useI18n()
const slug = Array.isArray(route.params.slug) ? route.params.slug.join('/') : ''
const path = ref<string>(slug)
const { data } = await useLazyAsyncData(
const { data } = await useAsyncData(
'route',
async () => await useGraphqlQuery(
'route',
Expand All @@ -26,7 +26,7 @@ const { data } = await useLazyAsyncData(
)
if (data.value?.data?.route === null)
showError({ statusCode: 404, statusMessage: 'Not Found' })
throw createError({ statusCode: 404, statusMessage: 'Not Found', fatal: true })
const page = ref<NodeUnion | undefined>(undefined)
Expand Down Expand Up @@ -66,7 +66,7 @@ const i18nRoutes = computed(() => {
}
// Remove the slug for the home page
if (`/${routes.en.slug}` === data.value?.data.info.home) {
if (`/${routes.en?.slug}` === data.value?.data.info.home) {
for (const [langcode] of Object.entries(routes))
routes[langcode].slug = ''
}
Expand Down Expand Up @@ -111,8 +111,10 @@ useHead({
</script>

<template>
<BasePageLayout
v-if="page"
:page="page"
/>
<div>
<BasePageLayout
v-if="page"
:page="page"
/>
</div>
</template>
2 changes: 1 addition & 1 deletion frontend/base/pages/preview/[...slug].vue
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ else {
}
if (data.value === null)
showError({ statusCode: 404, statusMessage: 'Not Found' })
throw createError({ statusCode: 404, statusMessage: 'Not Found', fatal: true })
const page = ref<NodeUnion | undefined>(undefined)
Expand Down
15 changes: 15 additions & 0 deletions frontend/themes/default/assets/css/tailwind.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,18 @@ body {
#app {
@apply flex flex-col flex-1;
}

.fade-enter-active,
.fade-leave-active {
@apply transition-opacity;
}

.fade-enter-from,
.fade-leave-to {
@apply opacity-0;
}

.fade-enter-to,
.fade-leave-from {
@apply opacity-100;
}

0 comments on commit c5dec52

Please sign in to comment.