Code Monkey home page Code Monkey logo

notiflix / notiflix Goto Github PK

View Code? Open in Web Editor NEW
613.0 613.0 53.0 1.36 MB

Notiflix is a pure JavaScript library for client-side non-blocking notifications, popup boxes, loading indicators, and more that makes your web projects much better.

Home Page: https://notiflix.github.io

License: MIT License

CSS 7.51% JavaScript 86.54% TypeScript 5.95%
alert angular-notification block-elements block-ui confirm javascript-alert javascript-confirm loading loading-indicators nextjs-notifications notification notifications notiflix notify popup-box popup-boxes react-notifications toast

notiflix's Introduction

Notiflix

Notiflix


NPM Version Known Vulnerabilities TypeScript Downloads jsDelivr Size License

Notiflix

Notiflix is a pure JavaScript library for client-side non-blocking notifications, popup boxes, loading indicators, and more that makes your web projects much better.

Current Version

3.2.7 *

Browser Compatibility

Chrome || Firefox || Safari || Edge || Opera || * Edge Legacy || * IE 10+

* SVG animations are not supported.


Documentation

https://notiflix.github.io/documentation

Modules (Demo/Playground)


(A) Install and Import

Install

yarn

yarn add notiflix

npm

npm i notiflix

Import

// all modules
import Notiflix from 'notiflix';

// one by one
import { Notify } from 'notiflix/build/notiflix-notify-aio';
import { Report } from 'notiflix/build/notiflix-report-aio';
import { Confirm } from 'notiflix/build/notiflix-confirm-aio';
import { Loading } from 'notiflix/build/notiflix-loading-aio';
import { Block } from 'notiflix/build/notiflix-block-aio';

(B) Add to an HTML page (Global)

CSS and JS

<link rel="stylesheet" href="dist/notiflix-3.2.7.min.css" />

<script src="dist/notiflix-3.2.7.min.js"></script>

or only JS (All in One - Internal CSS)

<script src="dist/notiflix-aio-3.2.7.min.js"></script>

or only Modules JS (All in One - Internal CSS)

<script src="dist/notiflix-notify-aio-3.2.7.min.js"></script>

<script src="dist/notiflix-report-aio-3.2.7.min.js"></script>

<script src="dist/notiflix-confirm-aio-3.2.7.min.js"></script>

<script src="dist/notiflix-loading-aio-3.2.7.min.js"></script>

<script src="dist/notiflix-block-aio-3.2.7.min.js"></script>

Usage

1- Notify Module

Notiflix Notify module can be used to send non-blocking alerts/notifications. This module includes 4 types of notifications: "Success", "Failure", "Warning", and "Info".

/*
* @param1 {string}: Required, a text in string format.
* @param2 {function | Object}: Optional, a callback function that will be called when the notification element has been clicked. Or, extending the initialize options with the new options for each notification element.
* @param3 {Object}: Optional, extending the initialize options with new the options for each notification element. (If the second parameter has been already used for a callback function.)
*/

// e.g. Only message
Notiflix.Notify.success('Sol lucet omnibus');

Notiflix.Notify.failure('Qui timide rogat docet negare');

Notiflix.Notify.warning('Memento te hominem esse');

Notiflix.Notify.info('Cogito ergo sum');

// e.g. Message with a callback
Notiflix.Notify.success(
  'Click Me',
  function cb() {
    // callback
  },
);

// e.g. Message with the new options
Notiflix.Notify.success(
  'Click Me',
  {
    timeout: 6000,
  },
);

// e.g. Message with callback, and the new options
Notiflix.Notify.success(
  'Click Me',
  function cb() {
    // callback
  },
  {
    timeout: 4000,
  },
);

------------------------------------

2- Report Module

Notiflix Report module can be used to show extended notifications that contain a title, description, and button(with a callback function). This module includes 4 types of notifications: "Success", "Failure", "Warning", and "Info".

/*
* @param1 {string}: Required, title text in string format.
* @param2 {string}: Required, message text in string format.
* @param3 {string}: Required, button text in string format.
* @param4 {function | Object}: Optional, a callback function that will be called when the button element has been clicked. Or, extending the initialize options with the new options for each notification element.
* @param5 {Object}: Optional, extending the initialize options with new the options for each notification element. (If the fourth parameter has been already used for a callback function.)
*/

// e.g. Only title, message, and button text
Notiflix.Report.success('Title', 'Message', 'Button Text');

Notiflix.Report.failure('Title', 'Message', 'Button Text');

Notiflix.Report.warning('Title', 'Message', 'Button Text');

Notiflix.Report.info('Title', 'Message', 'Button Text');

// e.g. With a callback
Notiflix.Report.success(
  'Title',
  'Message',
  'Button Text',
  function cb() {
    // callback
  },
);

// e.g. With the new options
Notiflix.Report.success(
  'Title',
  'Message',
  'Button Text',
  {
    width: '360px',
    svgSize: '120px',
  },
);

// e.g. With a callback, and the new options
Notiflix.Report.success(
  'Title',
  'Message',
  'Button Text',
  function cb() {
    // callback
  },
  {
    width: '360px',
    svgSize: '120px',
  },
);

------------------------------------

3- Confirm Module

Notiflix Confirm module can be used to show non-blocking confirm/prompt boxes. This module includes 3 types of prompts: "Show", "Ask", and "Prompt". An additional question can be asked within the prompt box if using the "Ask" and/or "Prompt" ones unlike the "Show" one.

