Lightweight notification module for websites
Install package
npm install codex-notifier --saveyarn add codex-notifierconst notifier = require('codex-notifier');import notifier from 'codex-notifier';
import {ConfirmNotifierOptions, NotifierOptions, PromptNotifierOptions} from 'codex-notifier';Module has only one public method β show.
You should pass there object with notification properties
messageβ notification message (can contains HTML)typeβ type of notification:alert,confirmorprompt.Alertby defaultstyleβ just add'cdx-notify--' + styleclass. We have some default styles:successanderrortimeβ notification expire time in ms. Only foralertnotifies expires (8s by default)
okTextβ text for confirmation button (Confirm by default)cancelTextβ text for cancel button (Cancel by default)okHandlerβ fires when Confirm button was pressedcancelHandlerβ fires when Cancel button was pressed or notification was closed
okTextβ text for submit button (Ok by default)okHandlerβ fires when submit button was pressed. Gets input's value as a parametercancelHandlerβ fires when notification was closedplaceholderβ input placeholderdefaultβ input default valueinputTypeβ type of input (text by default)
notifier.show({
message: 'Refresh the page'
})notifier.show({
message: 'Message was sent',
style: 'success',
time: 5000
})notifier.show({
message: 'Sorry, server is busy now',
style: 'error'
})notifier.show({
message: 'Delete account?',
type: 'confirm',
okText: 'Yes',
cancelText: 'Oh, wait',
okHandler: account.delete
})notifier.show({
message: 'Enter your email',
type: 'prompt',
okText: 'Enter',
okHandler: checkEmail,
inputType: 'email',
placeholder: 'team@ifmo.su'
})You can easily customize notifications appearance. Read more about it here




