1.0.0 • Published 7 months ago

vue3-snotify v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

Vue Snotify for Vue 3

Based on vue-snotify for Vue 2.

The following vue-snotify features are missing from this fork:

  • Custom HTML notifications
  • Dark and simple themes

Installation

  • npm i vue3-snotify
  • yarn add vue3-snotify

Usage

In main.ts:

...
import snotify from 'vue3-snotify';
import 'vue3-snotify/style';

const app = createApp(App);

app.use(snotify);

app.provide('snotify', app.config.globalProperties.$snotify);

app.mount('#app');

In App.vue:

<div>
    <MyApp />
    <vue-snotify />
</div>

With the Options API:

<script>
...

methods: {
    showToast() {
        this.$snotify.error('Hello, world!');
    },
},

...
</script>

<template>
    <button :onClick="showToast" />
</template>

With the Composition API:

<script setup>
import type { SnotifyService } from 'vue3-snotify';

const snotify = inject('snotify');

const showToast = snotify.success('Hello, world!');
</script>

<template>
    <button :onClick="showToast" />
</template>

With Nuxt 3

In plugins/snotify.ts:

import { defineNuxtPlugin } from '#app';
import Snotify, { type SnotifyService } from 'vue3-snotify';
import 'vue3-snotify/style';

declare module '#app' {
  interface NuxtApp {
    $snotify: SnotifyService;
  }
}

export default defineNuxtPlugin(nuxtApp => {
  const { vueApp } = nuxtApp;

  vueApp.use(Snotify);
  nuxtApp.provide('snotify', vueApp.config.globalProperties.$snotify);
});

In composables/useSnotify.ts:

export function useSnotify() {
  const { $snotify } = useNuxtApp();

  return $snotify;
}

Usage:

<script setup>
const snotify = useSnotify();

const showToast = snotify.success('Hello, world!');
</script>

<template>
    <button :onClick="showToast" />
</template>

To-do:

  • Restore HTML functionality on SnotifyService
  • Export Dark and Simple themes
  • Unit tests
0.1.0

8 months ago

1.0.0

7 months ago

0.2.0

8 months ago

0.0.6

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago