npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

snackfy

v1.2.0

Published

Snackfy is a notification provider for React that can easily show, stack up, queue and customize notifications inside your react app.

Downloads

16

Readme

Snackfy

Snackfy is a notification provider for React that can easily show, stack up, queue and customize notifications inside your react app.

snackfy

Installation

Use npm package manager to install snackfy.

npm install snackfy

Basic usage

  1. Wrap your App inside SnackbarProvider
import { SnackbarProvider } from 'snackfy';

<SnackbarProvider>
  <App/>
</SnackbarProvider>
  1. Import useSnackbar, this hook has two methods "enqueueSnackbar" and "closeSnackbar". the method "enqueueSnackbar" returns the snackbar id that can be provided to "closeSnackbar" if needed.
import { useSnackbar } from 'snackfy';

const MyComponent = () => {
  const { enqueueSnackbar } = useSnackbar();

  const handleClick = () => {
    enqueueSnackbar({
      message: 'This is an awesome Snackbar!'
    });
  };

  return (
    <Button onClick={handleClick}>Show snackbar</Button>
  );
}

Props

SnackbarProvider

| Property | Type | Default | Description | | ------------------- | ------------------- | ------------------- | ------------------- | | maxSnacks | number | 3 | Maximum amount of snackbars that will be displayed at same time (recommended to keep the maximum to 3 snackbars) | | placement | placement object | undefined | Object that determines the vertical and horizontal placement | | customIcon | any | undefined | Property that replace the default snackbar icon | | customDismiss | any | undefined | Property to replace the default dismiss icon | | customStyle | custom style object | undefined | Object that replace the default style for all snackbars |

placement props (object prop from SnackbarProvider)

| Property | Type | Default | Description | | ------------------- | ------------------- | ------------------- | ------------------- | | vertical | 'top' or 'bottom' | | Prop that determines the vertical placement | | horizontal | 'left' or 'center' or 'right' | | Props that determines the horizontal placement |

custom style props (object prop from SnackbarProvider and enqueueSnackbar options)

| Property | Type | Default | Description | | ------------------- | ------------------- | ------------------- | ------------------- | | default | React.CSSProperties | undefined | Prop that overides snackbar default style | | success | React.CSSProperties | undefined | Prop that overides snackbar success variant default style | | error | React.CSSProperties | undefined | Prop that overides snackbar error variant default style | | warning | React.CSSProperties | undefined | Prop that overides snackbar warning variant default style | | info | React.CSSProperties | undefined | Prop that overides snackbar info variant default style |

enqueueSnackbar props (returns id type: number)

| Property | Type | Default | Description | | ------------------- | ------------------- | ------------------- | ------------------- | | message | string | | Message that will be displayed in the snackbar | | actions | object (Actions) | | Object that contains the actions (max: 2), for each action will be generated a button | | options | object (Options) | | Object that contains the options to customize your snackbars |

actions props (object prop from enqueueSnackbar)

| Property | Type | Default | Description | | ------------------- | ------------------- | ------------------- | ------------------- | | first | object (Action)| | This is required only if actions is set on enqueueSnackbar and receive an action object (see below) | | second | object(Action) | | The second action is not required and receive an action object |

options props (object prop from enqueueSnackbar)

| Property | Type | Default | Description | | ------------------- | ------------------- | ------------------- | ------------------- | | countdown | number | 5000 | The amount of milliseconds the snackbar will remain open | | persist | boolean | false | If set to true, the snackbar will never be closed, unless if you pass the id to closeSnackbar or set dismissible to true (see more below) | | dismissible | boolean | false | Set to true to show a close icon (x) in the snackbar that closes the snackbar when pressed| | variant | 'sucess' or 'error' or 'warning' or 'info' | | Apply the variant style to the snackbar | | customIcon | any | undefined | Property that replace the default snackbar icon (will override Provider customIcon) | | customDismiss | any | undefined | Property to replace the default dismiss icon (will override Provider customDismiss) | | customStyle | custom style object | undefined | Object that replace the default style for all snackbars (will override Provider customStyle) |

action props (object prop from actions)

| Property | Type | Default | Description | | ------------------- | ------------------- | ------------------- | ------------------- | | name | string| | The action name that will be displayed in the button | | action | Function | | The action that will be triggered when the button is pressed |

Contributing

Pull requests are welcome. If you have any trouble, open an issue and I will solve soon as possible.

Author

Bruno Kurt

e-mail

instagram