0.4.4 • Published 1 month ago

@overlays/vue2 v0.4.4

Weekly downloads
-
License
MIT
Repository
github
Last release
1 month ago

Getting Started

overlays only supports Vue3 | Vue2 Composition-api

Install

With pnpm:

pnpm add @overlays/vue

With yarn:

yarn add @overlays/vue

Global

You can register overlays globally, which will inherit the application context for all popups.

// main.js
import Vue from 'vue'
import unoverlay from '@overlays/vue'

const app = new Vue({})
app.use(unoverlay)

Usage

Step 1: Define Component

overlays is suitable for most components. Using useOverlay can provide finer control over the component process.

<!-- overlay.vue -->
<script>
import { useOverlay } from '@overlays/vue2'
export default {
  mixins: [useOverlay({ duration: 1000 })],
  methods: {
    onClick() {
      // use this.$visible
      // use this.$resolve or this.$reject
    }
  }
}
</script>

<template>
  <div v-if="visible" @click="resolve(`${title}:confirmed`)">
    {{ title }}
  </div>
</template>

Step 2: Create Overlay

You can use the defineOverlay method to convert the component into a modal dialog in Javascript / Typescript, which allows you to call it.

import { defineOverlay } from '@overlays/vue'
import OverlayComponent from './overlay.vue'

// Convert to imperative callback
const callback = defineOverlay(OverlayComponent)
// Call the component and get the value of the resolve callback
const value = await callback({ title: 'callbackOverlay' })
// value === "callbackOverlay:confirmed"

You can also use renderOverlay to directly call the component and skip the defineOverlay method.

import { renderOverlay } from '@overlays/vue'
import OverlayComponent from './overlay.vue'

const value = await renderOverlay(OverlayComponent, {
  title: 'useOverlay'
})
// value === "useOverlay:confirmed"
0.4.4

1 month ago

0.4.3

12 months ago

0.4.2

1 year ago

0.4.1

1 year ago

0.4.0

1 year ago

0.3.0

1 year ago

0.2.2

1 year ago

0.2.1

1 year ago

0.2.0

1 year ago

0.1.2

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago