Created
May 23, 2019 19:25
-
-
Save nathanbarrett/780246622afbeace355ddaec92744847 to your computer and use it in GitHub Desktop.
A Simple Vue JS Modal
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
<template> | |
<div class="modal" :class="{show: show}"> | |
<div class="modal-box"> | |
<slot></slot> | |
</div> | |
</div> | |
</template> | |
<script lang="ts"> | |
import Vue from "vue"; | |
export default Vue.extend({ | |
props: { | |
show: { | |
type: Boolean, | |
required: true | |
} | |
} | |
}); | |
</script> | |
<style lang="scss" scoped> | |
// Breakpoints | |
$sm: 576px; | |
$md: 768px; | |
$lg: 992px; | |
$xl: 1200px; | |
$xxl: 1920px; | |
@mixin media($point) { | |
@media screen and (min-width: $point) { @content; } | |
} | |
.modal { | |
background-color: rgba(0, 0, 0, 0.5); | |
position: fixed; | |
left: 0; | |
top: 0; | |
z-index: 1000; | |
overflow: auto; | |
display: none; | |
&.show { | |
display: flex; | |
justify-content: center; | |
align-items: center; | |
} | |
&.show > .modal-box { | |
margin-top: 0; | |
opacity: 1; | |
} | |
} | |
.modal-box { | |
background-color: #FFFFFF; | |
border-radius: 3px; | |
z-index: 1001; | |
margin-top: 200px; | |
opacity: 0; | |
transition: all 500ms ease-out; | |
width: 95%; | |
padding: 10px; | |
@include media($md) { | |
width: 70%; | |
padding: 25px; | |
} | |
@include media($lg) { | |
width: 50%; | |
} | |
} | |
</style> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment