All Projects → JounQin → Vue Async Modal

JounQin / Vue Async Modal

Licence: mit
Flexible modal component for Vue with ability of asynchronous lazy loading

Projects that are alternatives of or similar to Vue Async Modal

react-gallery-carousel
Mobile-friendly gallery carousel 🎠 with server side rendering, lazy loading, fullscreen, thumbnails, touch, mouse emulation, RTL, keyboard navigation and customisations.
Stars: ✭ 178 (+493.33%)
Mutual labels:  modal, lazy-loading
Elementui Multiselect
基于element ui、vue的多选框,支持选项disabled,支持分页,输入框过滤,可显示或隐藏全选和清空项
Stars: ✭ 14 (-53.33%)
Mutual labels:  vue-component
React Cool Inview
😎 🖥️ React hook to monitor an element enters or leaves the viewport (or another element).
Stars: ✭ 830 (+2666.67%)
Mutual labels:  lazy-loading
React Login Modal Sm
Customizable React Social Media login modal
Stars: ✭ 23 (-23.33%)
Mutual labels:  modal
Sloth
a simple images lazy load plugin.
Stars: ✭ 7 (-76.67%)
Mutual labels:  lazy-loading
Skeleton Elements
Skeleton elements - UI for improved perceived performance
Stars: ✭ 27 (-10%)
Mutual labels:  lazy-loading
Vue Quill Editor
🍡@quilljs editor component for @vuejs
Stars: ✭ 6,874 (+22813.33%)
Mutual labels:  vue-component
Hr4r
Example project - "Hot Reloading 4 RequireJS" front-end web applications & some extra code demonstrating hot-reloading for Node.js Express servers
Stars: ✭ 28 (-6.67%)
Mutual labels:  lazy-loading
Preact Lazy Route
Lazy load preact route components
Stars: ✭ 12 (-60%)
Mutual labels:  lazy-loading
V Distpicker
✨ A flexible, highly available district picker for picking provinces, cities and districts of China.
Stars: ✭ 919 (+2963.33%)
Mutual labels:  vue-component
Io Lazyload
A javascript library to lazy load images with intersection observer
Stars: ✭ 19 (-36.67%)
Mutual labels:  lazy-loading
Vue Js Toggle Button
🍥 Vue.js 2 toggle / switch button - simple, pretty, customizable
Stars: ✭ 836 (+2686.67%)
Mutual labels:  vue-component
Vue Croppa
A simple straightforward customizable mobile-friendly image cropper for Vue 2.0.
Stars: ✭ 942 (+3040%)
Mutual labels:  vue-component
Webannoyances
Fix and remove annoying web elements such as sticky headers, floating boxes, floating videos, dickbars, social share bars and other distracting elements.
Stars: ✭ 831 (+2670%)
Mutual labels:  modal
Vue Echarts V3
Vue.js(v2.x+) component wrap for ECharts.js(v3.x+)
Stars: ✭ 884 (+2846.67%)
Mutual labels:  vue-component
React Overlays
Utilities for creating robust overlay components
Stars: ✭ 809 (+2596.67%)
Mutual labels:  modal
Vue Responsive Calendar
A responsive calendar component for Vue.js
Stars: ✭ 17 (-43.33%)
Mutual labels:  vue-component
Nuxt Lazysizes
Lazysizes module for Nuxt.js
Stars: ✭ 25 (-16.67%)
Mutual labels:  lazy-loading
Vue Gh Corners
GitHub Corners for Vue.
Stars: ✭ 30 (+0%)
Mutual labels:  vue-component
Modalzinha Js
👨🏻‍💻 Very tiny modal in vanilla js.
Stars: ✭ 15 (-50%)
Mutual labels:  modal

vue-async-modal

GitHub Actions Codacy Grade npm GitHub Release

David Peer David David Dev

Conventional Commits Renovate enabled JavaScript Style Guide Code Style: Prettier codechecks.io

Flexible modal component for Vue with ability of asynchronous lazy loading

Usage

Firstly, you should add Modal component in your template.

<template>
  <div id="app">
    <modal />
  </div>
</template>
<script>
import { Modal } from 'vue-async-modal'

export default {
  components: {
    Modal,
  },
}
</script>

Then, you will be able to get the modal instance via this.$modal in every Vue component.

We provide a basic modal component ModalItem.

If you want to open modal MyModal in component Demo:

// Demo.vue
<template>
  <button @click="loadMyModal"></button>
</template>
<script>
export default {
  methods: {
    loadMyModal() {
      this.$modal.open({
        id: 'my-modal',
        component: import('./MyModal.vue'),
        options: {
          destroy: true,
        },
        props: {
          whatever,
        },
      })
    },
  },
}
</script>

// MyModal.vue
<template>
  <!-- the simplest way to use default header template an override modal-title is use prop header -->
  <!-- if you want to use default footer template, just add prop `footer: true` -->
  <!-- every ModalItem instance will show/disppear with a fade transition by default -->
  <!-- you can define prop transition to use your own transition, or just pass empty string `transition` prop to disable it -->
  <modal-item :header="Modal Header" :footer="true">
    <!-- slot header will be content of .modal-header -->
    <template slot="header">
      <button>×</button>
      <h4>
        <div class="modal-title">I'm Modal Title</div>
      </h4>
    </template>

    <!-- default slot will be used as content in .modal-body -->
    I'm content of Modal Body

    <!-- or you can use slot body to rewrite whole .modal-body -->
    <div class="modal-body" slot="body">
      Let's rewrite default .modal-body
    </div>

    <!-- you can overwrite footer content by slot footer -->
    <template slot="footer">
      <!-- cancle/confirm text can be rewrote by prop `cancleText` and `confirmText` -->
      <button class="btn btn-default">取消</button>
      <!-- if you are using `footer: true`, it will trigger `confirm` event on clicking confirm btn-->
      <!-- or you can use prop `disbaled: true` to disbale it -->
      <button class="btn btn-primary">确定</button>
    </template>
  </modal-item>
</template>
<script>
import { ModalItem } from 'vue-async-modal'

export default {
  components: {
    ModalItem,
  },
}
</script>

API

There are several useful methods on modal instance:

  1. open a modal instance
this.$modal.open({id, component, options, props}): Promise

id is optional, if no id passed in, it will generate a id by timestamp.

component could be a normal Vue component or a promise which will resolve a Vue component, so that we could use code spit and dynamic loading here.

options: {show, backdrop, destroy}:

show and backdrop will true if you don't set it.

If show is true, when you open modal, it will show automatically, or it will just add into DOM without displaying.

If backdrop is true, modal will open with a transparent black backdrop, unless backdrop is static, when user click modal outside, modal will auto trigger close event.

If destroy is true, the modal instance will destroy automatically on closing.

  1. close or destroy a modal instance
this.$modal.close(id, destroy): Promise

If id is falsy, it will be automatically choose current modal instance id.

if destroy is true, the modal instance will be destroyed even if it's options.destroy is false.

Changelog

Detailed changes for each release are documented in CHANGELOG.md.

License

MIT © JounQin@1stG.me

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].