0.4.7 • Published 3 months ago

@overlays/vue v0.4.7

Weekly downloads
-
License
MIT
Repository
github
Last release
3 months 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 { createApp } from 'vue'
import unoverlay from '@overlays/vue'

const app = createApp({})
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 setup>
import { defineEmits, defineProps } from 'vue'
import { useOverlay } from '@overlays/vue'
const props = defineProps({
  title: String,
})

// Get Overlay information from useOverlay
const { visible, resolve, reject } = useOverlay({
  // Duration of popup layer duration to avoid premature destruction of the component
  duration: 1000,
})
</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.7

3 months ago

0.4.6

12 months ago

0.4.5

12 months ago

0.4.4

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