| 1 |
<script lang="ts" setup> |
| 2 |
import Icon from "@/components/Icon/Icon.vue"; |
| 3 |
import { computed, defineAsyncComponent } from "vue"; |
| 4 |
import { useModal } from "@/composables"; |
| 5 |
import { useModalStore } from "@/stores"; |
| 6 |
|
| 7 |
const { closeModal } = useModal(); |
| 8 |
const modalStore = useModalStore(); |
| 9 |
const activeModal = computed(() => modalStore.activeModal); |
| 10 |
|
| 11 |
const modalComponent = computed( |
| 12 |
() => |
| 13 |
activeModal.value && |
| 14 |
defineAsyncComponent( |
| 15 |
() => import(`@/components/Modals/${activeModal.value?.name}.vue`) |
| 16 |
) |
| 17 |
); |
| 18 |
</script> |
| 19 |
|
| 20 |
<template> |
| 21 |
<Transition name="fade"> |
| 22 |
<div v-if="activeModal" class="modal__wrapper"> |
| 23 |
<div |
| 24 |
class="modal__container" |
| 25 |
:class="{ |
| 26 |
'modal__container--xxl': activeModal.settings?.isXXL, |
| 27 |
'modal__container--xl': activeModal.settings?.isXL, |
| 28 |
'modal__container--lg': activeModal.settings?.isLG, |
| 29 |
}" |
| 30 |
> |
| 31 |
<Icon |
| 32 |
v-if="activeModal.settings?.hasCloseButton" |
| 33 |
name="icon-close" |
| 34 |
class="modal__icon" |
| 35 |
color="gray" |
| 36 |
@click="closeModal" |
| 37 |
/> |
| 38 |
<div |
| 39 |
class="modal__content" |
| 40 |
:class="{ |
| 41 |
'modal__content--no-content-padding': |
| 42 |
activeModal.settings?.noContentPadding, |
| 43 |
'modal__content--no-border': activeModal.settings?.noBorder, |
| 44 |
}" |
| 45 |
> |
| 46 |
<component :is="modalComponent" v-bind="activeModal.data" /> |
| 47 |
</div> |
| 48 |
</div> |
| 49 |
</div> |
| 50 |
</Transition> |
| 51 |
</template> |
| 52 |
|
| 53 |
<style lang="scss" scoped> |
| 54 |
.modal { |
| 55 |
&__wrapper { |
| 56 |
--modal-backdrop: rgba(0, 0, 0, 0.3); |
| 57 |
|
| 58 |
overflow: auto; |
| 59 |
position: fixed; |
| 60 |
z-index: var(--z-index-modal); |
| 61 |
height: 100%; |
| 62 |
top: 0; |
| 63 |
left: 0; |
| 64 |
bottom: 0; |
| 65 |
right: 0; |
| 66 |
background-color: var(--modal-backdrop); |
| 67 |
display: flex; |
| 68 |
align-items: center; |
| 69 |
justify-content: center; |
| 70 |
|
| 71 |
&.is-above-intercom { |
| 72 |
z-index: var(--z-index-intercom-2); |
| 73 |
} |
| 74 |
} |
| 75 |
|
| 76 |
&__icon { |
| 77 |
position: absolute; |
| 78 |
top: 16px; |
| 79 |
right: 16px; |
| 80 |
cursor: pointer; |
| 81 |
} |
| 82 |
|
| 83 |
&__container { |
| 84 |
position: relative; |
| 85 |
max-height: calc(100vh - 6rem); |
| 86 |
width: 100%; |
| 87 |
max-width: 500px; |
| 88 |
|
| 89 |
&--auto-width { |
| 90 |
max-width: none !important; |
| 91 |
width: auto; |
| 92 |
} |
| 93 |
|
| 94 |
&--lg { |
| 95 |
max-width: 600px; |
| 96 |
} |
| 97 |
|
| 98 |
&--xl { |
| 99 |
max-width: 800px; |
| 100 |
} |
| 101 |
|
| 102 |
&--xxl { |
| 103 |
max-width: 964px; |
| 104 |
} |
| 105 |
} |
| 106 |
|
| 107 |
&__content { |
| 108 |
border: 1px solid var(--gray-border); |
| 109 |
border-radius: 16px; |
| 110 |
background-color: var(--light); |
| 111 |
|
| 112 |
padding: 32px 40px 40px; |
| 113 |
@media screen and (max-width: 600px) { |
| 114 |
padding: 32px 40px 40px; |
| 115 |
} |
| 116 |
|
| 117 |
&--no-content-padding { |
| 118 |
padding: 0; |
| 119 |
} |
| 120 |
|
| 121 |
&--no-border { |
| 122 |
border: none; |
| 123 |
} |
| 124 |
} |
| 125 |
} |
| 126 |
</style> |
| 127 |
|