Skip to content

Commit a79e5e8

Browse files
feat: drag & resize (#98)
* refactor: plugin validation, unit test fix: build lib refactor validPlugin function refactor: validPlugin and unit test test: watch hideOverlay * feat: add postcss plugin autoprefixer * chore: add favicon * feat: support v-html in dynamic modal slot * feat: draggable modal fix: remove prop dragSelector fix: unit test, contentStyle only support [Object, Array] docs: 1. add vetur attributes and tags 2. drag document refactor: drag modal docs: fix typo docs fix feat: drag and resize modal build lib docs: update docs * docs: Bump @nuxt/content-theme-docs * feat: api return promise * feat: add postcss plugin autoprefixer (#71) * refactor: plugin validation, unit test (#70) fix: build lib refactor validPlugin function refactor: validPlugin and unit test test: watch hideOverlay * Feat: vite (#78) * feat: 1. bump rollup, rollup-plugin-cleanup 2. remove rollup-plugin-css-only * feat(example): vite, windicss, vite-plugin-components for Vue 2 * docs: fix duplicate component name * feat: remove vue-cli-service, add jest, eslint * fix: lint tests directory * feat: add script dev:example, dev:docs * fix: .babelrc for build and test * feat!: api return promise (#76) * feat: api return promise * refactor: use noop to replace empty arrow function * feat: unit tests * docs: update * fix: dynamic modal promise, refactor unit test * feat: unit tests * feat: resizable modal in boundary * feat: drag & resize * docs(en): drag & resize * docs(zh-Hant): drag & resize * refactor: code review * docs: fix v-button * docs: version 2 * chore: lint * refactor: CLASS_PROP, STYLE_PROP * chore: update yarn.lock
1 parent bd98009 commit a79e5e8

File tree

99 files changed

+3419
-1972
lines changed

Some content is hidden

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

99 files changed

+3419
-1972
lines changed

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
## 🎉 [Documentation](https://vue-final-modal.org)
3030

31-
## 🙌 [Examples](https://vue-final-modal.org/examples/manual)
31+
## 🙌 [Examples](https://vue-final-modal.org/examples/liveDemo)
3232

3333
## Introduction
3434

@@ -42,7 +42,7 @@ You can create a [higher-order component](https://vue-final-modal.org/examples/r
4242
- [Tailwind CSS](https://vue-final-modal.org/examples/tailwind) friendly
4343
- Renderless component
4444
- [Tiny bundle size](https://bundlephobia.com/result?p=vue-final-modal)
45-
- Support `stackable`, `detachable`, `scrollable`, `transition`, `accessibility`, `focusTrap`, `dynamic modal`
45+
- Support `stackable`, `detachable`, `scrollable`, `draggable`, `resizable`, `transition`, `accessibility`, `focusTrap`, `dynamic modal`
4646

4747
## **Development**
4848

@@ -63,7 +63,7 @@ yarn build
6363
# Run examples
6464
cd examples
6565
yarn
66-
yarn serve
66+
yarn dev
6767

6868
# Run docs
6969
cd docs
@@ -95,6 +95,8 @@ To develop `vue-final-modal`, I learn a lot from these awesome libraries:
9595
- focusTrap for A11y
9696
- [Bootstrap Vue](https://bootstrap-vue.org/)
9797
- lockScroll
98+
- [vue-resizable](https://github.com/nikitasnv/vue-resizable)
99+
- drag & resize
98100

99101
> There is no perfect library even the `final` of vue modal.
100102

dist/VueFinalModal.esm.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/VueFinalModal.esm.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/VueFinalModal.umd.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/VueFinalModal.umd.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/components/examples/basic/BasicOptions.vue

Lines changed: 91 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,31 @@
1616
:attach="attach ? '#attach' : false"
1717
:focus-retain="focusRetain"
1818
:focus-trap="focusTrap"
19+
:drag="drag"
20+
:fit-parent="fitParent"
21+
:keep-changed-style="keepChangedStyle"
22+
:resize="resize"
23+
:resize-directions="resizeDirections"
24+
:drag-selector="allowDragSelector ? dragSelector : ''"
25+
:min-width="minWidth"
26+
:max-width="maxWidth"
27+
:min-height="minHeight"
28+
:max-height="maxHeight"
1929
@confirm="showModal = false"
2030
@cancel="showModal = false"
2131
>
2232
<template v-slot:title># Hello, world!</template>
23-
<p>
24-
Lorem Ipsum is simply dummy text of the printing and typesetting industry.
25-
</p>
33+
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry.</p>
2634
</v-modal>
2735

28-
<button class="vfm-btn" @click="showModal = true">Open Modal</button>
36+
<div class="flex space-x-2">
37+
<v-button highlight @click="showModal = true">Open Modal</v-button>
38+
<v-button @click="reset">reset</v-button>
39+
</div>
2940

30-
<h3>Prop Options:</h3>
41+
<h3 class="py-2">Basic:</h3>
3142

32-
<div class="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-4 p-4 border rounded">
43+
<div class="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-y-4 p-4 border rounded select-none">
3344
<label class="flex items-center space-x-2">
3445
<span>value:</span>
3546
<input v-model="showModal" type="checkbox" />
@@ -38,7 +49,6 @@
3849
<span>ssr:</span>
3950
<input v-model="ssr" type="checkbox" />
4051
</label>
41-
4252
<label class="flex items-center space-x-2">
4353
<span>lockScroll:</span>
4454
<input v-model="lockScroll" type="checkbox" />
@@ -101,13 +111,69 @@
101111
<span>focusTrap:</span>
102112
<input v-model="focusTrap" type="checkbox" />
103113
</label>
104-
<button class="vfm-btn" @click="reset">reset</button>
105114
</div>
106-
<h4>Attach area:</h4>
107-
<div id="attach" class="relative w-full h-64 mt-8 p-4 border rounded dark:bg-gray-700">
108-
<button class="vfm-btn" @click="openAttach">
109-
Attach to here and open modal
110-
</button>
115+
<h3 class="py-2">Drag & Resize:</h3>
116+
<div class="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-4 p-4 border rounded select-none">
117+
<label class="flex items-center space-x-2">
118+
<span>drag:</span>
119+
<input v-model="drag" type="checkbox" />
120+
</label>
121+
<div class="flex flex-col">
122+
<label class="flex items-center space-x-2">
123+
<input v-model="allowDragSelector" type="checkbox" />
124+
<span>dragSelector:</span>
125+
</label>
126+
<label>
127+
<input
128+
v-model="dragSelector"
129+
:disabled="!allowDragSelector"
130+
class="pl-2 dark:text-black rounded focus:outline-none"
131+
/>
132+
</label>
133+
</div>
134+
<label class="flex items-center space-x-2">
135+
<span>fitParent:</span>
136+
<input v-model="fitParent" type="checkbox" />
137+
</label>
138+
<label class="flex items-center space-x-2">
139+
<span>keepChangedStyle:</span>
140+
<input v-model="keepChangedStyle" type="checkbox" />
141+
</label>
142+
<label class="flex items-center space-x-2">
143+
<span>resize:</span>
144+
<input v-model="resize" type="checkbox" />
145+
</label>
146+
<div class="flex flex-col">
147+
<span>resizeDirections:</span>
148+
<div class="flex space-x-1">
149+
<div v-for="direction in ['t', 'tr', 'r', 'br', 'b', 'bl', 'l', 'tl']" :key="direction">
150+
<label>
151+
{{ direction }}:
152+
<input type="checkbox" v-model="resizeDirections" :value="direction" />
153+
</label>
154+
</div>
155+
</div>
156+
</div>
157+
<label class="flex items-center space-x-2">
158+
<span>minWidth:</span>
159+
<input v-model.number="minWidth" type="number" class="w-20 pl-2 dark:text-black rounded focus:outline-none" />
160+
</label>
161+
<label class="flex items-center space-x-2">
162+
<span>maxWidth:</span>
163+
<input v-model.number="maxWidth" type="number" class="w-20 pl-2 dark:text-black rounded focus:outline-none" />
164+
</label>
165+
<label class="flex items-center space-x-2">
166+
<span>minHeight:</span>
167+
<input v-model.number="minHeight" type="number" class="w-20 pl-2 dark:text-black rounded focus:outline-none" />
168+
</label>
169+
<label class="flex items-center space-x-2">
170+
<span>maxHeight:</span>
171+
<input v-model.number="maxHeight" type="number" class="w-20 pl-2 dark:text-black rounded focus:outline-none" />
172+
</label>
173+
</div>
174+
<h3 class="py-2">Attach:</h3>
175+
<div id="attach" class="relative w-full h-64 p-4 border rounded dark:bg-gray-900 overflow-hidden">
176+
<v-button highlight @click="openAttach">Attach to here and open modal</v-button>
111177
<p>click will:</p>
112178
<ul>
113179
<li>set "attach" to "true"</li>
@@ -134,7 +200,18 @@ const initData = () => ({
134200
zIndex: 0,
135201
attach: false,
136202
focusRetain: true,
137-
focusTrap: false
203+
focusTrap: false,
204+
drag: false,
205+
fitParent: true,
206+
keepChangedStyle: false,
207+
resize: false,
208+
resizeDirections: ['t', 'tr', 'r', 'br', 'b', 'bl', 'l', 'tl'],
209+
allowDragSelector: false,
210+
dragSelector: '.modal__title',
211+
minWidth: 0,
212+
maxWidth: 2000,
213+
minHeight: 0,
214+
maxHeight: 2000
138215
})
139216
140217
export default {

docs/components/examples/basic/BasicPlainStyleCodepen.vue

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

docs/components/examples/basic/VAccessibility.vue

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,10 @@
22
<div>
33
<v-modal v-model="show" @confirm="show = false" @cancel="show = false" focus-trap>
44
<template v-slot:title>Hello, vue-final-modal</template>
5-
<p>
6-
Vue Final Modal is a renderless, stackable, detachable and lightweight modal component.
7-
</p>
5+
<p>Vue Final Modal is a renderless, stackable, detachable and lightweight modal component.</p>
86
</v-modal>
97

10-
<button class="vfm-btn" @click="show = true">Open modal</button>
8+
<v-button highlight @click="show = true">Open modal</v-button>
119
</div>
1210
</template>
1311

docs/components/examples/basic/VActionButtons.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@
1111
</p>
1212
</div>
1313
<div class="modal__action">
14-
<button class="vfm-btn" @click="showModal = false">confirm</button>
15-
<button class="vfm-btn" @click="showModal = false">cancel</button>
14+
<v-button @click="showModal = false">confirm</v-button>
15+
<v-button @click="showModal = false">cancel</v-button>
1616
</div>
1717
</vue-final-modal>
18-
<button class="vfm-btn" @click="showModal = true">Open modal</button>
18+
<v-button highlight @click="showModal = true">Open modal</v-button>
1919
</div>
2020
</template>
2121

docs/components/examples/basic/VApiShow.vue

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
<template>
22
<div>
33
<v-modal v-model="showModal" name="VApiShow" @confirm="showModal = false" @cancel="showModal = false">
4-
<template v-slot="{ params }"> Hi {{ params.userName }} </template>
4+
<template v-slot="{ params }">Hi {{ params.userName }} </template>
55
<template v-slot:title>$vfm.show</template>
66
</v-modal>
7-
<button class="vfm-btn" @click="$vfm.show('VApiShow', { userName: 'vue-final-modal' })">
8-
Open modal
9-
</button>
7+
<v-button highlight @click="$vfm.show('VApiShow', { userName: 'vue-final-modal' })">Open modal</v-button>
108
</div>
119
</template>
1210

docs/components/examples/basic/VBackground.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<vue-final-modal v-model="showModal" content-class="modal-content">
44
<span class="modal__title">Hello, vue-final-modal</span>
55
</vue-final-modal>
6-
<button class="vfm-btn" @click="showModal = true">Open modal</button>
6+
<v-button highlight @click="showModal = true">Open modal</v-button>
77
</div>
88
</template>
99

docs/components/examples/basic/VBasic.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<vue-final-modal v-model="showModal">
44
<span class="modal__title">Hello, vue-final-modal</span>
55
</vue-final-modal>
6-
<button class="vfm-btn" @click="showModal = true">Open modal</button>
6+
<v-button highlight @click="showModal = true">Open modal</v-button>
77
</div>
88
</template>
99

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<template>
2+
<button class="v-btn" v-on="$listeners"><span v-if="highlight">👉 </span><slot></slot></button>
3+
</template>
4+
5+
<script>
6+
export default {
7+
props: {
8+
highlight: {
9+
type: Boolean,
10+
default: false
11+
}
12+
}
13+
}
14+
</script>
15+
<style scoped>
16+
button.v-btn {
17+
@apply px-2 py-1 border rounded;
18+
}
19+
button.v-btn + button.v-btn {
20+
margin: 0 0 0 1rem;
21+
}
22+
</style>

docs/components/examples/basic/VCentered.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<vue-final-modal v-model="showModal" classes="modal-container" content-class="modal-content">
44
<span class="modal__title">Hello, vue-final-modal</span>
55
</vue-final-modal>
6-
<button class="vfm-btn" @click="showModal = true">Open modal</button>
6+
<v-button highlight @click="showModal = true">Open modal</v-button>
77
</div>
88
</template>
99

docs/components/examples/basic/VCloseButton.vue

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,10 @@
66
</button>
77
<span class="modal__title">Hello, vue-final-modal</span>
88
<div class="modal__content">
9-
<p>
10-
Vue Final Modal is a renderless, stackable, detachable and lightweight modal component.
11-
</p>
9+
<p>Vue Final Modal is a renderless, stackable, detachable and lightweight modal component.</p>
1210
</div>
1311
</vue-final-modal>
14-
<button class="vfm-btn" @click="showModal = true">Open modal</button>
12+
<v-button highlight @click="showModal = true">Open modal</v-button>
1513
</div>
1614
</template>
1715

docs/components/examples/basic/VContent.vue

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,10 @@
33
<vue-final-modal v-model="showModal" classes="modal-container" content-class="modal-content">
44
<span class="modal__title">Hello, vue-final-modal</span>
55
<div class="modal__content">
6-
<p>
7-
Vue Final Modal is a renderless, stackable, detachable and lightweight modal component.
8-
</p>
6+
<p>Vue Final Modal is a renderless, stackable, detachable and lightweight modal component.</p>
97
</div>
108
</vue-final-modal>
11-
<button class="vfm-btn" @click="showModal = true">Open modal</button>
9+
<v-button highlight @click="showModal = true">Open modal</v-button>
1210
</div>
1311
</template>
1412

docs/components/examples/basic/VDynamic.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<button class="vfm-btn mb-4" @click="dynamic">Open Dynamic Modal</button>
2+
<v-button class="mb-4" highlight @click="dynamic">Open Dynamic Modal</v-button>
33
</template>
44

55
<script>

docs/components/examples/basic/VDynamicAdvanced.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<button class="vfm-btn mb-4" @click="dynamic">Open Dynamic Modal</button>
2+
<v-button class="mb-4" highlight @click="dynamic">Open Dynamic Modal</v-button>
33
</template>
44

55
<script>

docs/components/examples/basic/VEvents.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
>
1212
<template v-slot:title>Events Example!</template>
1313
</v-modal>
14-
<button class="vfm-btn" @click="showModal = true">Open modal</button>
14+
<v-button highlight @click="showModal = true">Open modal</v-button>
1515
</div>
1616
</template>
1717

docs/components/examples/basic/VParams.vue

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,27 +19,15 @@
1919
</p>
2020
</div>
2121
<div class="modal__action">
22-
<button class="vfm-btn" @click="$vfm.hide('stackable')">
23-
confirm
24-
</button>
25-
<button class="vfm-btn" @click="$vfm.hide('stackable')">
26-
cancel
27-
</button>
22+
<v-button @click="$vfm.hide('stackable')">confirm</v-button>
23+
<v-button @click="$vfm.hide('stackable')">cancel</v-button>
2824
</div>
2925
</template>
3026
</vue-final-modal>
31-
<button class="vfm-btn" @click="$vfm.show('stackable', { test: 123 })">
32-
Show modal with params
33-
</button>
34-
<button class="vfm-btn" @click="$vfm.toggle('stackable', null, { test: 321 })">
35-
Toggle modal with params
36-
</button>
37-
<button class="vfm-btn" @click="$vfm.show('stackable')">
38-
Show modal
39-
</button>
40-
<button class="vfm-btn" @click="$vfm.hide('stackable')">
41-
Hide modal
42-
</button>
27+
<v-button @click="$vfm.show('stackable', { test: 123 })">Show modal with params</v-button>
28+
<v-button @click="$vfm.toggle('stackable', null, { test: 321 })">Toggle modal with params</v-button>
29+
<v-button @click="$vfm.show('stackable')">Show modal</v-button>
30+
<v-button @click="$vfm.hide('stackable')">Hide modal</v-button>
4331
</div>
4432
</template>
4533

docs/components/examples/basic/VScrollable.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
</p>
1212
</div>
1313
</vue-final-modal>
14-
<button class="vfm-btn" @click="showModal = true">Open modal</button>
14+
<v-button highlight @click="showModal = true">Open modal</v-button>
1515
</div>
1616
</template>
1717

0 commit comments

Comments
 (0)