New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@miraidesigns/dialog

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@miraidesigns/dialog

Mirai Designs Framework: Dialog module

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

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.

NameElementDescription
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

NameTypeDescription
mdf-dialog-containerParentContains the dialog element. Creates the backdrop and centers the dialog
mdf-dialog--activeModifier1. Prepares the dialog to be visible
mdf-dialog--fade-inModifier2. Fades-in the dialog and allows for interaction
mdf-dialogParent / ChildContains the dialog elements. Child to .mdf-dialog-container
mdf-dialog__headerParent / ChildContains the dialog title. Child to .mdf-dialog
mdf-dialog__closeChildCloses the dialog. Child to .mdf-dialog__header
mdf-dialog__titleChildTitle element. Child to .mdf-dialog__header
mdf-dialog__contentParent / ChildContains the text description or other kinds of content. Child to .mdf-dialog
mdf-dialog__actionsParent / ChildContains the user actions. Child to .mdf-dialog
mdf-dialog-backdropChildDialog backdrop. Child to .mdf-dialog-container

Events

NameDataDescription
MDFDialog:openednullFires when the dialog opens
MDFDialog:closednullFires when the dialog closes

Properties

NameTypeDescription
.container(): HTMLElementReturns the dialog container element
.dialog(): HTMLElementReturns the dialog element
.content(): HTMLElementReturns the content element
.text(): HTMLParagraphElementReturns the text element
.openDialog(message?, setFocus?)(string, boolean): voidOpen the dialog window (set displayed message, set focus on first item)
.closeDialog(confirmed?)(boolean): voidClose the dialog window (run confirm or cancel callback)

Options

NameTypeDefaultDescription
onOpen() => voidnullFunction will run when the dialog is opened
onConfirm() => voidnullFunction will run when the dialog window is confirmed
onCancel() => voidnullFunction will run when the dialog window is closed or cancelled
hideOnClickbooleantrueDialog will be hidden when clicked outside of it's content

Keywords

FAQs

Package last updated on 06 Aug 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc