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

@miraidesigns/alert

v1.0.0

Published

Mirai Designs Framework: Alert module

Downloads

4

Readme

Alerts

Alerts display an important message to the user fixed to the top of the screen.


HTML

Make sure to put this as high in your <body> element as possible.

<div id="alert" class="mdf-alert" role="alert">
    <div class="mdf-alert__content">
        <svg class="mdf-icon" viewBox="0 0 24 24" aria-hidden="true">
            <use href="icons.svg#error"></use>
        </svg>

        <span class="mdf-alert__text">This is an alert message</span>
    </div>

    <div class="mdf-alert__actions">
        <button class="mdf-button" data-alert-action="cancel">Dismiss</button>
        <button class="mdf-button" data-alert-action="confirm">Confirm</button>
    </div>
</div>

Sass

// Include default styles without configuration
@forward '@miraidesigns/alert/styles';
// Configure appearance
@use '@miraidesigns/alert' with (
    $variable: value
);

@include alert.styles();

TypeScript

import { MDFAlert } from '@miraidesigns/alert';

const alert = new MDFAlert(document.querySelector('.mdf-alert'));
alert.showAlert();

Implementation

Attributes

| Name | Element | Description | | ----------------------------- | ---------- | ----------------------------------------------------------------- | | data-alert-action="cancel" | <button> | Will execute the onCancel function when this button is clicked | | data-alert-action="confirm" | <button> | Will execute the onConfirm function when this button is clicked |

Classes

| Name | Type | Description | | -------------------- | -------------- | ---------------------------------------------------------- | | mdf-alert | Parent | Alert element | | mdf-alert--active | Modifier | 1. Prepares the alert to be visible | | mdf-alert--move-in | Modifier | 2. Moves the alert on screen and allows for interaction | | mdf-alert--filled | Modifier | Fills the alert's background with the set brand color | | mdf-alert--warning | Modifier | Fills the alert's background with the set warning color | | mdf-alert--error | Modifier | Fills the alert's background with the set error color | | mdf-alert__content | Parent / Child | Contains the alert text and actions. Child to .mdf-alert | | mdf-alert__text | Child | Alert text. Child to .mdf-alert__content | | mdf-alert__actions | Child | Alert action buttons. Child to .mdf-alert__content |

Events

| Name | Data | Description | | ----------------- | ------ | ------------------------------------ | | MDFAlert:opened | null | Fires once the alert has been opened | | MDFAlert:closed | null | Fires once the alert has been closed |

Properties

| Name | Type | Description | | -------------------- | ----------------- | --------------------------------------- | | .alert | HTMLElement | Returns the alert element | | .message | string | Get or set the alert's text message | | .showAlert(delay?) | (number): void | Show the alert, optionally with a delay |

Options

| Name | Type | Default | Description | | ----------- | ------------ | ------- | --------------------------------------------- | | onOpen | () => void | null | Function will run when the alert is opened | | onConfirm | () => void | null | Function will run when the alert is confirmed | | onCancel | () => void | null | Function will run when the alert is dismissed |