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 🙏

© 2025 – Pkg Stats / Ryan Hefner

fp-dom-alert

v1.1.2

Published

JS library, create alert using the fp-dom-tool module

Downloads

34

Readme

fp-dom-alert

Library that helps you create HTML Alert.

Installation

You need node.js and npm and fp-dom-tool.

npm install fp-dom-alert

import _tool from "fp-dom-tool"; // opt.
import _alert from "fp-dom-alert"; // lib fp-dom-alert

const _export = {
  _alert,
  _alertDanger,
  _alertSuccess,
  _alertWarning,
  _createAlertStyle,
  _setStyle,
};

export default _export;

To export the Style

  • In you config.webpack.js:
module: {
  rules: [
    {
      test: /\.css$/,
      use: [
        {
          loader: "style-loader",
        },
        {
          loader: "css-loader",
          options: {
            modules: true,
          },
        },
      ],
    },
  ];
}
  • In you scss or css file:
@import "fp-dom-alert/lib/index.css";

Usage

  • You need to create an html container with a class ._message. You can use the function _createElement from the fp-dom-tool package.
const _messageContainer = _tool._createElement("div")(["class", "_message"]);
  • Create an alert with the function _alert. The function required two arguments: an alert type and and content. The package has 3 alert pre-created.
const _alertDanger = _alert._alert("danger");
const _alertSuccess = _alert._alert("success");
const _alertWarning = _alert._alert("warning");
  • You then append all you alert to the ._message container by using the function _appendElement.
const appendMessageContainer = _tool._appendElement(_messageContainer);
appendMessageContainer(
  _alert._alertDanger("Something is wrong"),
  _alert._alertWarning("Better be carefull"),
  _alert._alertSuccess("All is fine now")
);
  • The ._message container is by default on display:none. You can use the function _switchElementDisplay from the from the fp-dom-tool package. Everytime the _switchElementDisplay is used the element changes state from display:none to display:block.
const _switchAlertDisplay = _tool._switchElementDisplay(_messageContainer);
_switchAlertDisplay(); // display:block
_switchAlertDisplay(); // display:none

Style

Each pre-created alert has the following style:

@import url("https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,200;0,300;0,400;0,700;1,200;1,300;1,400;1,700&display=swap");
$message-danger: #f8d7d9;
$message-success: #d4edd9;
$message-warning: #fff3cd;

@mixin message($color) {
  background-color: $color;
  border-color: darken($color, 50);
  color: darken($color, 50);
}

._message {
  display: none;

  &__container {
    padding: 0.6rem;
    border: 2px solid #000;
    border-radius: 0.3em;
    font-family: "Montserrat", sans-serif;
    font-size: 1.1rem;
    margin: 0.3rem 0;
  }
  &--danger {
    @include message($message-danger);
  }
  &--success {
    @include message($message-success);
  }
  &--warning {
    @include message($message-warning);
  }
}

Changing style

Direclty in css

You can overide the predifined with yours by creating your own style.

By using the library

You can also use the function _createAlertStyle from this package. First you need to create an object that will overide the _AlertCss object. The _AlertCss has the following property:

const _AlertCss = {
  padding: ".6rem",
  border: "2px solid #000",
  borderRadius: "0.3em",
  fontFamily: "'Montserrat', sans-serif",
  fontSize: "1.1rem",
  margin: "0.3rem 0",
  backgroundColor: "#fff",
  borderColor: "#000",
  color: "#000",
};

You can't add additional property to the object. Any property not listed in the _AlertCss won't be added.

const newStyle = {
  backgroundColor: "#9da3d8",
  color: "#2835ad",
  borderColor: "#2835ad",
};

const alertInfoStyle = _alert._createAlertStyle(newStyle);

You can then use the function _setStyle to set the new style to a given element.

const dangerAlert = _tool._getElementClass("_message--danger");
_alert._setStyle(dangerAlert)(dangerStyle);

Example

// Create the div ._message container that will contain all the alerts.
const _messageContainer = _tool._createElement("div")(["class", "_message"]);
const appendMessageContainer = _tool._appendElement(_messageContainer);

// Create a new type of alert: alertinfo
const alertInfo = _alert._alert("info");

// Add a message to the newly alertinfo and append it to the div ._message container.
appendMessageContainer(alertInfo("Fun Fact: I'm an info"));

//creste a new style with the element you wish to override.
const newStyle = {
  backgroundColor: "#9da3d8",
  color: "#2835ad",
  borderColor: "#2835ad",
};

// create a new object style
const alertInfoStyle = _createAlertStyle(newStyle);

// get the alert alertInfo in the dom and set the new style
const info = _tool._getElementClass("_message--info");
_setStyle(info)(alertInfoStyle);

// display the alert
_switchAlertDisplay(); // display:block

The alert now is now created.