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

mil-toast

v1.1.0

Published

Toast notifications Webcomponent following open-wc recommendations

Downloads

22

Readme

<mil-toast>

'mil-toast' is toast notification webcomponent .

This webcomponent follows the open-wc recommendation.

See it in action on Stackblitz: https://stackblitz.com/edit/mil-toast-example?file=index.js

Installation

npm i mil-toast

Usage

<script type="module">
  import 'mil-toast/mil-toast.js';
</script>

<mil-toast></mil-toast>

Styling

Use customs CSS properties for styling.

| CSS property | Definition | | -------------------------- | --------------------------------- | | --success-icon-box-color | success icon background color | | --success-text-box-color | success text box background color | | --success-text-color | success text and icon color |

Customs properties for 'danger', 'warning' and 'info' are available with the same pattern.

Methods

Toasts are managed by customs events.

/* Show a toast for 6 seconds */
this.dispatchEvent(
  new CustomEvent("openToast", {
    bubbles: true,
    composed: true,
    detail: {
      toastText: "Show me a toast",
      toastClass: "info"
    }
  })
);

toastClass are 'info', 'warning', 'danger' and 'success'

Toasts will remain open for 6s and close-off.

To show Toasts that remain open until a user instruction is received, do the following:

this.dispatchEvent(
  new CustomEvent("openStickyToast", {
    bubbles: true,
    composed: true,
    detail: {
      toastText: "This toast will remain open until closeStickToast is fired",
      toastClass: "warning"
    }
  })
);

to close toast:

this.dispatchEvent(
  new CustomEvent("closeStickyToast", {
    bubbles: true,
    composed: true,
    detail: {
      toastText: "This toast will remain open until closeStickToast is fired",
      toastClass: "warning"
    }
  })
);

Toasts can also be closed from a tap event. 2 options are available: reload or close.

this.dispatchEvent(
  new CustomEvent("openStickyToast", {
    bubbles: true,
    composed: true,
    detail: {
      toastText: "This toast will remain open until closeStickToast is fired",
      toastClass: "warning",
      reload: true,
      close: true
    }
  })
);

reload: true makes the toast clickable and generates a page reload. close: true shows a close button.

*** In all cases, toastText must be identical in both open and close events.

Linting with ESLint, Prettier, and Types

To scan the project for linting errors, run

npm run lint

You can lint with ESLint and Prettier individually as well

npm run lint:eslint
npm run lint:prettier

To automatically fix many linting errors, run

npm run format

You can format using ESLint and Prettier individually as well

npm run format:eslint
npm run format:prettier

Local Demo with es-dev-server

npm start

To run a local development server that serves the basic demo located in demo/index.html

npm start:compatibility

To run a local development server in compatibility mode for older browsers that serves the basic demo located in demo/index.html