Show:

This method can be used to show a confirm box with info, and take the custom actions via the callback functions.

/*
* @param1 {string}: Required, title text in string format.
* @param2 {string}: Required, message/question in string format.
* @param3 {string}: Required, OK button text in string format.
* @param4 {string}: Optional, Cancel button text in string format.
* @param5 {function}: Optional, a callback function that will be called when the OK button element has been clicked.
* @param6 {function}: Optional, a callback function that will be called when the Cancel button element has been clicked.
* @param7 {Object}: Optional, extending the initialize options with new the options for each confirm box.
*/

Notiflix.Confirm.show(
  'Notiflix Confirm',
  'Do you agree with me?',
  'Yes',
  'No',
  function okCb() {
    alert('Thank you.');
  },
  function cancelCb() {
    alert('If you say so...');
  },
  {
    width: '320px',
    borderRadius: '8px',
    // etc...
  },
);
Ask:

This method can be used to ask a question within a confirm box. The confirm box doesn't remove till the client gives the correct answer. Or, the client can click on the cancel button to close/remove the confirm box as well.

/*
* @param1 {string}: Required, title text in string format.
* @param2 {string}: Required, question text in string format.
* @param3 {string}: Required, answer text in string format.
* @param4 {string}: Required, OK button text in string format.
* @param5 {string}: Optional, Cancel button text in string format.
* @param6 {function}: Optional, a callback function that will be called when the OK button element has been clicked.
* @param7 {function}: Optional, a callback function that will be called when the Cancel button element has been clicked.
* @param8 {Object}: Optional, extending the initialize options with new the options for each confirm box.
*/

Notiflix.Confirm.ask(
  'Where is Padmé?',
  'Is she safe? Is she all right?',
  'It seems, in your anger, you killed her.',
  'Answer',
  'Cancel',
  function okCb() {
    alert('😡 NOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO!!!');
  },
  function cancelCb() {
    alert('😪 ...');
  },
  {
    // Custom options
  },
);
Prompt:

This method works similarly as window.prompt(). The client doesn't have to type a correct answer to the input element to proceed unlike the Notiflix.Confirm.ask(); method. The client answer passes to the callback functions as a parameter and this parameter is always a string.

/*
* @param1 {string}: Required, title text in string format.
* @param2 {string}: Required, question text in string format.
* @param3 {string}: Required, default answer text in string format. An empty string can be used as well.
* @param4 {string}: Required, OK button text in string format.
* @param5 {string}: Optional, Cancel button text in string format.
* @param6 {function}: Optional, a callback function that will be called when the OK button element has been clicked.
* @param7 {function}: Optional, a callback function that will be called when the Cancel button element has been clicked.
* @param8 {Object}: Optional, extending the initialize options with new the options for each confirm box.
*/

Notiflix.Confirm.prompt(
  'Hello',
  'How are you feeling?',
  'Awesome!',
  'Answer',
  'Cancel',
  function okCb(clientAnswer) {
    console.log('Client answer is: ' + clientAnswer);
  },
  function cancelCb(clientAnswer) {
    console.log('Client answer was: ' + clientAnswer);
  },
  {
    // Custom options
  },
);

------------------------------------

4- Loading Module

Notiflix Loading module can be used to show a loading indicator during a process (Fetch/XHR). Includes 6 types of animated SVG icons: "Standard", "Hourglass", "Circle", "Arrows", "Dots", and "Pulse". An additional type is "Custom", and it can be used with a custom SVG icon.

Show:

/*
* @param1 {string | Object}: Optional, a message in string format. Or, extending the initialize options with the new options for each loading indicator.
* @param2 {Object}: Optional, extending the initialize options with new the options for each loading indicator. (If the first parameter has been already used for a message.)
*/

// Only loading indicators
Notiflix.Loading.standard();
Notiflix.Loading.hourglass();
Notiflix.Loading.circle();
Notiflix.Loading.arrows();
Notiflix.Loading.dots();
Notiflix.Loading.pulse();

// Loading indicator with a message
Notiflix.Loading.standard('Loading...');

// Only loading indicator with the new options
Notiflix.Loading.standard({
  clickToClose: true,
  svgSize: '19px',
});

// Loading indicator with a message, and the new options
Notiflix.Loading.standard('Loading...', {
  backgroundColor: 'rgba(0,0,0,0.8)',
});

Change:

/*
* @param1 {string}: Required, new message in string format.
*/

Notiflix.Loading.change('Loading %20');

Remove:

/*
* @param1 {number}: Optional, milliseconds for delaying in number format.
*/

// Remove immediately
Notiflix.Loading.remove();

// Remove after delay => e.g. 1923ms
Notiflix.Loading.remove(1923);

Custom:

// Only custom loading indicator
Notiflix.Loading.custom({
  customSvgUrl: 'https://notiflix.github.io/content/media/loading/notiflix-loading-nx-light.svg',
});

// Custom loading indicator with a message
Notiflix.Loading.custom('Loading...', {
  customSvgUrl: 'https://notiflix.github.io/content/media/loading/notiflix-loading-nx-light.svg',
});


// Only custom loading indicator (A text-based SVG code)
Notiflix.Loading.custom({
  customSvgCode: '<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100">...</svg>',
});

// Custom loading indicator (A text-based SVG code) with a message
Notiflix.Loading.custom('Loading...', {
  customSvgCode: '<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100">...</svg>',
});

