0.2.0 • Published 1 year ago

@vex-ui/notification v0.2.0

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

Vex Notification

this is a small unstyled notification service library for Vue 3.

installation

pnpm i @vex/notification

usage

  1. register the plugin in your app.
import { createApp } from 'vue'
import VexPlugin from '@vex/notification'

const app = createApp()
app.use(VexPlugin, {})
app.mount()
  1. use the useNotification composable to access the notify and notifications data, then use the Notification component to display the notifications, and dismiss to dismiss them.
import { useNotification } from '@vex/notification'
const { notify, notifications, dismiss } = useNotification()

<template>
  <NotificationProvider>
    <Notification
      @timer-end="dismiss(item.uuid)"
      v-for="item in notifications"
      v-bind="item"
      :key="item.uuid"
    />
  </NotificationProvider>
</template>
  1. use the notify function to display a notification.
import { useNotification } from '@vex/notification'
const { notify, notifications } = useNotification()

// anything you pass on the first argument will be available inside item.meta in the template.
notify({ message: 'Hello!' }, { duration: 3000 })

<template>
  <NotificationProvider>
    <Notification
      @timer-end="dismiss(item.uuid)"
      v-for="item in notifications"
      v-bind="item"
      :key="item.uuid"
    >
      <h2>{{ item.meta.message }}</h2>
    </Notification>
  </NotificationProvider>
</template>
0.2.0

1 year ago

0.1.2

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago