Transitions

This commit is contained in:
Simon Cambier 2022-02-18 10:18:51 +01:00
parent dbeb7db2c3
commit 2dcfaf513f
8 changed files with 158 additions and 97 deletions

View File

@ -1,7 +1,19 @@
<script setup lang="ts"></script> <script setup lang="ts">
import AppHeader from './components/AppHeader.vue'
</script>
<template> <template>
<div class="container px-2 mx-auto h-full"> <div class="container flex overflow-hidden flex-col px-2 mx-auto h-full max-w-md">
<RouterView /> <AppHeader />
<!-- keep relative for transition -->
<div class="relative">
<RouterView v-slot="{ Component, route }">
<Transition name="route">
<Component
:is="Component"
:key="route.path" />
</Transition>
</RouterView>
</div>
</div> </div>
</template> </template>

View File

@ -1,7 +1,24 @@
<template> <template>
<h1 class="pt-2 pb-4 text-3xl font-bold text-center"> <div class="flex justify-between items-center mx-auto w-full max-w-md">
<RouterLink
:class="{ 'opacity-0': isHome }"
to="/"
class="text-xl text-stone-400 transition-opacity">
<IconHouse />
</RouterLink>
<h1 class="py-2 text-3xl text-center">
Numbers Numbers
</h1> </h1>
<IconMenu class="text-xl" />
</div>
</template> </template>
<script setup lang="ts"></script> <script setup lang="ts">
import { computed } from 'vue'
import { useRoute } from 'vue-router'
import IconHouse from '~icons/ph/house'
import IconMenu from '~icons/ph/list'
const isHome = computed(() => useRoute().name === 'home')
</script>

View File