------------------------------------

5- Block Module

Notiflix Block module can be used to block/unblock the elements during a process (Fetch/XHR), without locking the browser or the other elements/components to prevent the user’s interactions on the blocked elements.

Block:

/*
* @param1 {string | Array<HTMLElement> | NodeListOf<HTMLElement>}: Required, CSS selector(s) that matches the element(s) | Array of HTMLElments | NodeListOf HTMLElments to block.
* @param2 {string | Object}: Optional, a blocking message in string format. Or, extending the initialize options with the new options for each block element.
* @param3 {Object}: Optional, extending the initialize options with new the options for each block element. (If the second parameter has been already used for a blocking message.)
*/

// Only indicators
Notiflix.Block.standard('.js-element');
Notiflix.Block.hourglass('.js-element');
Notiflix.Block.circle('.js-element');
Notiflix.Block.arrows('.js-element');
Notiflix.Block.dots('.js-element');
Notiflix.Block.pulse('.js-element');

// Indicator with a blocking message
Notiflix.Block.standard('.js-element', 'Please wait...');

// Only indicator with the new options
Notiflix.Block.standard('.js-element', {
  cssAnimationDuration: 1881,
  svgSize: '19px',
});

// Indicator with a blocking message, and the new options
Notiflix.Block.standard('.js-element', 'Please wait...', {
  backgroundColor: 'rgba(0,0,0,0.8)',
});

Unblock:

/*
* @param1 {string | Array<HTMLElement> | NodeListOf<HTMLElement>}: Required, CSS selector(s) that matches the element(s) | Array of HTMLElments | NodeListOf HTMLElments to unblock.
* @param2 {number}: Optional, milliseconds for delaying in number format.
*/

// Unblock immediately
Notiflix.Block.remove('.js-element');

// Unblock after delay => e.g. 1923ms
Notiflix.Block.remove('.js-element', 1923);

------------------------------------

Initialize (optional)

Notiflix.*.init function can be used to set custom options as globally.

// Notify
Notiflix.Notify.init({});

// Report
Notiflix.Report.init({});

// Confirm
Notiflix.Confirm.init({});

// Loading
Notiflix.Loading.init({});

// Block
Notiflix.Block.init({});


// e.g. Initialize the Notify Module with some options
Notiflix.Notify.init({
  width: '280px',
  position: 'right-top',
  distance: '10px',
  opacity: 1,
  // ...
});

------------------------------------

Merge (optional)

Notiflix.*.merge function can be used to deeply extend the init() options for a specific page or event globally.

// e.g. Merge the Notify Module's initialize options with some new options.
Notiflix.Notify.merge({
  width: '300px',
  // ...
});



Options

The default options of all modules.

Notiflix Notify Module: Default Options

Notiflix.Notify.init({
  width: '280px',
  position: 'right-top', // 'right-top' - 'right-bottom' - 'left-top' - 'left-bottom' - 'center-top' - 'center-bottom' - 'center-center'
  distance: '10px',
  opacity: 1,
  borderRadius: '5px',
  rtl: false,
  timeout: 3000,
  messageMaxLength: 110,
  backOverlay: false,
  backOverlayColor: 'rgba(0,0,0,0.5)',
  plainText: true,
  showOnlyTheLastOne: false,
  clickToClose: false,
  pauseOnHover: true,

  ID: 'NotiflixNotify',
  className: 'notiflix-notify',
  zindex: 4001,
  fontFamily: 'Quicksand',
  fontSize: '13px',
  cssAnimation: true,
  cssAnimationDuration: 400,
  cssAnimationStyle: 'fade', // 'fade' - 'zoom' - 'from-right' - 'from-top' - 'from-bottom' - 'from-left'
  closeButton: false,
  useIcon: true,
  useFontAwesome: false,
  fontAwesomeIconStyle: 'basic', // 'basic' - 'shadow'
  fontAwesomeIconSize: '34px',

  success: {
    background: '#32c682',
    textColor: '#fff',
    childClassName: 'notiflix-notify-success',
    notiflixIconColor: 'rgba(0,0,0,0.2)',
    fontAwesomeClassName: 'fas fa-check-circle',
    fontAwesomeIconColor: 'rgba(0,0,0,0.2)',
    backOverlayColor: 'rgba(50,198,130,0.2)',
  },

  failure: {
    background: '#ff5549',
    textColor: '#fff',
    childClassName: 'notiflix-notify-failure',
    notiflixIconColor: 'rgba(0,0,0,0.2)',
    fontAwesomeClassName: 'fas fa-times-circle',
    fontAwesomeIconColor: 'rgba(0,0,0,0.2)',
    backOverlayColor: 'rgba(255,85,73,0.2)',
  },

  warning: {
    background: '#eebf31',
    textColor: '#fff',
    childClassName: 'notiflix-notify-warning',
    notiflixIconColor: 'rgba(0,0,0,0.2)',
    fontAwesomeClassName: 'fas fa-exclamation-circle',
    fontAwesomeIconColor: 'rgba(0,0,0,0.2)',
    backOverlayColor: 'rgba(238,191,49,0.2)',
  },

  info: {
    background: '#26c0d3',
    textColor: '#fff',
    childClassName: 'notiflix-notify-info',
    notiflixIconColor: 'rgba(0,0,0,0.2)',
    fontAwesomeClassName: 'fas fa-info-circle',
    fontAwesomeIconColor: 'rgba(0,0,0,0.2)',
    backOverlayColor: 'rgba(38,192,211,0.2)',
  },
});

