Skip to content

Ultra lightweight, dependency-free javascript library for creating dynamic & full-customizable modal dialogs.

Notifications You must be signed in to change notification settings

ksroga/FrostifyModal

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FrostifyModal.js

License

Ultra lightweight, dependency-free javascript library for creating dynamic & full-customizable modal dialogs.

Features

✔ Full-customizable styles

✔ Closes modal dialog on overlay click

✔ Closes modal dialog on pressing the ESC key

✔ Pressing TAB is working inside the modal.

✔ Ultra lightweight - it's only ~9kb!

Installation

via npm

npm i frostify-modal

Usage

Example usage:

FrostifyModal.set({
    title: 'Modal title',
    content: 'Text content',
    onok: () => {
        alert('Clicked ok button');
        return false; // do not close modal
    },
    oncancel: () => {
        alert('Clicked cancel button');
    },
    labels: {
        ok: 'Okay!',
        cancel: 'Cancel'
    }
}).show();

Available methods:

Method nameArgumentsDescription
set()Empty stringModal title.

Available config parameters:

NameDefault valueDescription
titleEmpty stringModal title.
contentEmpty stringModal content.
onOknullSubmit action callback.
onCancelnullCancel action callback.
isClosable trueDefines if modal is closable.
isDraggable trueDefines if modal is draggable.
reverseButtons falseIf true buttons are reversed.
labels ok: Okay
cancel: Cancel
Define button labels.
containerStylesEmpty objectContains modal container styles. You can use any css styles here.
headerStyles Empty objectContains modal header styles. You can use any css styles here.
bodyStyles Empty objectContains modal body styles. You can use any css styles here.
footerStyles Empty objectContains modal footer styles. You can use any css styles here.
buttonsStyles Empty objectContains modal buttons styles. You can use any css styles here.

Example with all availables configuration parameters:

FrostifyModal.set({
    title: 'Modal title',
    content: 'Text content',
    onok: () => {
        alert('Clicked ok button');
        return false; // do not close modal
    },
    oncancel: () => {
        alert('Clicked cancel button');
    },
    labels: {
        ok: 'Okay!',
        cancel: 'Cancel'
    },
    isClosable: true,
    isDraggable: true,
    reverseButtons: false,
    containerStyles: {
        radius: '25px',
    },
    headerStyles: {
        background: '#FFFFFF',
        color: '#000000',
        textAlign: 'left',
    }
}).show();

Licensing

This project is licensed under MIT license.

Created and maintained by

Konrad Sroga – @ksroga 🇵🇱

About

Ultra lightweight, dependency-free javascript library for creating dynamic & full-customizable modal dialogs.

Resources

Stars

Watchers

Forks

Contributors 2

  •  
  •