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