Notiflix Report Module: Default Options

Notiflix.Report.init({
  className: 'notiflix-report',
  width: '320px',
  backgroundColor: '#f8f8f8',
  borderRadius: '25px',
  rtl: false,
  zindex: 4002,
  backOverlay: true,
  backOverlayColor: 'rgba(0,0,0,0.5)',
  backOverlayClickToClose: false,
  fontFamily: 'Quicksand',
  svgSize: '110px',
  plainText: true,
  titleFontSize: '16px',
  titleMaxLength: 34,
  messageFontSize: '13px',
  messageMaxLength: 400,
  buttonFontSize: '14px',
  buttonMaxLength: 34,
  cssAnimation: true,
  cssAnimationDuration: 360,
  cssAnimationStyle: 'fade', // 'fade' - 'zoom'

  success: {
    svgColor: '#32c682',
    titleColor: '#1e1e1e',
    messageColor: '#242424',
    buttonBackground: '#32c682',
    buttonColor: '#fff',
    backOverlayColor: 'rgba(50,198,130,0.2)',
  },

  failure: {
    svgColor: '#ff5549',
    titleColor: '#1e1e1e',
    messageColor: '#242424',
    buttonBackground: '#ff5549',
    buttonColor: '#fff',
    backOverlayColor: 'rgba(255,85,73,0.2)',
  },

  warning: {
    svgColor: '#eebf31',
    titleColor: '#1e1e1e',
    messageColor: '#242424',
    buttonBackground: '#eebf31',
    buttonColor: '#fff',
    backOverlayColor: 'rgba(238,191,49,0.2)',
  },

  info: {
    svgColor: '#26c0d3',
    titleColor: '#1e1e1e',
    messageColor: '#242424',
    buttonBackground: '#26c0d3',
    buttonColor: '#fff',
    backOverlayColor: 'rgba(38,192,211,0.2)',
  },
});

Notiflix Confirm Module: Default Options

Notiflix.Confirm.init({
  className: 'notiflix-confirm',
  width: '300px',
  zindex: 4003,
  position: 'center', // 'center' - 'center-top' - 'center-bottom' - 'right-top' - 'right-center' - 'right-bottom' - 'left-top' - 'left-center' - 'left-bottom'
  distance: '10px',
  backgroundColor: '#f8f8f8',
  borderRadius: '25px',
  backOverlay: true,
  backOverlayColor: 'rgba(0,0,0,0.5)',
  rtl: false,
  fontFamily: 'Quicksand',
  cssAnimation: true,
  cssAnimationDuration: 300,
  cssAnimationStyle: 'fade', // 'zoom' - 'fade'
  plainText: true,

  titleColor: '#32c682',
  titleFontSize: '16px',
  titleMaxLength: 34,

  messageColor: '#1e1e1e',
  messageFontSize: '14px',
  messageMaxLength: 110,

  buttonsFontSize: '15px',
  buttonsMaxLength: 34,
  okButtonColor: '#f8f8f8',
  okButtonBackground: '#32c682',
  cancelButtonColor: '#f8f8f8',
  cancelButtonBackground: '#a9a9a9',
});

Notiflix Loading Module: Default Options

Notiflix.Loading.init({
  className: 'notiflix-loading',
  zindex: 4000,
  backgroundColor: 'rgba(0,0,0,0.8)',
  rtl: false,
  fontFamily: 'Quicksand',
  cssAnimation: true,
  cssAnimationDuration: 400,
  clickToClose: false,
  customSvgUrl: null,
  customSvgCode: null,
  svgSize: '80px',
  svgColor: '#32c682',
  messageID: 'NotiflixLoadingMessage',
  messageFontSize: '15px',
  messageMaxLength: 34,
  messageColor: '#dcdcdc',
});

Notiflix Block Module: Default Options

Notiflix.Block.init({
  querySelectorLimit: 200,
  className: 'notiflix-block',
  position: 'absolute',
  zindex: 1000,
  backgroundColor: 'rgba(255,255,255,0.9)',
  rtl: false,
  fontFamily: 'Quicksand',
  cssAnimation: true,
  cssAnimationDuration: 300,
  svgSize: '45px',
  svgColor: '#383838',
  messageFontSize: '14px',
  messageMaxLength: 34,
  messageColor: '#383838',
});



Copyright

Copyright © 2019 - 2024 Notiflix

License

MIT license - https://opensource.org/licenses/MIT

notiflix's People

Contributors

furcan avatar notiflix avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

notiflix's Issues

SOLVED: Hide the report icon

I need to hide the icon for the Report.
I found out a workaround that setting svgSize to 0 in the report options.

Are there any other ways?

[BUG] - Icon size prop on Notify module

Hi, just found out about this library, kudos!
I looked into docs, if I understand correctly, svgSize is the prop that controls the size of internal svg icons. I am using notify module and it seems like svgSize doesn't exists on notify, it exists on other modules.

is there any other way I can control the size of icon on svg module?

Expected behavior
Need a way to change svg icon on notify.

Screenshots
image

Desktop (please complete the following information):

  • OS: MacOs
  • Browser Chrome
  • Version: latest
  • Framework: nextjs.

