1.1.12 • Published 2 years ago

vue-grille-pain v1.1.12

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

vue-grille-pain

Lightweight Toast notifications for Vue3 composition API

npm.io

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.

ParameterTypeDefaultDescription
positionGpPositionGpPosition.BOTTOM_LEFTPosition of the toasts container
orderGpOrderGpOrder.ASCToasts ordering (oldest / newest on top)
fullWidthbooleanfalseToasts take up the full screen width (useful for mobile)
animationGpAnimationGpAnimation.SLIDE_UPToasts display animation
themeGpThemeGpTheme.LIGHTToasts theme
fadeAfternumber5000Time in ms before toasts fade (0 for never)
closeOnClickbooleanfalseWhether toasts should be closable on mouse click (by default, toasts are closable via a close button)
maxMessageLengthnumberundefinedIf set, texts of a greater length will be truncated and the toasts will be expandable
displayTimerbooleanfalseDisplays 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.

ParameterTypeDefaultDescription
titlestringundefinedDisplays a header with the title text
messagestring''Toast message
typeGpToastTypeGpToastType.INFOType of toast (message, success, warning, error)
classNamestring | string[]undefinedCustom CSS classes
animationGpAnimationGpAnimation.SLIDE_UPToast display animation
themeGpThemeGpTheme.LIGHTToast theme
fadeAfternumber5000Time in ms before toast fades (0 for never)
closeOnClickbooleanfalseWhether toast should be closable on mouse click
maxMessageLengthnumberundefinedIf set and the toast text length is greater, it will be truncated and the toast will be expandable
displayTimerbooleanfalseDisplays 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.

1.1.12

2 years ago

1.1.9

3 years ago

1.1.8

3 years ago

1.1.11

3 years ago

1.1.10

3 years ago

1.1.7

3 years ago

1.1.6

3 years ago

1.1.5

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.1.4

3 years ago

1.1.3

3 years ago

1.1.2

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago