Skip to content

Commit 5f547bd

Browse files
authored
Improve modal behavior (#1871)
* fix modal behavior * 3.22.5
1 parent 34871f8 commit 5f547bd

File tree

3 files changed

+27
-75
lines changed

3 files changed

+27
-75
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@devprotocol/clubs-core",
3-
"version": "3.22.4",
3+
"version": "3.22.5",
44
"description": "Core library for Clubs",
55
"main": "dist/index.mjs",
66
"exports": {

src/ui/components/Checkout/ModalCheckout.vue

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,9 @@ onMounted(async () => {
123123
</style>
124124

125125
<template>
126-
<div class="@container/clb_result_modal">
126+
<div
127+
class="m-auto w-full max-w-screen-lg rounded-xl bg-white p-4 text-black shadow @container/clb_result_modal"
128+
>
127129
<div
128130
class="bg-color-navy relative mb-6 flex h-auto min-h-52 w-full flex-col items-center justify-center overflow-hidden rounded-md border border-black p-2 @xl/clb_result_modal:h-96 @xl/clb_result_modal:min-h-0 @xl/clb_result_modal:p-8"
129131
>
@@ -138,12 +140,6 @@ onMounted(async () => {
138140
>
139141
</h3>
140142
<!-- image -->
141-
<img
142-
:src="image?.src"
143-
:width="image?.width"
144-
:height="image?.height"
145-
class="z-10 max-h-60 min-h-full max-w-60 object-contain @xl/clb_result_modal:max-h-none @xl/clb_result_modal:max-w-xl"
146-
/>
147143
<img
148144
v-if="!image && imageSrc"
149145
:src="imageSrc"

src/ui/components/Modal.vue

Lines changed: 23 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,26 @@
11
<script setup lang="ts">
2-
import { Component as VueComponent } from 'vue'
2+
import { useTemplateRef, Component as VueComponent, watch } from 'vue'
33
4-
defineProps<{
4+
const props = defineProps<{
55
eoa?: string
66
modalClose?: () => void
77
isVisible: boolean
88
modalContent: VueComponent
99
attrs: { [key: string]: any }
1010
}>()
11-
</script>
12-
13-
<style>
14-
.modal-container {
15-
position: fixed;
16-
top: 0;
17-
right: 0;
18-
bottom: 0;
19-
left: 0;
20-
display: flex;
21-
justify-content: center;
22-
align-items: flex-end;
23-
z-index: 10;
24-
}
25-
26-
@media (min-width: 1024px) {
27-
.modal-container {
28-
align-items: center;
29-
}
30-
}
3111
32-
.modal-overlay {
33-
position: fixed;
34-
top: 0;
35-
right: 0;
36-
bottom: 0;
37-
left: 0;
38-
background: rgba(0, 0, 0, 0.6);
39-
z-index: -1;
40-
}
41-
42-
.modal-content {
43-
display: flex;
44-
flex-direction: column;
45-
padding: 1rem;
46-
width: 100%;
47-
max-width: 64rem;
48-
background: white;
49-
border-top-left-radius: 0.5rem;
50-
border-top-right-radius: 0.5rem;
51-
border-bottom-left-radius: 0;
52-
border-bottom-right-radius: 0;
53-
box-shadow: 0 0 1rem rgba(0, 0, 0, 0.2);
54-
55-
max-height: 80vh;
56-
overflow-y: auto;
57-
}
12+
const dialog = useTemplateRef('dialog')
5813
59-
@media (min-width: 1024px) {
60-
.modal-content {
61-
border-bottom-left-radius: 0.5rem;
62-
border-bottom-right-radius: 0.5rem;
14+
watch(props, () => {
15+
if (props.isVisible) {
16+
dialog.value?.showModal()
17+
} else {
18+
dialog.value?.close()
6319
}
64-
}
20+
})
21+
</script>
6522

23+
<style>
6624
.v-enter-active {
6725
transition: transform 600ms cubic-bezier(0.07, 1.28, 0.5, 1);
6826
}
@@ -79,36 +37,34 @@ defineProps<{
7937
transform: translate(0, 0);
8038
}
8139
82-
html:has(#modal-container[data-active='true']) {
40+
html:has(dialog[open]) {
8341
overflow: hidden;
8442
}
8543
</style>
8644

8745
<template>
8846
<div>
89-
<Teleport to="body">
90-
<div
91-
id="modal-container"
92-
v-show="isVisible"
93-
class="modal-container"
94-
:data-active="isVisible"
95-
>
96-
<div class="modal-overlay"></div>
97-
<Transition>
47+
<dialog
48+
ref="dialog"
49+
class="fixed inset-0 flex items-center justify-center overflow-y-auto"
50+
:class="{ hidden: !isVisible }"
51+
>
52+
<div class="fixed inset-0 bg-black/60"></div>
53+
<Transition>
54+
<div class="relative m-auto w-full py-4">
9855
<component
9956
:eoa="eoa"
10057
:modalClose="modalClose"
10158
v-show="isVisible"
102-
class="modal-content"
10359
:is="modalContent"
10460
v-bind="attrs"
10561
>
10662
<template #after:description>
10763
<slot name="after:description" />
10864
</template>
10965
</component>
110-
</Transition>
111-
</div>
112-
</Teleport>
66+
</div>
67+
</Transition>
68+
</dialog>
11369
</div>
11470
</template>

0 commit comments

Comments
 (0)