mirror of
https://github.com/kevin-DL/build-gmail-clone-with-vue-3.git
synced 2026-01-24 07:55:34 +00:00
Abstract away Modal
This commit is contained in:
@@ -20,13 +20,16 @@
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<MailViewModal :email="openedEmail" :closeModal="() => {openedEmail = null;}"/>
|
<ModalView :isOpened="!!openedEmail" :closeModal="() => {openedEmail = null;}">
|
||||||
|
<MailView :email="openedEmail" />
|
||||||
|
</ModalView>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { format } from 'date-fns'
|
import { format } from 'date-fns'
|
||||||
import useEmailSelection from '../composition/useEmailSelection';
|
import useEmailSelection from '../composition/useEmailSelection';
|
||||||
import MailViewModal from '@/components/MailViewModal.vue';
|
import MailView from '@/components/MailView.vue';
|
||||||
|
import ModalView from '@/components/ModalView.vue';
|
||||||
import { ref } from 'vue';
|
import { ref } from 'vue';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@@ -48,7 +51,8 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
MailViewModal
|
MailView,
|
||||||
|
ModalView
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
20
src/components/MailView.vue
Normal file
20
src/components/MailView.vue
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
From: {{email.from}}<br>
|
||||||
|
Subject: <strong>{{email.subject}}</strong>
|
||||||
|
<p>{{email.body}}</p>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
props: {
|
||||||
|
email: {
|
||||||
|
type: Object
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
</style>
|
||||||
@@ -1,10 +1,8 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="modal" v-if="email">
|
<div class="modal" v-if="isOpened">
|
||||||
<div class="overlay" @click="closeModal()"></div>
|
<div class="overlay" @click="closeModal()"></div>
|
||||||
<div class="modal-card">
|
<div class="modal-card">
|
||||||
From: {{email.from}}<br>
|
<slot :closeModal="closeModal" />
|
||||||
Subject: <strong>{{email.subject}}</strong>
|
|
||||||
<p>{{email.body}}</p>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -12,8 +10,9 @@
|
|||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
email: {
|
isOpened: {
|
||||||
type: Object
|
type: Boolean,
|
||||||
|
required: true
|
||||||
},
|
},
|
||||||
closeModal: {
|
closeModal: {
|
||||||
type: Function,
|
type: Function,
|
||||||
Reference in New Issue
Block a user