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

@paper-development/vtoast

v1.0.0

Published

A vanilla JavaScript toast library

Downloads

3

Readme

Vanilla Toasts (also refered to as vtoast) is a lightweight VanillaJS toast library. It does not require any framework to run. It is inspired from toastr but removes the dependency to jQuery.

It's also lighter and has fewer lines of code.

It is currently in active development thus some features mentioned below might not be (yet) implemented. Additional features may also be developed.

Current version: 1.0.0

Known issues with the current code:

  • None

States

A toast has 3 states

  • Hidden: The toast is either in the process of being created or deleted.
  • Shown: The toast is visible for the time set in the duration option.
  • Focused: The toast is frozen in time (the auto-remove is cancelled). Happens when the cursor enters the toast. Once the cursor leaves the toast, the toast will remain in a "shown" state for the time set in the unfocus-duration option.

Usage

To start with, include the CSS and the JavaScript (where PATH is the installation path or URL)

<link rel="stylesheet" href="PATH/vtoast.css">
<script src="PATH/vtoast.js"></script>

And you are ready to bring quality toasts to your website.

Consider the 3 variables below:

let title;
let content;
let options;

title and content are strings, options is a JSON.

Content only

If you pass only one parameter to the show method, it will be used as content and the default options set will be used.

vtoast.show(content);

Title and content

You can pass the title and the content to the show method, the default options set will be used.

vtoast.show(title, content);

Title, content and options

You can take full control and pass the title, the content and the options to the show method.

vtoast.show(title, content, options);

Options

Options are passed to the show method as a "one depth" JSON object.

|Option key|Default value|Description/Possible values| |---|---|---| |width|350|Defines the width (in px) of the toast. Any Number| |margin|10|Defines the margin (in px) around the toast. Any Number| |color|#004085 (bootstrap's primary)|Defines the font color of the toast. Any hex value| |backgroundcolor|#CCE5FF (bootstrap's primary)|Defines the background color of the toast. Any hex value| |duration|5000|The time (in ms) during which the toast will be visible. Any number| |unfocusduration|1000|The time (in ms) that the toast will remain visible after it as been unfocused| |position|top-right|The position of the toast. Any combination of top\|middle\|bottom-left\|centre\|right| |showclose|false|Whether or not to show a close icon on the toast. true or false.| |progressbar|hidden|The position of the progress bar in the toast. Either hidden, top or bottom. Performance note: when using hidden, the progress bar is disabled and the code is not included (It's not simply "hidden" through CSS).| |opacity|1|The opacity of the toast. Any decimal number between 0 and 1.|