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/snackbar

v1.0.0

Published

Mirai Designs Framework: Snackbar module

Downloads

4

Readme

Snackbars

Snackbars show a quick message at the bottom of the screen.


HTML

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

<div class="mdf-snackbar" role="status" aria-live="polite">
    <span class="mdf-snackbar__text">This is a preview text message</span>

    <div class="mdf-snackbar__actions">
        <button class="mdf-button" data-snackbar-action="action">Action</button>

        <button class="mdf-snackbar__close" data-snackbar-action="close" aria-label="Dismiss snackbar">
            <svg class="mdf-icon" viewBox="0 0 24 24" aria-hidden="true">
                <use href="icons.svg#clear"></use>
            </svg>
        </button>
    </div>
</div>

Sass

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

@include snackbar.styles();

TypeScript

import { MDFSnackbar } from '@miraidesigns/snackbar';

const snackbar = new MDFSnackbar(document.querySelector('.mdf-snackbar'));
snackbar.showSnackbar();

Implementation

Attributes

Please see the WAI-ARIA page for attributes and best practices regarding status messages.

| Name | Element | Description | | ------------------------------- | ---------- | ---------------------------------------------------------------- | | data-snackbar-action="action" | <button> | Will execute the onAction function when this button is clicked | | data-snackbar-action="close" | <button> | Will execute the onClose function when this button is clicked |

Classes

| Name | Type | Description | | ----------------------- | -------------- | --------------------------------------------------------------- | | mdf-snackbar | Parent | Contains the snackbar elements | | mdf-snackbar--active | Modifier | Fades-in and moves the snackbar on-screen | | mdf-snackbar__text | Child | Holds the snackbar text message. Child to .mdf-snackbar | | mdf-snackbar__actions | Parent / Child | Holds the action and close button. Child to .mdf-snackbar | | mdf-snackbar__action | Child | Executes the supplied action. Child to .mdf-snackbar__actions | | mdf-snackbar__close | Child | Dismisses the snackbar. Child to .mdf-snackbar__actions |

Events

| Name | Data | Description | | -------------------- | ------ | ------------------------------ | | MDFSnackbar:opened | null | Fires when the snackbar opens | | MDFSnackbar:closed | null | Fires when the snackbar closes |

Properties

| Name | Type | Description | | ------------------------- | ---------------- | ---------------------------------------------------- | | .message | string | Get or set the snackbar text message | | .snackbar | HTMLElement | Returns the snackbar element | | .isActive() | (): boolean | Returns wether or not the sidebar is active | | .snowSnackbar(message?) | (string): void | Show the snackbar, optionally with the given message |

Options

| Name | Type | Default | Description | | ----------- | ------------ | ------- | -------------------------------------------------------------------------- | | delay | number | 5000 | The amount of time that has to pass before the snackbar disappears (in ms) | | onOpen | () => void | null | Function will run when the snackbar is opened | | onAction | () => void | null | Function will run when the action button is activated | | onClose | () => void | null | Function will run when the snackbar is closed by the user | | hideOnESC | boolean | true | Hide the snackbar when the ESC key is pressed |