npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

vue-grille-pain

v1.1.12

Published

Lightweight Toast notifications for Vue3 composition API

Downloads

6

Readme

vue-grille-pain

Lightweight Toast notifications for Vue3 composition API

Introduction

vue-grille-pain is a light toast notification plugin for Vue3.

  • Fully typed configuration
  • Provides a custom hook for usage with the composition API
  • Toasts can be individually customized
  • Several animations to chose from
  • Light and dark theme
  • ...and more options

Check the demo here

Installation

Using npm

npm install vue-grille-pain

Using yarn

yarn add vue-grille-pain

Using CDN

<!-- Insert the Vue core before -->
<script src="https://unpkg.com/vue-grille-pain"></script>

<script>
  createApp(App)
    .use(GrillePain)
    .mount("#app");
</script>

Usage

Register the plugin wherever you create your Vue App:

import { createApp } from Vue;
import App from "./App.vue";
import GrillePain from "vue-grille-pain";

createApp(App)
  .use(GrillePain)
  .mount("#app");

You can also pass some options:

import { createApp } from Vue;
import App from "./App.vue";
import GrillePain, { GpOptions } from "vue-grille-pain";

const opts: GpOptions = {
  // your default configuration, see the options section for details
};

createApp(App)
  .use(GrillePain, opts)
  .mount("#app");

Then in any component you can now import the useGrillePain hook like so:

import { useGrillePain } from "vue-grille-pain";

const { toast } = useGrillePain();

// Generate a toast
toast({
  title: "Hello",
  message: "Very cool message!",
});

You can override most of your default configuration by passing some options:

import { useGrillePain, GpToast } from "vue-grille-pain";

const { toast } = useGrillePain();

const opts: GpToast = {
  title: "Hello",
  message: "Very cool message!",
  // rest of your toast config, see the options section for details
};

// Generate customized toast
toast(opts);

Options

Plugin configuration

These parameters can be passed when registering the plugin.

| Parameter | Type | Default | Description | | ---------------- | ----------- | ------------------------ | ----------------------------------------------------------------------------------------------------- | | position | GpPosition | GpPosition.BOTTOM_LEFT | Position of the toasts container | | order | GpOrder | GpOrder.ASC | Toasts ordering (oldest / newest on top) | | fullWidth | boolean | false | Toasts take up the full screen width (useful for mobile) | | animation | GpAnimation | GpAnimation.SLIDE_UP | Toasts display animation | | theme | GpTheme | GpTheme.LIGHT | Toasts theme | | fadeAfter | number | 5000 | Time in ms before toasts fade (0 for never) | | closeOnClick | boolean | false | Whether toasts should be closable on mouse click (by default, toasts are closable via a close button) | | maxMessageLength | number | undefined | If set, texts of a greater length will be truncated and the toasts will be expandable | | displayTimer | boolean | false | Displays a pie timer showing time before toasts fade (must have fadeAfter > 0) |

position, order and fullWidth are global parameters, meaning they concern the toasts container and cannot be overridden on a single toast.

Toast customization

These parameters can be passed when generating a toast.

| Parameter | Type | Default | Description | | ---------------- | ------------------ | ---------------------- | -------------------------------------------------------------------------------------------------- | | title | string | undefined | Displays a header with the title text | | message | string | '' | Toast message | | type | GpToastType | GpToastType.INFO | Type of toast (message, success, warning, error) | | className | string | string[] | undefined | Custom CSS classes | | animation | GpAnimation | GpAnimation.SLIDE_UP | Toast display animation | | theme | GpTheme | GpTheme.LIGHT | Toast theme | | fadeAfter | number | 5000 | Time in ms before toast fades (0 for never) | | closeOnClick | boolean | false | Whether toast should be closable on mouse click | | maxMessageLength | number | undefined | If set and the toast text length is greater, it will be truncated and the toast will be expandable | | displayTimer | boolean | false | Displays a pie timer showing time before toast fades (must have fadeAfter > 0) |

Notes

This is just a sandbox project to play around with the new Vue3 features. Feel free to contact me with requests or suggestions, or post pull requests and issues directly on GitHub.