Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

snap-dialog-js

Package Overview
Dependencies
Maintainers
0
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

snap-dialog-js

SnapDialog is a versatile JavaScript plugin offering customizable prompt boxes and notification dialog alerts. Capture user input or deliver dynamic notifications with ease. Its intuitive API and flexible options ensure smooth integration, enhancing user

  • 1.0.5
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
82
increased by2633.33%
Maintainers
0
Weekly downloads
 
Created
Source

SnapDialog Plugin Documentation

Overview

SnapDialog is a versatile JavaScript plugin offering customizable prompt boxes and notification dialog alerts. Capture user input or deliver dynamic notifications with ease. Its intuitive API and flexible options ensure smooth integration, enhancing user interaction while combining simplicity with power.

Features

  • Customizable notification types: success, error, warning, info, html
  • Input field support: Allows input within dialogs
  • Progress bar support: Option to include a progress bar that tracks the duration before auto-close
  • RTL support: Right-to-left text support
  • Dark mode: Option to toggle between light and dark modes
  • Sizing options: Multiple Size for displaying dialog
  • Animation options: Various animations for notification appearance
  • Event handlers: Custom actions for confirm, cancel, and close events
  • Custom icons: Ability to define custom icons for each notification type

Installation

Here's how to use SnapDialog in your project:

Installation via CSS

Include the stylesheet on your document's </head> tag.

<head>
  <link rel="stylesheet" href="snap-dialog.css">
  <!-- Or -->
  <link rel="stylesheet" href="snap-dialog.min.css">
</head>

Instead of installing you may use the remote version.

<head>
  <link rel="stylesheet"
  href="https://cdn.jsdelivr.net/npm/snap-dialog-js@latest/dist/snap-dialog.css">
  <!-- Or -->
  <link rel="stylesheet"
  href="https://unpkg.com/snap-dialog-js@latest/dist/snap-dialog.min.css">
</head>

Installation via Javscript

Include the Plugin on your document's before </body> tag.

  <script src="/snap-dialog.js"></script>
  <!-- Or -->
  <script src="/snap-dialog.min.js"></script>

Instead of installing you may use the remote version.

  <script src="https://cdn.jsdelivr.net/npm/snap-dialog-js@latest/dist/snap-dialog.js"></script>
  <!-- Or -->
  <script src="https://unpkg.com/snap-dialog-js@latest/dist/snap-dialog.min.js"></script>

`

Usage

Basic Notification

SnapDialog().success('Success Title', 'This is a success message.');

Error Notification

SnapDialog().error('Error Title', 'This is an error message.');

Info Notification

SnapDialog().info('Info Title', 'This is an information message.');

Warning Notification

SnapDialog().warning('Warning Title', 'This is a warning message.');

Custom HTML Content

SnapDialog().html('<div><h3>Custom HTML</h3><p>This is a custom HTML dialog.</p></div>');

Configuring Options

You can configure global options for the plugin:

SnapDialog().SnapDialogOptions({
    rtl: true,
    isDark: true,
    autoClose : true,
    duration: 5000
});

Confirm and Cancel Example

You can handle confirm and cancel actions within a dialog:

SnapDialog().alert('Confirm Action', 'Are you sure?', {
    enableConfirm: true,
    onConfirm: function() {
        console.log('Confirmed');
    },
    enableCancel: true,
    onCancel: function() {
        console.log('Cancelled');
    }
});

Custom Input

You can create dialogs that include input fields:

SnapDialog().alert('Input Dialog', 'Please enter your name:', {
    input: 'text',
    inputPlcaeholder: 'Your name',
    enableConfirm: true,
    onConfirm: function(inputValue) {
        console.log('Input value:', inputValue);
    }
});

Clear All Notifications

SnapDialog().clearAll();

Available Options

OptionTypeDefaultDescription
rtlbooleanfalseEnables right-to-left text alignment.
typestringnullNotification type (success, error, warning, info).
titlestring'Default Title'Title for the notification.
messagestring'This is a default message'Message for the notification.
iconstringnullIcon to display.
customIconstringnullCustom icon in HTML format.
confirmTextstring'OK'Text for the confirm button.
enableConfirmbooleantrueEnables confirm button.
onConfirmfunctionfunction() {}Callback function when confirm is clicked.
onCancelfunctionfunction() {}Callback function when cancel is clicked.
enableCancelbooleanfalseEnables cancel button.
cancelTextstring'Cancel'Text for the cancel button.
enableCloseHandlerbooleanfalseEnables a custom close handler when the dialog is closed.
onClosefunctionfunction() {}Callback function when the dialog is closed.
clickToClosebooleanfalseAllows clicking "close button" to close it.
OutsideClosebooleanfalseAllows clicking outside the dialog to close it.
autoClosebooleanfalseAutomatically closes the dialog after the specified duration.
durationnumber3000Duration before auto-close (in milliseconds).
preogressBarbooleanfalseShows a progress bar for the duration.
isDarkbooleanfalseEnables dark mode for the dialog.
animationstring'slide'Animation style (slide, fade, zoom).
inputstringnullType of input field (text, number, email, etc.).
inputPlcaeholderstring''Placeholder for the input field.
inputMaskstringnullMask for the input field.
sizestringnullDialog size (sm, md, lg, xl, 2xl, 3xl, 4xl).

License

This plugin is open-source and available under the MIT License.

Keywords

FAQs

Package last updated on 16 Oct 2024

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