jupyterlab-contrib / jupyterlab_toastify

Customize 'react-toastify' to integrate nicely in JupyterLab.
Other
22 stars 4 forks source link
jupyterlab jupyterlab-extension

As of JupyterLab v3.6.0, notification is a built-in feature. We highly recommend using it - see documentation. Therefore this project is archived.

jupyterlab_toastify

Extension status Binder GitHub CI npm

Integrate react-toastify nicely in JupyterLab.

example

Installation

This package is not a JupyterLab extension but a regular npm package. So to add it to your project:

jlpm add jupyterlab_toastify

Usage

import { INotification } from 'jupyterlab_toastify';

// Error message notification - do not close automatically
INotification.error('Error');
// Warning message notification - do not close automatically
INotification.warning('Warning');
// Info message notification
INotification.info('Info');
// Success message notification
INotification.success('Success');

// Background task with progression animation
let id = await INotification.inProgress('Task in progress!');
// -> Update text
INotification.update({
  toastId: id,
  message: 'Updating task...'
});
// -> Update text, status and set closing delay (in ms)
INotification.update({
  toastId: id,
  message: 'Task succeed',
  type: 'success',
  autoClose: 3000
});

// Notification with two buttons
INotification.error('Error with button', {
  buttons: [
    {
      label: 'Action1',
      callback: () => alert('Action1 was clicked')
    },
    {
      label: 'Action2',
      callback: () => alert('Action2 was clicked')
    }
  ]
});

// Close a toast specified by its id
INotification.dismiss(id);

// Close all toasts
INotification.dismiss();

// Default call using `toast` function
// See https://github.com/fkhadra/react-toastify
INotification.notify('Default');

To close a notification, click on the close button.

Prerequisites

Installation

This is a pure NPM package since v4. You don't need to install a JupyterLab extension.

The toast container will be added to the DOM automatically by react-toastify.

All functions are asynchronous as react-toastify is lazy loaded if required.

Changelog

v4.2.0

v4.1.2

v4.1.1

v4.1.0

v4.0.0

v3.0.0

Port to JupyterLab v2

v2.3.1

v2.3.0

v2.2.0

v2.1.0

v2.0.0

v1.x

Development

For a development install (requires npm version 4 or later), do the following in the repository directory:

npm install
npm run build
jupyter labextension install .

To rebuild the package and the JupyterLab app:

npm run build
jupyter lab build