1.1.3 • Published 3 years ago

react-toast-wnm v1.1.3

Weekly downloads
2
License
MIT
Repository
-
Last release
3 years ago

react-toast-wnm · GitHub license codecov

Installation

$ npm install --save react-toast-wnm
$ yarn add react-toast-wnm

Demo

Check demo

Icons

ikonate github ikonate icons

Toast Hook Params

  • position options -> 'bottom-right' | 'bottom-center' | 'bottom-left' | 'top-left' | 'top-center' | 'top-right'.
  • type options -> 'default' | 'error' | 'warning' | 'success' | 'info'.
ParamsDescription
autoDismiss booleanDefault: true. Disable or enable dismiss autoclose toast.
backgroundColor stringDefault ''. Toast backgroundColor
borderRadius stringDefault 6px . Toast border toast.
children Object{actions, content}Optional. Toast content and action custom.
color stringDefault ''. Color text toast.
delay numberDefault 3000. The time until a toast will be dismissed automatically, in milliseconds.
enableAnimation booleanDefault: true.
height stringDefault 104px. Toast height.
isClosable booleanDefault true . Show or hide close button.
padding stringDefault 24px 32px. Toast padding.
position stringDefault bottom-right. Viewport place the toasts.
subtitle stringDefault ''. Toast title.
title stringDefault ''. Toast subtitle.
type stringDefault default. Type toast.
width stringDefault 456px. Toast width.

Default sample use

import { useToast } from 'react-toast-wnm'

const MyComponent = () => {
  const toast = useToast();

  return (
    <Button
      onClick={(): void => {
        toast({
          autoDismiss: true,
          enableAnimation: true,
          delay: 3000,
          type: 'success',
          borderRadius: '6px',
          position: 'bottom-right',
          height: '104px',
          padding: '24px 32px',
          subtitle: 'Default subtitle',
          title: 'Default title',
          width: '456px'
        });
      }}
    >
      Create my custom toast
    </Button>
  );
}

Custom sample use

import { useToast } from 'react-toast-wnm'

const CustomContent = () => (
  <div className={myCustomContentStyles}>
    <div>My custom title</div>
    <div>My custom subtitle</div>
  </div>
)

//When you create a custom actions 
// component, a closeToast prop is injected into your component.
const CustomActions = ({ closeToast, color, backgroundColor }) => (
  <div className={myCustomActionsStyles}>
    <button style={{ backgroundColor, color }} onClick={closeToast}>
      Button label
    </button>
    <button style={{ backgroundColor, color }}>Other button</button>
  </div>
)

const MyComponent = () => {
  const toast = useToast()

  return (
    <Button
      onClick={() => {
        toast({
          delay: 5000,
          backgroundColor: '#fff',
          borderRadius: '6px',
          color: '#000',
          position: 'top-right',
          actions: (
            <CustomActions
              color='purple'
              backgroundColor='red'
            />
          ),
          content: <CustomContent />,
     
        });
      }}
    >
      Create my custom toast
    </Button>
  )
}
1.1.3

3 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago