GithubHelp home page GithubHelp logo

taylorfoster90 / toastada Goto Github PK

View Code? Open in Web Editor NEW

This project forked from adamkarb/toastada

0.0 2.0 0.0 13 KB

Vanilla Javascript lightweight toast notifications.

License: MIT License

JavaScript 100.00%

toastada's Introduction

Toastada

Vanilla Javascript toast notifications for your application. The goal of toastada is to provide a ligthweight javascript solution to creating your own custom notification system. By removing external dependencies, we can have the smallest possible library that works with all modern browsers.

Getting started

npm install --save toastada

Playground

For a quick live environment, run

npm install
npm run demo

Basics of use

In order to create a toastada notification, just invoke one of the 4 supported methods and pass a custom message as the sole argument. For example,

toastada.success('You did it! Great job!');

toastada.info('Here is some information before you proceed.');

toastada.warning('Warning! You are about to delete important data!');

toastada.error('Oh no! Something went wrong. Please try again.');

In order for all of the toast notifications to be visible, you will need to configure the toast classes via the toast.setClasses() method that you can see below. These classes will be applied to their respective toast types, so you can style your toasts however you please! View the demo for a live example. Take note of the use of the setClasses method and the provided classes. Feel free to copy the example CSS as you see fit.

Options

Toastada supports configuration right out of the box. The available options can be set via

toastada.setOptions({
    prependTo: document.getElementById('container'),
    lifeSpan: 5000
});
Option Description Default
prependTo The dom element that the toast notification will be prepended to. document.body.childNodes[0]
lifeSpan The duration in milliseconds that the toast notification will appear on the page. 4000 (ms)
position The position of the toast notifications on the page. (Currently only default supported) top-right
animate Whether or not the toast notification should animate on exit. false
animateDuration The length of time in milliseconds the toast notification should animate before being removed from the DOM. 0

Classes

Since Toastada is configured entirely via javsacript, you can configure the classes that will be applied to the corresponding elements via

toastada.setClasses({
    animate: 'animation-toast',
    success: 'success',
    error: 'critical'
});
Class Description Default
container The class name of the container that all of the toast notifications will be prepended to. toast-container
animate The name of the class that will be applied to all of the toast notifications as their duration expires and they begin to animate. toast-exit
default The class name that will be applied to all toast notifications. toast
success The class name that will be applied to all toast notifications invoked using toastada.success(message). toast-success
info The class name that will be applied to all toast notifications invoked using toastada.info(message). toast-info
warning The class name that will be applied to all toast notifications invoked using toastada.warning(message). toast-warning
error The class name that will be applied to all toast notifications invoked using toastada.error(message). toast-error

toastada's People

Contributors

adamkarb avatar

Watchers

James Cloos avatar Taylor Foster 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.