@snack-uikit/toaster
TypeScript icon, indicating that this package has built-in type declarations

0.8.3 • Public • Published

Toaster

Installation

npm i @snack-uikit/toaster

Changelog

Usage

import { toaster } from '@snack-uikit/toaster';

// create userAction toast
const userActionId = await toaster.userAction.success({ label, id });

// create systemEvent toast
const systemEventId = await toaster.systemEvent.success({ title, description, id });

// update userAction toast
toaster.userAction.update.error(userActionId, { label: 'new text' });

// update systemEvent toast
toaster.systemEvent.update.error(systemEventId, {
    title: 'new text',
    description: 'new description',
});

// dismiss userAction toast
toaster.userAction.dismiss(userActionId);

// dismiss systemEvent toast
toaster.systemEvent.dismiss(systemEventId);

Props

type ToastUserActionLink = {
  text: string;
  href: string;
  onClick?(e: MouseEvent<HTMLAnchorElement>): void;
};

type ToastUserActionProps = Partial<RtToastContentProps> &
  WithSupportProps<{
    label: string;
    link?: ToastUserActionLink;
    className?: string;
    onClose(id?: string | number): void;
  }>;

type ToastSystemEventLink = {
  text: string;
  href: string;
  onClick?(e: MouseEvent<HTMLAnchorElement>): void;
};

type ToastSystemEventProps = Partial<RtToastContentProps> &
  WithSupportProps<{
    title: string;
    description?: string;
    link?: ToastSystemEventLink;
    progressBar?: boolean;
    closable?: boolean;
    className?: string;
    onCloseClick?(e: MouseEvent<HTMLButtonElement>, close?: () => void): void;
    onClose(id?: string | number): void;
  }>;

TODO

  • Translations

Readme

Keywords

none

Package Sidebar

Install

npm i @snack-uikit/toaster

Weekly Downloads

177

Version

0.8.3

License

Apache-2.0

Unpacked Size

182 kB

Total Files

119

Last publish

Collaborators

  • yetihead
  • cloud-ru-tech
  • agrigorii