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

@jfortunato/important-notice

v1.0.0

Published

This is a simple web component that you can use to quickly add an alert to your site.

Downloads

4

Readme

Important Notice Web Component

This is a simple web component that you can use to quickly add an alert to your site.

Basic Usage

Simply add this code anywhere within the body of your html.

<script src="/path/to/this/file/important-notice.js" async></script>
<important-notice heading="Attention!" always-show showstopper>
    Please change this message to alert your site visitors of an important notice!
</important-notice>

Advanced Usage

Corner notification

Just remove the showstopper property for a more subtle alert.

<script src="/path/to/this/file/important-notice.js" async></script>
<important-notice heading="Attention!" always-show>
    Please change this message to alert your site visitors of an important notice!
</important-notice>

Showstopper w/ link

You can optionally include a button that will link to a different page.

<script src="/path/to/this/file/important-notice.js" async></script>
<important-notice heading="Attention!" always-show showstopper link-href="https://example.com" link-label="Click Me" link-color="#09093d">
    Please change this message to alert your site visitors of an important notice!
</important-notice>

Creation with javascript

Instead of creating the alert with HTML you could opt to create it using javascript. One potential use-case would be for managing the notice using Google Tag Manager.

<script>
(function () {
       // Configure these options
       var HEADING = 'Attention!';
       var MESSAGE = 'Please change this message to alert your site visitors of an important notice!';
       var ALWAYS_SHOW = true;
       var IS_SHOWSTOPPER = true;

       // No need to touch anything below here.
       function appendScript(src) {
           var script = document.createElement('script');
           script.src = src;
           document.body.appendChild(script);
       };
       function appendNotice() {
           var notice = document.createElement('important-notice');
           notice.setAttribute('heading', HEADING);
           if (ALWAYS_SHOW === true) notice.setAttribute('always-show', true);
           if (IS_SHOWSTOPPER === true) notice.setAttribute('showstopper', true);
           notice.innerHTML = MESSAGE;
           document.body.appendChild(notice);
       };
       appendScript('./important-notice.js');
       appendNotice();
   })();
</script>

Properties

Name | Description ---- | ----------- heading | The heading of the notice. always-show | If omitted, then the notice will not be shown again during the current browsing session. showstopper | There are 2 types of notices:The "showstopper" will display what is commonly referred to as a "modal" or "dialog".The other type will simply display a notice in the corner of the page. link-label | Optional label to use for an external link button. link-href | Optional href to use for an external link button. link-color | Optional color to use for an external link button. Defaults to a gray background.