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

@tip2tail/toast

v0.1.1

Published

helper library for Bootstrap Toast functionality

Downloads

4

Readme

IMPORTANT NOTE

This package was mainly creted by @Script47 - see https://github.com/Script47/Toast

I have simply published it here to use in my build process.

Toast - A Bootstrap 4.2+ jQuery plugin

About

As of Bootstrap 4.2, toasts have been introduced and the aim of this plugin is to make them easier to use.

Usage

You can pass to the $.toast function an object with the settings for your toast which are as follows:

| Parameter |Description| Default | Values | | ------------- |-----------| ------- |--------- | title | Shows in the top left corner of the toast header | 'Notice!'| | | subtitle | Shows in the top right corner of the toast header | N/A | | | content | Shows in the toast body | N/A | | type | Determines the style of the toast based on Bootstrap styles | 'info' | 'info', 'success', 'warning', 'error' | delay | Determines how long the Toast shoud be shown for. The default, -1, will show the toast until the user clicks close. | -1 | omit or set to -1 to disable auto close, or timeout value in milliseconds | img | Shows an image before the title | N/A | { src: '', class: '', title: '', alt: '' }

Note: If content is omitted, the toast will not have a .toast-body and can be used as a small snack which will be shown below in the examples. By default toasts will be positioned in the top right corner and will in the future (hopefully) have other position options.

$.toast({
  title: 'Toast',
  subtitle: '11 mins ago',
  content: 'Hello, world! This is a toast message.',
  type: 'info',
  delay: 5000
});

Example #1

The respective markdown for the above would be:

<div class="toast" role="alert" aria-live="assertive" aria-atomic="true" data-delay="5000">
  <div class="toast-header bg-info text-white">
    <strong class="mr-auto">Toast</strong>
    <small class="text-white">11 mins ago</small>
    <button type="button" class="ml-2 mb-1 close" data-dismiss="toast" aria-label="Close">
      <span aria-hidden="true" class="text-white">&times;</span>
    </button>
  </div>
  <div class="toast-body">Hello, world! This is a toast message.</div>
</div>

To show a "snack" (a small version of the toast), simply omit the content property:

$.toast({
  title: 'A small bitesize snack, not a toast!',
  type: 'info',
  delay: 5000
});

Example Snack

Now, onto the different types:

Example #2

An 'info' toast

Example #3

A 'success' toast

Example #4

A 'warning' toast

Example #5

An 'error' toast

The toasts are stackable:

Example #6

Caveats

  • ~~The toast will remain in the DOM when hidden, I am working on a way to incorperate removing them from the DOM or reusing existing ones if left in, however, for the time being, you can use the following to remove the toast once it is hidden from the DOM:~~ - As of 2019-03-16, the toasts will be removed automatically from the DOM.
$('body').on('hidden.bs.toast', '.toast', function () {
  $(this).remove();
});

Roadmap

  • ~~Allow img in toast as is shown in the Bootstrap 4 documentation~~ - 2019-03-16
  • Allow the option to prevent stacking
  • ~~Autoremove toast from DOM once hidden~~ - 2019-03-16
  • Custom styling (rounded toasts, blocky toasts, custom background colours)
  • Positioning of the actual toast

Contributing

I am open to contributions and you could contribute in many ways:

  • Request features
  • Submit bug reports
  • Submit pull requests
  • Help by answering issues
  • Tell us if you are using the plugin and the project

The minifier that is used is: https://closure-compiler.appspot.com/home