Additional context
PS: on the other hand I have noticed few other bugs as well, if you want I can open separate issues for them. for the time being Just writing them here:

  1. the timeout property is not working, the notification doesn't go away automatically. using showOnlyTheLastOne as a workaround for now, would be really cool if this gets a fix.
  2. when I use useFontAwesome the icons are not visible, classes are getting applied, but can't see the icon at all. Do I have to install font-awesome for this?

heres my code:

Notify.success("Login successful", () => {}, {
        position: "center-top",
        timeout: 1000,
        showOnlyTheLastOne: true,
        width: "33%",
        borderRadius: "8px",
        fontSize: "14px",
        useIcon: true,
        success: {
          background: "#00CC6D",
        },
});

[FEAT] - Custom icon on all modules

First, thank you for this excellent and simple library.

Is your feature request related to a problem? Please describe.

No. Preset icons do not cause any issue but sometimes do not fully represent the meaning of the message to the user.

Describe the solution you'd like

Just like the Notify module allows us to use a custom Font Awesome icon, the possibility to customize the icon for all modules would be very nice.
Also, maybe add the possibility to use other icon sets (like Material Icons, Bootstrap Icons, etc.)?

Describe alternatives you've considered

At the moment, use of the default icon seems to be the only simple solution, although it seems possible to change the icon with JavaScript.

Callbacks fail when calling typescript functions

Describe the bug
When adding a typescript variable to a callback function, the button which calls the does nothing when clicked.

To Reproduce
Steps to reproduce the behavior:

  1. Install in Angular via method 1 under installation (npm install, import)
  2. Import Notiflix import { Confirm } from 'notiflix';
  3. Create a Confirm as follows and call from a class function:
     Confirm.Show(
         'Notiflix Confirm',
         'Do you agree with me?', 
        'Yes',
         'No', 
        function(){
            // Yes button callback
            this.classvariable = true;
            alert('alert is a typescript function');
        },
        function(){
            // No button callback
            alert('alert is a non-typescript function'); 
        }
    ); 
  4. The "No" Button should work, and the "Yes" Button should not do anything

Expected behavior
The yes button sets this.classvariable to true then raises the alert.

Desktop

  • OS: Ubuntu 20.04
  • Browser: Firefox 81
  • Notiflix Version: 2.5.0 (latest)

Not tested on Mobile

SOLVED: Notiflix.Notify | Ambiguous functionality: closeButton and autoClose

Hi, we're using Notiflix (and we love it).

