@oerlikon/notification
Provides a simple react hook for app frame notifications
Last updated 5 months ago by oerlikon-admin .
ISC · Original npm · Tarball · package.json
$ cnpm install @oerlikon/notification 
SYNC missed versions from official npm registry.

@oerlikon/notification

Provides a simple react hook for app frame notifications

api

useNotification exposes 4 methods:

  • showInfo(text, options) (blue)
  • showSuccess(text, options) (green)
  • showWarning(text, options) (yellow)
  • showError(text, options) (red)

Each method works exactly identical except for the different severity.

text (required) the text to display

options (optional):

  • identifier: (optional) notification id to ensure the notification is only displayed once
  • autHide: (optional) if a number (duration in ms) is provided, the notification will automatically disappear. If false is provided, the user has to dismiss the notification manually. (default: 3000ms)
  • actions: An array of actions (buttons) for the user to interact with. Every action will cause the notification to disappear. If no actions are provided, the notification will show a dismiss icon.
interface Options {
  identifier?: string;
  autoHide?: number | false;
  actions?: Action[];
}

interface Action {
  label: stirng
  onClick?: () => void
}

example

This example shows a warning notification that requires the user to confirm the action

import React from 'react';
import { useNotification } from '@oerlikon/notification';

export const User = () => {

  const { showWarning } = useNotification();

  cosnt handleClick = () => {
    showWarning('This text is shown to the user', {
      autoHide: false,
      actions: [
        {
          label: 'Yes!',
          onClick: () => console.log('user clicked yes')
        },
        {
          label: 'No!',
          onClick: () => console.log('user clicked no');
        }
      ]
    });
  };

  return (
    <button type="button" onClick={handleClick}>Show notification</button>
  );
}

Current Tags

  • 1.0.0-alpha.4                                ...           latest (5 months ago)

4 Versions

  • 1.0.0-alpha.4                                ...           5 months ago
  • 1.0.0-alpha.3                                ...           6 months ago
  • 1.0.0-alpha.2                                ...           6 months ago
  • 1.0.0-alpha.1                                ...           8 months ago
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (6)
Dependents (0)
None

Copyright 2014 - 2017 © taobao.org |