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

@miraidesigns/alert

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@miraidesigns/alert

Mirai Designs Framework: Alert module

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
increased by100%
Maintainers
1
Weekly downloads
 
Created
Source

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

NameElementDescription
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

NameTypeDescription
mdf-alertParentAlert element
mdf-alert--activeModifier1. Prepares the alert to be visible
mdf-alert--move-inModifier2. Moves the alert on screen and allows for interaction
mdf-alert--filledModifierFills the alert's background with the set brand color
mdf-alert--warningModifierFills the alert's background with the set warning color
mdf-alert--errorModifierFills the alert's background with the set error color
mdf-alert__contentParent / ChildContains the alert text and actions. Child to .mdf-alert
mdf-alert__textChildAlert text. Child to .mdf-alert__content
mdf-alert__actionsChildAlert action buttons. Child to .mdf-alert__content

Events

NameDataDescription
MDFAlert:openednullFires once the alert has been opened
MDFAlert:closednullFires once the alert has been closed

Properties

NameTypeDescription
.alertHTMLElementReturns the alert element
.messagestringGet or set the alert's text message
.showAlert(delay?)(number): void Show the alert, optionally with a delay

Options

NameTypeDefaultDescription
onOpen() => voidnullFunction will run when the alert is opened
onConfirm() => voidnullFunction will run when the alert is confirmed
onCancel() => voidnullFunction will run when the alert is dismissed

Keywords

FAQs

Package last updated on 13 Jul 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