render modals into the “modal” portal

This commit is contained in:
taehoon 2019-10-18 11:53:38 -04:00
parent d502baaffc
commit a41ffea146
5 changed files with 36 additions and 20 deletions

View file

@ -120,7 +120,7 @@
<MobilePostStatusButton /> <MobilePostStatusButton />
<UserReportingModal /> <UserReportingModal />
<PostStatusModal /> <PostStatusModal />
<portal-target name="modal" /> <portal-target name="modal" multiple />
</div> </div>
</template> </template>

View file

@ -1,7 +1,7 @@
<template> <template>
<Modal <Modal
v-if="showing" v-if="showing"
class="media-modal-view" view-class="media-modal-view"
@close="hide" @close="hide"
> >
<img <img

View file

@ -0,0 +1,20 @@
import Vue from 'vue'
const Modal = {
props: {
viewClass: {
type: String
},
isOpen: {
type: Boolean,
default: true
}
},
methods: {
closeModal () {
this.$emit('close')
}
}
}
export default Modal

View file

@ -1,22 +1,18 @@
<template> <template>
<div <portal to="modal">
v-body-scroll-lock="true" <div
class="modal-view" ref="view"
@click.self="closeModal" v-body-scroll-lock="isOpen"
> v-show="isOpen"
<slot /> :class="['modal-view', viewClass]"
</div> @click.self="closeModal"
>
<slot />
</div>
</portal>
</template> </template>
<script> <script src="./modal.js"></script>
export default {
methods: {
closeModal () {
this.$emit('close')
}
}
}
</script>
<style lang="scss"> <style lang="scss">
.modal-view { .modal-view {

View file

@ -1,8 +1,8 @@
<template> <template>
<Modal <Modal
v-if="isLoggedIn && !resettingForm" v-if="isLoggedIn && !resettingForm"
v-show="modalActivated" :is-open="modalActivated"
class="post-form-modal-view" view-class="post-form-modal-view"
@close="closeModal" @close="closeModal"
> >
<div class="post-form-modal-panel panel"> <div class="post-form-modal-panel panel">