But, have a little problem. We just want to enable closeOnClick functionality for Notiflix.Notify methods, but can't simply succeeded.

  • Firstly we tried to set closeButton: true, it worked but removed the auto-close functionality (and we don't understand why?) (Problem 1)

  • Then, we realized when we set a callback method for Success / Info etc. It works like "click on close = true". So we add an empty callback methods for all calls () => null (Problem 2: This is a hack)

In my opinion, a simple closeOnClick property like Notiflix.Notify.Init({ closeOnClick: true }) could solve all complexity for this simple task.

[FEAT] - TS7016: Could not find a declaration file for module 'notiflix'

Is your feature request related to a problem? Please describe.
I don't want to always have to use // @ts-ignore with your library

Describe the solution you'd like
Please add @types/notiflix

Describe alternatives you've considered
Currently only use // @ ts-ignore or write a separate interface for it

Additional context
image

SOLVED: Allow temporal options for an specific message

I'm facing a problem: I initialize the Notify component globally for my application but I need to use specific settings for certain messages. Using Merge is not an option because that overrides the global settings and I realized that it would be great and not a hard work to allow to pass an options object for a specific message. I did a test for Notify.Info but the changes could easily be applied to all functions:

var Notiflix = {
  // Notify on
  Notify: {
    // ...
    Info: function (message, options, callback) {
      // if not initialized pretend like init
      if (!newNotifySettings) {
        Notiflix.Notify.Init({});
      }
      var theType = newNotifySettings.info;
      if (!callback && typeof options === 'function') {
        // received message & callback as second parameter
        calback = options;
        options = undefined;
      }
      NotiflixNotify(message, callback, theType, 'Info', options);
    },
  },
};
var NotiflixNotify = function (message, callback, theType, staticType, tempOptions) {
  if (arguments && arguments.length = 5) {

    // if tempOptions on
    let newNotifySettings_backup;
    if (tempOptions) {
      newNotifySettings_backup = { ...newNotifySettings };
      newNotifySettings = { ...newNotifySettings, ...tempOptions };
    }
    // if tempOptions off

    // after all the code, at the end of the block
  
    // if tempOptions on
    if (newNotifySettings_backup) {
      newNotifySettings = { ...newNotifySettings_backup };
    }
    // if tempOptions off

  }
};

After that, it is possible to do something like this:

import { Notify } from 'notiflix';

var messages = [
  { text: 'Lorem ipsum' },
  { text: 'dolor sit amet', important: true },
  { text: 'consectetur adipiscing elit' },
];

messages.forEach((message) => {
  Notify.Info(message.text, message.important ? { timeout: 10000 } : null);
});

This way, the first and second messages will use the default timeout of 3 seconds but the important one will stay visible for 10 seconds.

SOLVED: I have a question in the confirm function.

hi nice to meet you.

first, I am using notiflix very well. thank you.

When the confirm popup open,
How to make the popup close automatically when i press enter button?
Is there a way to set a HotKey?

[BUG] - Notiflix fonksiyonları içerisinde this datasına erişim hatası

Notiflix'e ait fonksiyonlar içerisinde vue instencesine this ile erişmem gerekirken this instencesi değişiyor ve erişemiyorum. Aşağıdaki şekilde bir çözüm ile sorunumu çözebiliyorum fakat her sefer bunu yapmak gerekiyor.

let vueData = this;
this.Notiflix.Confirm.Show('Uyarı', 'Kullanıcı Grubu Silinsin mi?', this.$i18n.t('tool.yes'), this.$i18n.t('tool.no'), function () {
    vueData.$axios.post('personal/deleteGroup', {id: itemId}).then(response => {
        if (response.data.status === "success") {
            vueData.Notiflix.Notify.Success(response.data.message)
            vueData.$store.dispatch('personals/getPersonalGroups')
        } else {
            vueData.Notiflix.Notify.Failure(response.data.message)
        }
    })
});

SOLVED: In the same page, I want to use Notiflix.Loading 2 times, but can't open the second after I remove the first

In the same page, I want to use Notiflix.Loading 2 times, but can't open the second after I remove the first .
for example:

Notiflix.Loading.Init();
Notiflix.Loading.Hourglass('the first loading');
//do something, about 5 seconds.
Notiflix.Loading.Remove();
Notiflix.Loading.Circle('the second loading!');

When the first loading was remove, the second loading did not open.
How can I do?
Thank you very much for answering my question!

SOLVED: Blocking confirm

Hi.
First of all thank you for this great library.

Your library emphasize non-blocking nature strongly. Which is a good thing in most cases but confirm function is a little bit different.

Here is the scenario:
User changes the form but doesn't save and clicks another link in the screen. In this scenario, we should warn the user and he/she confirm the action. After that, if the user confirms, we should rollback all changes and redirect or we should prevent the redirection.

This scenario doesn't apply to your library by nature of non-blocking confirm function but native javascript confirm function is blocking the main thread and runs smootly.

How about add an option to change the default behavior? And also, I think confirm function optionally can return a boolean value which like, true user clicked ok, false user clicked cancel.

Thanks.

[FEAT] - Notiflix Confirm component to add an input / content

First of all thanks for your library, it is very clean and easy to use.

Is your feature request related to a problem? Please describe.

I would like to modify the Notiflix Confirm component to add an input, or even modify it to add content, in order to transform it a bit in the style of confirming a password.

Describe the solution you'd like

Give the possibility to add content to the component, either by giving directly html or add parameters giving the possibility to add input with placeHolder and for the answer return a json with for each input the answer something like that.

Additional context

Another implementation that could be nice is the addition of the parameter.
backOverlayClickToClose parameter to the Confirm component it would be cool.

I thank you in advance and await your return.

When there's a Report opened it's still possible to navigate the page using the Tab key

Describe the bug
As said in the title, whenever there's a Report opened in fullscreen, the page is still navigable using the Tab key and with the Enter key links are still clickable.

Expected behavior
In my opinion, the report has to be closed by pressing che Enter key and the Tab has to be blocked in the mean time.

Desktop:

  • OS: Linux Mint 20.2
  • Browser: Firefox 91.0.1esr , Chromium 92.0.4515.159

className option not setting as expected?

Hello! I tried to set the className option on the "Block" module, but I have no clue why it is adding '-position' to it. And it persists even when the module is "removed".

Config:

Notiflix.Block.standard('.form', { 
  className: 'myClass'
});

Result:

<form class="form myClass-position">...</form>

I`ve tried the same on the Report module, but this time it sets "myClass-content". Is that behavior correct? Or Am I doing something wrong? 🤔

I`m building a web application with Nextjs v12 btw.

[FEAT] - tips, prompt, etc.

Hello, I like this plugin very much, and hope to add the following functions later:
Tips, iframe, prompt, etc.
Something like https://github.com/sentsin/layer https://layer.layui.com
This is a Chinese plugin, you can use Google Translate to read it.

Thanks again!

[FEAT] - Add Prompt Dialog

Is your feature request related to a problem? Please describe.
Yes, the Notiflix.Confirm.ask() function doesn't allow the user to provide answers other than the defined correct answer.

Describe the solution you'd like
If you can change the library to accept any value and pass it to the button callbacks, it will serve as an equivalent for the native browser prompt.

Describe alternatives you've considered
The native browser prompt https://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_prompt

[FEAT] - Notifications from left and right do not work at the same time

Version: 2.6.0

m.successNotification('Some noti', 2500, '14.5px', 'right-top', 'from-right');
m.successNotification('Some noti', 2500, '14.5px', 'left-top', 'from-left');

If the right is called before the notification on the left is closed, the notification appears on the left.

Notiflix.Notify.Init({
	fontFamily: 'Quicksand',
	useGoogleFont: true,
	closeButton: false,
	fontSize: '13px',
	width: '390px',
	plainText: false,
	// useFontAwesome: true,
	// fontAwesomeIconStyle: 'shadow',
	clickToClose: true,
	showOnlyTheLastOne: true,
	cssAnimationStyle: 'from-right',
	timeout: 2000,
	distance: '5px',
	position: 'right-top',
	messageMaxLength: 1000
});
var m = {
	successNotification: function(
		message,
		timeout = 2500,
		fontSize = '13px',
		position = 'right-top',
		cssAnimationStyle = 'from-right'
	) {
		Notiflix.Notify.Merge({
			timeout: timeout,
			fontSize: fontSize,
			position: position,
			cssAnimationStyle: cssAnimationStyle
		});
		Notiflix.Notify.Success(message);
	},
	errorNotification: function(
		message,
		timeout = 2500,
		fontSize = '13px',
		position = 'right-top',
		cssAnimationStyle = 'from-right'
	) {
		Notiflix.Notify.Merge({
			timeout: timeout,
			fontSize: fontSize,
			position: position,
			cssAnimationStyle: cssAnimationStyle
		});
		Notiflix.Notify.Failure(message);
	}
}

How to set global style ?

Thanks for this libraries.

I need to set global style changes, eg. change Success Notify background color.

Thanks.

SOLVED: Notiflix import error

I'm trying to use Notiflix from Vue. When I import the library and I try to use it I get this error:

vue.runtime.esm.js?2b0e:1888 TypeError: Cannot read property 'Sucess' of undefined
at VueComponent.createTicket (InsertDocument.vue?dbea:111)
at click (eval at ./node_modules/cache-loader/dist/cjs.js?{"cacheDirectory":"node_modules/.cache/vue-loader","cacheIdentifier":"0ed0ee4a-vue-loader-template"}!./node_modules/vue-loader/lib/loaders/templateLoader.js?!./node_modules/cache-loader/dist/cjs.js?!./node_modules/vue-loader/lib/index.js?!./src/views/InsertDocument.vue?vue&type=template&id=580a65ae&scoped=true& (0.js:23), :133:35)
at invokeWithErrorHandling (vue.runtime.esm.js?2b0e:1854)
at HTMLDivElement.invoker (vue.runtime.esm.js?2b0e:2179)
at HTMLDivElement.original._wrapper (vue.runtime.esm.js?2b0e:6911)

I'm using it in this way:

Notiflix.Notify.Sucess('Turno generado')

"notiflix": "^1.9.1"

[FEAT] - Callback and timeout

Is your feature request related to a problem? Please describe.

I wanted a notification with a timeout and a callback.

Describe the solution you'd like

I'd like to have the possibility to have a timeout and a callback together.

Additional context

It is currently not possible because of this line which prevent the timeout if callback is set: https://github.com/notiflix/Notiflix/blob/main/src/notiflix.js#L769

If you are okay with this, I can try to make a PR!

A callback option

All:

Not an issue or request. I needed the ability to execute the callback only when the click happened anywhere but the close element, allowing for notifications like "Click here to get report, close otherwise".

Since I am using the all-in-one, I made modifications to the source, which are included. Search for ECANDIDUS to see the changes.

The new option is "callbackOnTextClick", and a new "local value" is created by the changes and stored in "ntflxNotify.forcedCloseClicked".

You are more than welcome to do as you wish. with the code. If you do decide to include it, let me know as I rather use your code in case other new features are added,

BTW, neat piece of code.

notiflix-aio.zip

Receiving data from the keyboard

Hello, first of all I was very happy that the library was developed by a human:) It would be nice to have a prompt for keyboard input. Do you think for a close version?

