Security News
Bun 1.2 Released with 90% Node.js Compatibility and Built-in S3 Object Support
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
jenesius-vue-modal
Advanced tools
Jenesius vue modal is simple library for Vue 3 only .
npm i jenesius-vue-modal
For add modals in your project you need to put the modal's container in the App component:
App.vue
<template>
<widget-container-modal />
</template>
<script>
import {container} from "jenesius-vue-modal";
export default {
components: {WidgetContainerModal: container},
name: "App"
}
</script>
Methods openModal
and pushModal
used to display modal windows.
openModal
- close all previous modals and then display provided component.pushModal
- display provided component import {openModal} from "jenesius-vue-modal";
import SomeVueComponent from "SomeVueComponent.vue";
openModal(SomeVueComponent, props);
Methods return promise, in this case promise is resolved - modalObject
const modal = await openModal(SomeVueComponent); // {id, close, onclose, closed}
openModal
- close all modals and then open provided modal.pushModal
- add one more provided modal.closeModal
- close all modals.popModal
- close last opened modal.There are three ways to track the closing of a modal:
Versions is higher than 1.2.0 NOT support 'next'. Now All hooks use only returned value(Boolean) for navigation hooks. If function return false or throwing an Error modal window will not be closed.
const modal = await openModal(Modal);
modal.onclose = () => {
console.log("Close");
return false; //Modal will not be closed
}
export default {
props: {},
data: () => ({isValidate: false}),
beforeModalClose(){
console.log("Close");
if (!isValidate) return false; //modal will not be closed while isValidate === false
}
}
export default{
setup() {
onBeforeModalClose(() => {
console.log("Close");
});
}
}
Hooks also can be asynchronous functions:
async beforeModalClose(){
await doSome();
return false; // This modal can not be closed!
}
or
beforeModalClose(){
return Promise(resolve => {
setTimeout(() => resolve(true), 2000); //Modal will closed after 2 second
})
}
For integrate modals into VueRouter you need to initialize your application:
import {createWebHistory, createRouter} from "vue-router";
import {useModalRouter} from "jenesius-vue-modal";
const router = createRouter({
history: createWebHistory(),
routes: [...],
});
useModalRouter.init(router);
import Modal from "Modal.vue"
const routes = [
{
path: "/any-route",
component: useModalRouter(Modal)
}
]
Now, when route will be /any-route the Modal window will open. For more information see Docs.
Please refer to the documentation to change the styles or animations of modals.
WidgeTestModal.vue
<template>
<p>{{title}}</p>
</template>
<script>
export default {
props: {
title: String
}
}
</script>
To show this component
import {openModal} from "jenesius-vue-modal"
import WidgeTestModal from "WidgeTestModal.vue";
openModal(WidgeTestModal, {
title: "Hello World!"
});
FAQs
The progressive and simple modal system for Vue.js v3
The npm package jenesius-vue-modal receives a total of 2,415 weekly downloads. As such, jenesius-vue-modal popularity was classified as popular.
We found that jenesius-vue-modal demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
Security News
Biden's executive order pushes for AI-driven cybersecurity, software supply chain transparency, and stronger protections for federal and open source systems.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.