@ -2,7 +2,7 @@
<div> <div>
<TransitionGroup name="slide_up"> <TransitionGroup name="slide_up">
<div <div
class="mb-2 text-center" class="text-center md:mb-2"
v-for="(op, i) in operations" v-for="(op, i) in operations"
:style="{ :style="{
transitionDelay: `${transDelay * (operations.length - i)}ms`, transitionDelay: `${transDelay * (operations.length - i)}ms`,
@ -21,7 +21,7 @@
<!-- OPERATOR --> <!-- OPERATOR -->
<div class="flex justify-center w-[2.5em] transition-all"> <div class="flex justify-center w-[2.5em] transition-all">
<Component <Component
class="text-lg" class="text-lg text-stone-400"
v-if="op.operator" v-if="op.operator"
:is="operatorIcons[op.operator]" /> :is="operatorIcons[op.operator]" />
<span v-else>&nbsp;</span> <span v-else>&nbsp;</span>
@ -33,7 +33,7 @@
</div> </div>
<!-- EQUALS --> <!-- EQUALS -->
<div class="mx-4 border-none"> <div class="mx-4 text-stone-400 border-none">
<IconEquals /> <IconEquals />
</div> </div>
@ -56,10 +56,10 @@
<!-- UNDO --> <!-- UNDO -->
<button <button
class="ml-8" class="ml-4"
@click="undoOperation(i)"> @click="undoOperation(i)">
<IconUndo <IconUndo
class="text-stone-400" class="text-stone-600"
:class="{ :class="{
invisible: !canOperationBeDeleted(op), invisible: !canOperationBeDeleted(op),
}" /> }" />

View File

@ -4,6 +4,7 @@
<TransitionGroup name="slide_left"> <TransitionGroup name="slide_left">
<PlaquetteBox <PlaquetteBox
v-for="(item, i) in plaquettes" v-for="(item, i) in plaquettes"
:key="i" :key="i"
is="button" is="button"
@click="click(item)" @click="click(item)"

View File

@ -1,7 +1,7 @@
<template> <template>
<Component <Component
:is="is" :is="is"
class="flex overflow-hidden justify-center font-bold rounded border-stone-600 transition-opacity" class="flex overflow-hidden justify-center rounded border-stone-600"
:class="[textSize]"> :class="[textSize]">
<span <span
class="self-center text-center" class="self-center text-center"

View File

@ -13,13 +13,13 @@
src: url('../fonts/manrope-v8-latin-regular.eot'); src: url('../fonts/manrope-v8-latin-regular.eot');
/* IE9 Compat Modes */ /* IE9 Compat Modes */
src: local(''), src: local(''),
url('../fonts/manrope-v8-latin-regular.eot?#iefix') format('embedded-opentype'), url('../fonts/manrope-v8-latin-regular.eot?#iefix')
/* IE6-IE8 */ format('embedded-opentype'),
url('../fonts/manrope-v8-latin-regular.woff2') format('woff2'), /* IE6-IE8 */ url('../fonts/manrope-v8-latin-regular.woff2') format('woff2'),
/* Super Modern Browsers */ /* Super Modern Browsers */ url('../fonts/manrope-v8-latin-regular.woff')
url('../fonts/manrope-v8-latin-regular.woff') format('woff'), format('woff'),
/* Modern Browsers */ /* Modern Browsers */ url('../fonts/manrope-v8-latin-regular.ttf')
url('../fonts/manrope-v8-latin-regular.ttf') format('truetype'), format('truetype'),
/* Safari, Android, iOS */ /* Safari, Android, iOS */
url('../fonts/manrope-v8-latin-regular.svg#Manrope') format('svg'); url('../fonts/manrope-v8-latin-regular.svg#Manrope') format('svg');
/* Legacy iOS */ /* Legacy iOS */
@ -35,17 +35,40 @@
/* IE9 Compat Modes */ /* IE9 Compat Modes */
src: local(''), src: local(''),
url('../fonts/manrope-v8-latin-700.eot?#iefix') format('embedded-opentype'), url('../fonts/manrope-v8-latin-700.eot?#iefix') format('embedded-opentype'),
/* IE6-IE8 */ /* IE6-IE8 */ url('../fonts/manrope-v8-latin-700.woff2') format('woff2'),
url('../fonts/manrope-v8-latin-700.woff2') format('woff2'), /* Super Modern Browsers */ url('../fonts/manrope-v8-latin-700.woff')
/* Super Modern Browsers */ format('woff'),
url('../fonts/manrope-v8-latin-700.woff') format('woff'), /* Modern Browsers */ url('../fonts/manrope-v8-latin-700.ttf')
/* Modern Browsers */ format('truetype'),
url('../fonts/manrope-v8-latin-700.ttf') format('truetype'), /* Safari, Android, iOS */ url('../fonts/manrope-v8-latin-700.svg#Manrope')
/* Safari, Android, iOS */ format('svg');
url('../fonts/manrope-v8-latin-700.svg#Manrope') format('svg');
/* Legacy iOS */ /* Legacy iOS */
} }
/* ROUTE TRANSITION */
.route-move,
.route-enter-active,
.route-leave-active {
transition: all .8s ease;
}
.route-enter-from {
opacity: 0;
transform: translateX(100vw);
}
.route-leave-to {
opacity: 0;
transform: translateX(-100vw);
}
.route-leave-active {
position: absolute;
}
/* SLIDE LEFT */
.slide_left-move, .slide_left-move,
.slide_left-enter-active, .slide_left-enter-active,
.slide_left-leave-active { .slide_left-leave-active {
@ -58,6 +81,12 @@
transform: translateX(30px); transform: translateX(30px);
} }
/* .slide_left-leave-active {
position: absolute;
} */
/* SLIDE UP */
.slide_up-enter-active, .slide_up-enter-active,
.slide_up-leave-active { .slide_up-leave-active {
transition: all 0.5s ease; transition: all 0.5s ease;

View File

@ -1,10 +1,9 @@
<template> <template>
<AppHeader /> <div class="w-full">
<!-- Number to find --> <!-- Number to find -->
<PlaquetteBox class="p-1 mx-auto mb-4 w-fit text-cyan-500"> <div class="p-1 mx-auto mb-4 w-fit text-cyan-500">
<span class="text-4xl">{{ result }}</span> <span class="text-4xl">{{ result ? result : '???' }}</span>
</PlaquetteBox> </div>
<!-- Start button --> <!-- Start button -->
<!-- TODO: fix animation --> <!-- TODO: fix animation -->
@ -12,11 +11,9 @@
<div <div
class="text-center" class="text-center"
v-if="gameState === GameState.Waiting"> v-if="gameState === GameState.Waiting">
<div> <div v-if="isDaily">
Combinez les nombres imposés afin de trouver le résultat ci-dessus, ou Le défi quotidien vous propose un résultat différent chaque jour,
de vous en approcher le plus possible.<br> commun à tous les joueurs.<br>
Le compteur démarre quand vous cliquez sur le bouton.<br>Partagez vos
meilleurs temps !
</div> </div>
<button <button
@ -62,6 +59,7 @@
</button> </button>
</div> </div>
</Transition> </Transition>
</div>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
@ -205,8 +203,13 @@ function reboot(): void {
*/ */
onMounted(() => { onMounted(() => {
// reboot()
// gameState.value = GameState.Waiting
result.value = 0
setTimeout(() => {
reboot() reboot()
gameState.value = GameState.Waiting gameState.value = GameState.Waiting
}, 800)
}) })
onUnmounted(() => { onUnmounted(() => {

View File

@ -1,17 +1,16 @@
<template> <template>
<div class="flex flex-col h-full text-center"> <div class="flex flex-col grow p-1 w-full text-center">
<AppHeader /> <div class="flex flex-col grow gap-16 justify-center md:mt-16">
<div> <div>
Combinez les nombres imposés afin d'atteindre le résultat, ou de vous en Combinez les nombres imposés afin d'atteindre le résultat, ou de vous en
approcher le plus possible.<br> approcher le plus possible.<br>
<br> <br>
</div> </div>
<div class="flex flex-col grow gap-16 justify-center md:flex-row md:mt-16">
<!-- Daily --> <!-- Daily -->
<div class="flex flex-col gap-4 items-center"> <div class="flex flex-col gap-4 items-center">
<RouterLink <RouterLink
to="/daily" to="/daily"
class="text-3xl btn"> class="text-2xl btn">
{{ t('dailyGame') }} {{ t('dailyGame') }}
</RouterLink> </RouterLink>
<span> <span>
@ -24,7 +23,7 @@
<div class="flex flex-col gap-4 items-center"> <div class="flex flex-col gap-4 items-center">
<RouterLink <RouterLink
to="/random" to="/random"
class="text-3xl btn"> class="text-2xl btn">
{{ t('randomGame') }} {{ t('randomGame') }}
</RouterLink> </RouterLink>
Un nombre au hasard, pour le plaisir Un nombre au hasard, pour le plaisir