[FEAT] - modules for CDN scripts

Is your feature request related to a problem? Please describe.
No it's not related to a problem per se, more about the size of the package. Currently this library allows importing the different modules if the lib is being used with es6 modules. However, using it with a script tag means the entire library must be loaded.

Describe the solution you'd like
I'd like to be able to exclude modules I don't use, for instance using a build process where I can specify the modules I use and only those get included in the generated script.

Describe alternatives you've considered
Something like Zepto's script builder.

Additional context
N/A

[FEAT] - ES6 Module Support

The ability to use this library with module support in ES6 would be great.
As I understand (though I am far from immersed in the technology), most other module systems support ES6 modules.

This would enable faster, more efficient, more simple loading for Vanilla usage of this library.

CLOSED: Loading clickToClose option set to false, how to close it ?

I have looked into the documentation and once you set the "clickToClose" option to false, there is no explanation of how to close it manually. So I am just using a plain javascript to remove it from "document.body".
I think it would be easier and better to return a closing function when you initialize a Loading :).

SOLVED: Features request

Hi,

First, I've spent a little bit of time trying to find other libraries because of the missing features I will mention below and yours never came up in any search. And for the life of me I can't figure out why, since from the few I looked at, it is by far the best. Easiest to use, to configure and with tones of options. And looks great as well.

That being said, there are 2 things that I would love if you could add. Not sure if this is the place to ask for them but it's the best I've got.

  1. Would be awesome if the backOverlay appearance would be customizable per alert type. I would love to put it up for failures, but not for warnings for example.
  2. Can you please add center positions on the edges? I would love to have notifications left-center for example.

Thank you very much for an awesome product.

Click on the overlay to close the popup

In the Report feature, you can add a feature that allows the user to click on the overlay to close the popup.
You can add a boolean prop to turn this feature off or on

SOLVED: Dismiss/Overlay

Hey, I didn't saw that you have a feature to dismiss other notifications.
If I generate two notification one after another, is there a way to display only the last one clicked?

SOLVED: Button off screen

When the close button is off screen (i.e. on a small phone), there is no way to close a Report notification.

[BUG] - Block Module: Temporary class name for the position

Describe the bug

For the Block Module;
The temporary class name for the static positioned reference elements can not be related to the options and/or can not be dynamic. Add and remove methods have their own instances and these options always will be different from each other if using method-based init options instead of the global init.
The temporary class name should be static or a built-in state can be used to store the previous one.

