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

v1.0.1

Published

Mirai Designs Framework: Dialog module

Downloads

5

Readme

Dialogs

Dialogs inform users about a task or action they need to take.


HTML

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

<div class="mdf-dialog-container" aria-hidden="true">
	<div class="mdf-dialog" role="dialog" aria-labelledby="dialog-title" aria-describedby="dialog-desc">
		<div class="mdf-dialog__header">
			<h2 id="dialog-title" class="mdf-dialog__title">Dialog title</h2>

			<button class="mdf-dialog__close" aria-label="Close dialog">
				<svg class="mdf-icon" viewBox="0 0 24 24" aria-hidden="true">
					<use href="icons.svg#clear"></use>
				</svg>
			</button>
		</div>

		<div class="mdf-dialog__content">
			<p id="dialog-desc">Dialog description further explaining the actions.</p>
		</div>

		<div class="mdf-dialog__actions">
			<button class="mdf-button" data-dialog-action="cancel">Cancel</button>
			<button class="mdf-button" data-dialog-action="confirm">Confirm</button>
		</div>
	</div>

	<div class="mdf-dialog-backdrop"></div>
</div>

Sass

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

@include dialog.styles();

TypeScript

import { MDFDialog } from '@miraidesigns/dialog';

const dialog = new MDFDialog(document.querySelector('.mdf-dialog'));
dialog.openDialog();

Implementation

Attributes

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

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

Classes

| Name | Type | Description | | ---------------------- | -------------- | ------------------------------------------------------------------------------- | | mdf-dialog-container | Parent | Contains the dialog element. Creates the backdrop and centers the dialog | | mdf-dialog--active | Modifier | 1. Prepares the dialog to be visible | | mdf-dialog--fade-in | Modifier | 2. Fades-in the dialog and allows for interaction | | mdf-dialog | Parent / Child | Contains the dialog elements. Child to .mdf-dialog-container | | mdf-dialog__header | Parent / Child | Contains the dialog title. Child to .mdf-dialog | | mdf-dialog__close | Child | Closes the dialog. Child to .mdf-dialog__header | | mdf-dialog__title | Child | Title element. Child to .mdf-dialog__header | | mdf-dialog__content | Parent / Child | Contains the text description or other kinds of content. Child to .mdf-dialog | | mdf-dialog__actions | Parent / Child | Contains the user actions. Child to .mdf-dialog | | mdf-dialog-backdrop | Child | Dialog backdrop. Child to .mdf-dialog-container |

Events

| Name | Data | Description | | ------------------ | ------ | ---------------------------- | | MDFDialog:opened | null | Fires when the dialog opens | | MDFDialog:closed | null | Fires when the dialog closes |

Properties

| Name | Type | Description | | ---------------------------------- | -------------------------- | ----------------------------------------------------------------------- | | .container | (): HTMLElement | Returns the dialog container element | | .dialog | (): HTMLElement | Returns the dialog element | | .content | (): HTMLElement | Returns the content element | | .text | (): HTMLParagraphElement | Returns the text element | | .openDialog(message?, setFocus?) | (string, boolean): void | Open the dialog window (set displayed message, set focus on first item) | | .closeDialog(confirmed?) | (boolean): void | Close the dialog window (run confirm or cancel callback) |

Options

| Name | Type | Default | Description | | ------------- | ------------ | ------- | --------------------------------------------------------------- | | onOpen | () => void | null | Function will run when the dialog is opened | | onConfirm | () => void | null | Function will run when the dialog window is confirmed | | onCancel | () => void | null | Function will run when the dialog window is closed or cancelled | | hideOnClick | boolean | true | Dialog will be hidden when clicked outside of it's content |