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

alertajs

v1.1.1

Published

A minimalist toast notification system for React.

Downloads

2

Readme

AlertaJs

A minimalist toast notification system for React. Alerta provides a simple and elegant way to display toast notifications, ensuring users are informed of events and actions in your application.

Features

  • Lightweight and easy to integrate
  • Supports different types of notifications: success, error, info, and warning
  • Customizable options for each toast
  • Automatic dismissal of toasts
  • Simple API for adding and removing toasts

Installation

To install Alerta, you can use npm or yarn:

  • With npm: npm install alertajs
  • With yarn: yarn add alertajs

Usage

1. Setup

Import the ToastBox component in your app component and specify the position for the toasts to be displayed

import {alerta, ToastBox} from "alertajs"

then

// App.tsx
import React from 'react';
import {alerta, ToastBox} from "alertajs"

const App: React.FC = () => {
  return (
    <div>
      <h1>Your App</h1>
      {/* Other components */}
      <ToastBox position="top-left | top-right | bottom-left | bottom-right" />
    </div>
  );
};

export default App;

2. Using Alerta

You can use the Alerta methods in your components to show different types of notifications such as success, error, info, and warning. Each method accepts a message and optional customization options.

import React from 'react';
import {alerta, ToastBox} from "alertajs"

const SomeComponent: React.FC = () => {
  const showSuccessToast = () => {
    alerta.success('Operation completed successfully!', {
      title: 'Success',
      duration: 3000,
    });
  };

  const showErrorToast = () => {
    alerta.error('Something went wrong.', {
      title: 'Error',
      duration: 5000,
    });
  };

  return (
    <div>
      <button onClick={showSuccessToast}>Show Success Toast</button>
      <button onClick={showErrorToast}>Show Error Toast</button>
    </div>
  );
};

export default SomeComponent;

API

alerta

  • success(message: string, options?: Partial<ToastOptions>): Displays a success toast.
  • error(message: string, options?: Partial<ToastOptions>): Displays an error toast.
  • info(message: string, options?: Partial<ToastOptions>): Displays an informational toast.
  • warning(message: string, options?: Partial<ToastOptions>): Displays a warning toast.
  • dismissAll(): Dismisses all active toasts.

Customization

You can customize the appearance of your toasts by adding CSS styles. Modify the styles to suit your application’s design.

.toast {
  background: white;
  border: 1px solid #ccc;
  border-radius: 4px;
  padding: 10px;
  margin: 5px 0;
}

.toast.success {
  border-color: green;
}

.toast.error {
  border-color: red;
}

.toast.info {
  border-color: blue;
}

.toast.warning {
  border-color: orange;
}

License

MIT License. See LICENSE for details.

Contributing

If you'd like to contribute to AlertaJs, feel free to fork the repository and submit a pull request!