Skip to content

Commit b918009

Browse files
Feat/swipe to close (#318)
* feat: support swipeToClose to VueFinalModal, delete ModalFullscreen and ModalBottom * docs: update * docs: update docs * chore: add warning for useModal() * docs: update docs * chore: warning only in dev mode
1 parent f9cc023 commit b918009

File tree

65 files changed

+1062
-1211
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+1062
-1211
lines changed

docs/components/content/BottomSheet.vue

Lines changed: 0 additions & 19 deletions
This file was deleted.

docs/components/content/BottomSheetPreview.vue

Lines changed: 0 additions & 16 deletions
This file was deleted.

docs/components/content/ConfirmModalPreview.vue

Lines changed: 0 additions & 21 deletions
This file was deleted.

docs/components/content/DragResizeModalPreview.vue

Lines changed: 0 additions & 16 deletions
This file was deleted.

docs/components/content/Fullscreen.vue

Lines changed: 0 additions & 21 deletions
This file was deleted.

docs/components/content/FullscreenPreview.vue

Lines changed: 0 additions & 16 deletions
This file was deleted.

docs/components/content/LoginFormModal.vue

Lines changed: 0 additions & 23 deletions
This file was deleted.

docs/components/content/LoginFormVorms.vue

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ const { value: remember, attrs: rememberAttrs } = register('remember')
3333
</script>
3434

3535
<template>
36+
<h1 class="text-2xl mb-4">Login</h1>
3637
<form @submit="handleSubmit">
3738
<div class="field">
3839
<input
@@ -74,11 +75,6 @@ const { value: remember, attrs: rememberAttrs } = register('remember')
7475
</template>
7576

7677
<style>
77-
form {
78-
background: #344951;
79-
color: rgb(63, 63, 70, var(--tw-text-opacity));
80-
}
81-
8278
.field + .field {
8379
margin-top: 15px;
8480
}
@@ -89,7 +85,7 @@ input[type='submit'] {
8985
width: 100%;
9086
border-radius: 4px;
9187
border: 1px solid white;
92-
padding: 12px 16px;
88+
padding: 4px 16px 4px 4px;
9389
}
9490
9591
.field__error {
@@ -100,7 +96,6 @@ input[type='submit'] {
10096
.checkbox {
10197
display: flex;
10298
align-items: center;
103-
color: white;
10499
}
105100
106101
.field__checkbox {
@@ -114,7 +109,6 @@ input[type='submit'] {
114109
input[type='submit'] {
115110
background: #41b883;
116111
border: 1px solid #41b883;
117-
color: #344951;
118112
cursor: pointer;
119113
}
120114
</style>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<script setup lang="ts">
2+
import { VueFinalModal } from 'vue-final-modal'
3+
4+
defineProps<{
5+
title?: string
6+
}>()
7+
</script>
8+
9+
<template>
10+
<VueFinalModal
11+
content-class="absolute bottom-0 w-full p-4 bg-white dark:bg-gray-900 space-y-2"
12+
swipe-to-close="down"
13+
content-transition="vfm-slide-down"
14+
overlay-transition="vfm-fade"
15+
>
16+
<h1 class="text-xl">
17+
{{ title }}
18+
</h1>
19+
<div class="text-3xl">Swipe down to close the modal</div>
20+
<slot />
21+
</VueFinalModal>
22+
</template>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<script setup lang="ts">
2+
import { ModalsContainer, useModal } from 'vue-final-modal'
3+
import ModalBottom from './ModalBottom.vue'
4+
const { open, close } = useModal({
5+
component: ModalBottom,
6+
attrs: {
7+
title: 'Hello World!',
8+
onClose() {
9+
close()
10+
},
11+
},
12+
slots: {
13+
default: '<p>ModalBottom: The content of the modal</p>',
14+
},
15+
})
16+
</script>
17+
18+
<template>
19+
<VButton @click="() => open()">
20+
Open Modal
21+
</VButton>
22+
23+
<ModalsContainer />
24+
</template>

docs/components/content/ConfirmModal.vue renamed to docs/components/content/ModalConfirm.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ defineProps<{
66
}>()
77
88
const emit = defineEmits<{
9-
(e: 'update:modelValue', modelValue: boolean): void
109
(e: 'confirm'): void
1110
}>()
1211
</script>
@@ -15,7 +14,8 @@ const emit = defineEmits<{
1514
<VueFinalModal
1615
class="flex justify-center items-center"
1716
content-class="flex flex-col max-w-xl mx-4 p-4 bg-white dark:bg-gray-900 border dark:border-gray-700 rounded-lg space-y-2"
18-
@update:model-value="val => emit('update:modelValue', val)"
17+
content-transition="vfm-fade"
18+
overlay-transition="vfm-fade"
1919
>
2020
<h1 class="text-xl">
2121
{{ title }}

docs/components/content/PlainCssConfirmModal.vue renamed to docs/components/content/ModalConfirmPlainCss.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ defineProps<{
66
}>()
77
88
const emit = defineEmits<{
9-
(e: 'update:modelValue', modelValue: boolean): void
109
(e: 'confirm'): void
1110
}>()
1211
</script>
@@ -15,7 +14,8 @@ const emit = defineEmits<{
1514
<VueFinalModal
1615
class="confirm-modal"
1716
content-class="confirm-modal-content"
18-
@update:model-value="val => emit('update:modelValue', val)"
17+
overlay-transition="vfm-fade"
18+
content-transition="vfm-fade"
1919
>
2020
<h1>{{ title }}</h1>
2121
<slot />

docs/components/content/PlainCssConfirmModalPreview.vue renamed to docs/components/content/ModalConfirmPlainCssPreview.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<script setup lang="ts">
22
import { ModalsContainer, useModal } from 'vue-final-modal'
3-
import PlainCssConfirmModal from './PlainCssConfirmModal.vue'
3+
import ModalConfirmPlainCss from './ModalConfirmPlainCss.vue'
44
55
const { open, close } = useModal({
6-
component: PlainCssConfirmModal,
6+
component: ModalConfirmPlainCss,
77
attrs: {
88
title: 'Hello World!',
99
onConfirm() {
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<script setup lang="ts">
2+
import { ModalsContainer, useModal } from 'vue-final-modal'
3+
import ModalConfirm from './ModalConfirm.vue'
4+
const { open, close } = useModal({
5+
component: ModalConfirm,
6+
attrs: {
7+
title: 'Hello World!',
8+
onConfirm() {
9+
close()
10+
},
11+
},
12+
slots: {
13+
default: '<p>UseModal: The content of the modal</p>',
14+
},
15+
})
16+
</script>
17+
18+
<template>
19+
<VButton @click="() => open()">
20+
Open Modal
21+
</VButton>
22+
23+
<ModalsContainer />
24+
</template>

docs/components/content/DragResizeModal.vue renamed to docs/components/content/ModalDragResize.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ function dragResize(newRect) {
4040
<h3>Hello World!</h3>
4141
<p>{{ top }} х {{ left }} </p>
4242
<p>{{ width }} х {{ height }}</p>
43-
<button class="absolute top-0 right-0 mt-2 mr-2 px-2 border rounded-md " @click="emit('update:modelValue', false)">
43+
<button class="absolute top-0 right-0 mt-2 mr-2 px-2 border rounded-md " @pointerup="emit('update:modelValue', false)">
4444
X
4545
</button>
4646
</VueDragResize>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<script setup lang="ts">
2+
import { ModalsContainer } from 'vue-final-modal'
3+
import ModalDragResize from './ModalDragResize.vue'
4+
5+
const show = ref(false)
6+
</script>
7+
8+
<template>
9+
<VButton @click="show = true">
10+
Open Modal
11+
</VButton>
12+
13+
<ModalDragResize v-model="show" />
14+
15+
<ModalsContainer />
16+
</template>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<script setup lang="ts">
2+
import { VueFinalModal } from 'vue-final-modal'
3+
4+
defineProps<{
5+
title?: string
6+
}>()
7+
8+
const emit = defineEmits<{
9+
(e: 'close'): void
10+
}>()
11+
</script>
12+
13+
<template>
14+
<VueFinalModal
15+
content-class="w-full h-full flex flex-col bg-white dark:bg-gray-900 space-y-2"
16+
:hide-overlay="true"
17+
content-transition="vfm-fade"
18+
>
19+
<h1 class="text-xl">
20+
{{ title }}
21+
</h1>
22+
<slot />
23+
<button class="absolute top-4 right-4 px-2 border rounded-lg" @click="emit('close')">
24+
x
25+
</button>
26+
</VueFinalModal>
27+
</template>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<script setup lang="ts">
2+
import { ModalsContainer, useModal } from 'vue-final-modal'
3+
import ModalFullscreen from './ModalFullscreen.vue'
4+
const { open, close } = useModal({
5+
component: ModalFullscreen,
6+
attrs: {
7+
title: 'Hello World!',
8+
onClose() {
9+
close()
10+
},
11+
},
12+
slots: {
13+
default: '<p>ModalFullscreen: The content of the modal</p>',
14+
},
15+
})
16+
</script>
17+
18+
<template>
19+
<VButton @click="() => open()">
20+
Open Modal
21+
</VButton>
22+
23+
<ModalsContainer />
24+
</template>

docs/components/content/ModalIdPreview.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ function confirm() {
1414
Open Modal
1515
</VButton>
1616

17-
<ConfirmModal
17+
<ModalConfirm
1818
:modal-id="modalId"
1919
title="Hello World!"
2020
@confirm="() => confirm()"
2121
>
2222
<p>The content of the modal</p>
23-
</ConfirmModal>
23+
</ModalConfirm>
2424
</template>

0 commit comments

Comments
 (0)