Expected behaviour

The temporary class name should be removed in any case.

Additional context

This issue is also related to: #45

SOLVED: How to go on new line in Notiflix.Report.Info

I wanna the text go on the next line, but '\n' is not correct way.
For Example,

var text="1. something;\n 2. something;\n 3. something;";
Notiflix.Report.Info( 'Title', text, 'OK');

The '\n' can't make a new line.
Is there another way to make a new line?
Thanks a million for your help!

`The requested module ... does not provide an export named ...`

The library works fine (really well, thanks!) as a global src but I'm trying to change to using it as a module import but getting errors no matter what I try.

Using 3.2.5, trying to import individual modules or the whole thing, from the full file, or individuals, all throws for some reason.

SOLVED: Cannot auto remove Notify.Info when multiple Notifys poping up at the same time.

Hi there,

When I showing Notify.info within a loop, I keep getting errors saying:

Uncaught TypeError: Cannot read property 'removeChild' of null
    at removeNotifyElmentsAndWrapper (VM39888 notiflix-aio-1.9.1.js:1129)
    at VM39888 notiflix-aio-1.9.1.js:1152

My JS Code:

function insertAfter(el, referenceNode) {
    referenceNode.parentNode.insertBefore(el, referenceNode.nextSibling);
}

$(document).on('knack-view-render.view_65', function(event, scene) {

  LazyLoad.js(['https://dl.dropbox.com/s/vj6guwl2a8b0wze/notiflix-aio-1.9.1.min.js?','https://dl.dropboxusercontent.com/s/d0bepdjq0bonnqj/notiflix-aio-1.9.1.js','https://dl.dropboxusercontent.com/s/bwanjv361aifmls/papaparse.min.js','https://dl.dropboxusercontent.com/s/2onm4emhos577sf/papaparse.js'], function () {
      var para = document.createElement("input");
      para.setAttribute("type", "file");
      para.setAttribute("name", "File Upload");
      para.setAttribute("id", "txtFileUpload");
      para.setAttribute("accept", ".csv");
      var element = document.getElementById("view_65");
      var celement = element.childNodes[0];
      if (document.getElementById("txtFileUpload")){
      	}else{insertAfter(para, celement)};

      document.getElementById('txtFileUpload').addEventListener('change', upload, false);

       function upload(evt) {
       var txt;

       Notiflix.Confirm.Show(
        'Upload file:',
        evt.target.value,
        'Yes, upload',
        'No, cancel',
        // ok button callback
        function(){
         // codes...
         Notiflix.Loading.Standard('Loading...');
         var data = null;
         var file = evt.target.files[0];
         var reader = new FileReader();
         reader.readAsText(file);
         reader.onload = function(event) {
         var csvData = event.target.result;
           
         var payload = null;
		 var i = 0;
         var j = 0;
   
         Papa.parse(csvData, {
         //download: true,
         header: true,
         step: function(row) {
         	payload = '{ "field_17": "' + row.data['Record ID'] + 
              '" ,"field_18": "' + row.data.Date + 
              '" ,"field_19": "' + row.data['Clock In Time'] + 
              '" ,"field_20": "' + row.data['Clock out Time'] + 
              '" ,"field_22": "' + row.data.Employee + 
              '" ,"field_23": "' + row.data['Timer Number'] + 
              '" }';
            j = j + 1;
           	$.ajax({
            url: "https://api.knack.com/v1/pages/scene_32/views/view_65/records",
            type: "POST",
            //async: false,
            headers: {'X-Knack-Application-Id':'*****','X-Knack-REST-API-KEY':'*****','content-type':'application/json'},
            data: payload,
            complete:function(data) { 
              	Knack.views["view_65"].model.fetch();
              	if (i == j){
                  Notiflix.Loading.Remove();
                  Notiflix.Report.Success(
                    'Upload Success',
                    j + ' rows have been successfully uploaded!',
                    'Click');;
                };
            }, 
            success: function(response) {
              	i = i + 1;	
           	Notiflix.Notify.Info('Uploading Row: '+ i);
            }
            });
         },
         complete: function() { }
         });
         };
         reader.onerror = function() {
         Notiflix.Report.Failure('Unable to read ' + file.fileName);
         };
        },
        function(){
          Notiflix.Report.Failure("You pressed Cancel!");
        }
      );
      }
  });
});




SOLVED: Strange behaviour in Firefox and Chrome, using Confirm with question mark and double quotes

I have a message like Knowledge of Operation - This operation "can not be reverted" - Do you Confirm?
Don´t know how, but in FF & Chrome message gets rendered as:
Knowledge of Operation - This operation "can ?not be reverted" - Do you Confirm
When check source code with browser F12 it looks correct.
If I go to Notiflix Live Demo, it shows fine.

Here an image what I´m getting
Screenshot_2019-04-08 Screenshot
Image from Live demo
Screenshot_2019-04-08 Notiflix a JavaScript library for client-side non-blocking notifications

Code I´m using
<script type="text/javascript"> function zNotiflixConfirm() { Notiflix.Confirm.Init({ width: '350px', titleMaxLength: 100, messageMaxLength: 250, rtl: true }) Notiflix.Confirm.Show('Agreement Confirmation', 'Knowledge of Operation - This operation "can not be reverted" - Do you Confirm?', 'Yes', 'No', function () { alert('Thank you.'); }); } </script>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.