Coder Social home page Coder Social logo

sermonis / vue-notification-notivue Goto Github PK

View Code? Open in Web Editor NEW

This project forked from smastrom/notivue

0.0 0.0 0.0 1.25 MB

:bell: Fully-featured toast notification system for Vue and Nuxt.

Home Page: https://notivue.smastrom.dev

License: MIT License

Shell 0.70% JavaScript 1.48% TypeScript 66.69% CSS 3.76% HTML 0.20% Vue 27.18%

vue-notification-notivue's Introduction

notivue


Notivue

Fully-featured notification system for Vue and Nuxt

Live Demo - Documentation


Examples: Custom Components - Nuxt



Features

๐Ÿงฌ JS and CSS modular
Granularly include only the features you need

๐Ÿ’Š Drop-in components to enhance notifications
NotivueSwipe, NotivueKeyboard, all optional and customizable

๐ŸŽข Slick transitions and animations
Customize any animation with CSS

๐Ÿงฉ Custom Components API
Use your own components while Notivue handles the rest

๐ŸŒ€ Promise API
Update pending notifications with ease

๐Ÿ”ฐ Includes a ready-made component with anything you need
Themes, icons, rtl support and much more

โ™ฟ๏ธ Fully accessible
Built-in screen reader, reduced motion, and keyboard support

๐Ÿงšโ€โ™‚๏ธ Zero dependencies
From ~4.5 KB (gzipped)


Installation

pnpm add notivue

# npm i notivue
# yarn add notivue
# bun install notivue

Single-page app (Vite or Webpack)

๐Ÿ’ก See โ†“ below for Nuxt

main.js/ts

import { createApp } from 'vue'
import { createNotivue } from 'notivue'

import App from './App.vue'

import 'notivue/notifications.css' // Only needed if using built-in notifications
import 'notivue/animations.css' // Only needed if using built-in animations

const app = createApp(App)

// Place it at THE END of the app.use() chain, just right before app.mount()
export const push = createNotivue(app)
app.mount('#app')

App.vue

<script setup>
import { Notivue, Notifications } from 'notivue'
import { push } from './main'
</script>

<template>
  <button @click="push.success('This is your first notification!')">Push</button>

  <Notivue v-slot="item">
    <Notifications :item="item" />
  </Notivue>

  <!-- RouterView, etc. -->
</template>
Using custom components
<script setup>
import { Notivue } from 'notivue'
import { push } from './main'
</script>

<template>
  <button @click="push.success('This is your first notification!')">Push</button>

  <Notivue v-slot="item">
    <div class="rounded-full flex py-2 pl-3 bg-slate-700 text-slate-50 text-sm">
      <p :role="item.ariaRole" :aria-live="item.ariaLive">
        {{ item.message }}
      </p>

      <button
        @click="item.clear"
        aria-label="Dismiss"
        class="pl-3 pr-2 hover:text-red-300 transition-colors"
      >
        <svg
          xmlns="http://www.w3.org/2000/svg"
          viewBox="0 0 20 20"
          fill="currentColor"
          class="w-5 h-5"
          aria-hidden="true"
        >
          <path
            fill-rule="evenodd"
            d="M10 18a8 8 0 100-16 8 8 0 000 16zM8.28 7.22a.75.75 0 00-1.06 1.06L8.94 10l-1.72 1.72a.75.75 0 101.06 1.06L10 11.06l1.72 1.72a.75.75 0 101.06-1.06L11.06 10l1.72-1.72a.75.75 0 00-1.06-1.06L10 8.94 8.28 7.22z"
          />
        </svg>
      </button>
    </div>
  </Notivue>

  <!-- RouterView, etc. -->
</template>

Nuxt

nuxt.config.ts

export default defineNuxtConfig({
  modules: ['notivue/nuxt'],
  css: [
    'notivue/notifications.css', // Only needed if using built-in notifications
    'notivue/animations.css' // Only needed if using built-in animations
  ],
  notivue: {
    // Options
  }
})

app.vue

<script setup>
const push = usePush()
</script>

<template>
  <button @click="push.success('This is your first notification!')">Push</button>

  <Notivue v-slot="item">
    <Notifications :item="item" />
  </Notivue>

  <!-- NuxtLayout, NuxtPage, etc. -->
</template>

Thanks


License

MIT Licensed - Simone Mastromattei ยฉ 2023

vue-notification-notivue's People

Contributors

smastrom avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.