Created
July 25, 2022 21:26
-
-
Save JeffreyWay/bd5a37a9b5ae5eac5e768f0554cf87b2 to your computer and use it in GitHub Desktop.
Learn Vue 3: Step By Step, Episode 29 - Two Ways to Transition
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script setup> | |
defineProps({ | |
show: Boolean | |
}); | |
</script> | |
<template> | |
<Transition | |
enter-from-class="opacity-0 scale-125" | |
enter-to-class="opacity-100 scale-100" | |
enter-active-class="transition duration-300" | |
leave-active-class="transition duration-200" | |
leave-from-class="opacity-100 scale-100" | |
leave-to-class="opacity-0 scale-125" | |
> | |
<div v-if="show" class="modal-mask"> | |
<div class="modal-container"> | |
<div> | |
<slot>default body</slot> | |
</div> | |
<footer class="modal-footer"> | |
<slot name="footer"> | |
<button @click="$emit('close')">Close</button> | |
</slot> | |
</footer> | |
</div> | |
</div> | |
</Transition> | |
</template> | |
<style> | |
.modal-mask { | |
position: fixed; | |
inset: 0; | |
background: rgba(0, 0, 0, .6); | |
display: grid; | |
place-items: center; | |
} | |
.modal-container { | |
background: white; | |
padding: 1rem; | |
width: 80vw; | |
max-width: 500px; | |
border-radius: 7px; | |
} | |
.modal-footer { | |
border-top: 1px solid #ddd; | |
margin-top: 1rem; | |
padding-top: 0.5rem; | |
font-size: .8rem; | |
} | |
.modal-footer button { | |
background: #ddd; | |
padding: .25rem .75rem; | |
border-radius: 20px; | |
} | |
.modal-footer button:hover { | |
background: #c8c8c8; | |
} | |
</style> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment