1.0.1 • Published 9 months ago

@dakataa/bootstrap-alert v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

Bootstrap Alert

This library is Bootstrap Framework extension that helps you to create beautiful Alert and Confirm popups, based on Bootstrap Modals.

How to install

Using npm:

npm install @dakataa/bootstrap-alert

Using yarn:

yarn add @dakataa/bootstrap-alert

How to use it

1. Import the library

import Alert, {Icon} from "@dakataa/bootstrap-alert";

2. Create Alert Instance and show it

const config = {
	title: 'Well done!',
	icon: Icon.success
};

const instance = new Alert(config);
instance.show().then((result) => {
	console.log('successed', result);
}).catch((result) => {
	console.log('cancelled or denied', result)
});

Configuration

KeyRequiredTypeDefaultDescription
titleYesstringNoText or HTML
textNostringnullText or HTML
iconNoIcon Enum, Promise or stringnullAnimated Lottie Icon
animationNoAnimation Enum or stringAnimation.scale
sizeNoSize Enum or stringSize.small (sm)Popup size
actionsNoObject (key: Action)nullAction Buttons
allowCloseNoBooleanfalsePreventing the Popup from closing except if there is no actions defined
timeoutNoIntegernullAutomatically closing after number of milliseconds
timeoutProgressNoBooleanfalseDisplay Timeout Progress bar

Methods

MethodReturnDescription
showPromiseDisplay popup based on configuration
hidevoidHide popup
getHTMLElementHTMLElement or undefinedReturns Modal HTML Element
getBootstrapModalInstanceBootstrap Modal instance or undefined

Icon Enum

Icon Enum is an object contains import Promises of default Lottie Animations.

KeyDescription
successSuccess animation
deniedDenied Animation
warningWarning Animation
successSuccess Animation

How to use it

import {Icon} from "@dakataa/bootstrap-alert";

new Alert({title: 'Success', icon: Icon.success}).show();

How to use custom icon

const customIconAnimation = import('path/to/lottie.json');

new Alert({title: 'Custom Icon Animation', icon: customAnimation}).show();

or

new Alert({title: 'Custom Icon Animation', icon: 'public/path/to/lottie.json'}).show();

Examples

TODO