Skip to content

Commit e66ecce

Browse files
committed
docs: add modal-long-scroll example to use cases page #337
1 parent d3f7cb0 commit e66ecce

File tree

3 files changed

+165
-0
lines changed

3 files changed

+165
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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: 'update:modelValue', modelValue: boolean): void
10+
(e: 'confirm'): void
11+
}>()
12+
</script>
13+
14+
<template>
15+
<VueFinalModal
16+
content-transition="vfm-fade"
17+
overlay-transition="vfm-fade"
18+
content-class="absolute inset-0"
19+
@update:model-value="(val) => emit('update:modelValue', val)"
20+
>
21+
<div
22+
class="absolute inset-0 h-full overflow-auto"
23+
@click.self="() => emit('update:modelValue', false)"
24+
>
25+
<div class="flex flex-col max-w-xl my-12 mx-auto p-4 bg-white dark:bg-gray-900 border dark:border-gray-700 rounded-lg space-y-2">
26+
<h1 class="text-xl">
27+
{{ title }}
28+
</h1>
29+
<slot />
30+
<button class="mt-1 ml-auto px-2 border rounded-lg" @click="() => emit('confirm')">
31+
Confirm
32+
</button>
33+
</div>
34+
</div>
35+
</VueFinalModal>
36+
</template>
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<script setup lang="ts">
2+
import { ModalsContainer, useModal } from 'vue-final-modal'
3+
import ModalLongScroll from './ModalLongScroll.vue'
4+
5+
const p = `<p>
6+
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras ullamcorper,
7+
ex at blandit iaculis, nibh urna lacinia tellus, a auctor lorem libero a
8+
lectus. Nulla bibendum mollis sapien, nec euismod mi mattis cursus.
9+
Curabitur accumsan erat eu viverra fringilla. Interdum et malesuada fames
10+
ac ante ipsum primis in faucibus. Phasellus ut neque eu diam vehicula
11+
efficitur. Vivamus ultricies purus facilisis augue porttitor vestibulum a
12+
non neque. Nunc egestas risus elit, sed fringilla velit posuere et.
13+
</p>`
14+
15+
const { open, close } = useModal({
16+
component: ModalLongScroll,
17+
attrs: {
18+
title: 'Hello World!',
19+
onConfirm: () => close(),
20+
},
21+
slots: {
22+
default: p + p + p + p + p + p + p + p + p + p + p + p,
23+
},
24+
})
25+
</script>
26+
27+
<template>
28+
<VButton @click="open">
29+
Open Modal
30+
</VButton>
31+
32+
<ModalsContainer />
33+
</template>
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
---
2+
head.title: 'Modal Long Scroll | Examples'
3+
---
4+
5+
# Modal Long Scroll
6+
7+
A long scrollable modal example like [Bootstrap Modal scrolling-long-content](https://getbootstrap.com/docs/5.3/components/modal/#scrolling-long-content)
8+
9+
## Preview
10+
11+
::code-group
12+
::code-block{label="Preview" preview}
13+
::modal-long-scroll-preview
14+
::
15+
::
16+
17+
```vue [Preview.vue]
18+
<script setup lang="ts">
19+
import { ModalsContainer, useModal } from 'vue-final-modal'
20+
import ModalLongScroll from './ModalLongScroll.vue'
21+
22+
const p = `<p>
23+
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras ullamcorper,
24+
ex at blandit iaculis, nibh urna lacinia tellus, a auctor lorem libero a
25+
lectus. Nulla bibendum mollis sapien, nec euismod mi mattis cursus.
26+
Curabitur accumsan erat eu viverra fringilla. Interdum et malesuada fames
27+
ac ante ipsum primis in faucibus. Phasellus ut neque eu diam vehicula
28+
efficitur. Vivamus ultricies purus facilisis augue porttitor vestibulum a
29+
non neque. Nunc egestas risus elit, sed fringilla velit posuere et.
30+
</p>`
31+
32+
const { open, close } = useModal({
33+
component: ModalLongScroll,
34+
attrs: {
35+
title: 'Hello World!',
36+
onConfirm: () => close(),
37+
},
38+
slots: {
39+
default: p + p + p + p + p + p + p + p + p + p + p + p,
40+
},
41+
})
42+
</script>
43+
44+
<template>
45+
<VButton @click="open">
46+
Open Modal
47+
</VButton>
48+
49+
<ModalsContainer />
50+
</template>
51+
52+
```
53+
::
54+
55+
## `<ModalLongScroll>` component
56+
57+
::code-group
58+
```vue [ModalLongScroll.vue]
59+
<script setup lang="ts">
60+
import { VueFinalModal } from 'vue-final-modal'
61+
62+
defineProps<{
63+
title?: string
64+
}>()
65+
66+
const emit = defineEmits<{
67+
(e: 'update:modelValue', modelValue: boolean): void
68+
(e: 'confirm'): void
69+
}>()
70+
</script>
71+
72+
<template>
73+
<VueFinalModal
74+
content-transition="vfm-fade"
75+
overlay-transition="vfm-fade"
76+
content-class="absolute inset-0"
77+
@update:model-value="(val) => emit('update:modelValue', val)"
78+
>
79+
<div
80+
class="absolute inset-0 h-full overflow-auto"
81+
@click.self="() => emit('update:modelValue', false)"
82+
>
83+
<div class="flex flex-col max-w-xl my-12 mx-auto p-4 bg-white dark:bg-gray-900 border dark:border-gray-700 rounded-lg space-y-2">
84+
<h1 class="text-xl">
85+
{{ title }}
86+
</h1>
87+
<slot />
88+
<button class="mt-1 ml-auto px-2 border rounded-lg" @click="() => emit('confirm')">
89+
Confirm
90+
</button>
91+
</div>
92+
</div>
93+
</VueFinalModal>
94+
</template>
95+
```
96+
::

0 commit comments

Comments
 (0)