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

@pakenfit/toast-it

v1.5.0

Published

Let's toast to the health of your app

Downloads

3

Readme

@pakenfit/toast-it

Let's toast to the health of your application

Installation

npm install @pakenfit/toast-it --save
yarn add @pakenfit/toast-it

Dependencies

This library needs these dependencies to be installed in your project before you can use it:

npm install react-native-gesture-handler react-native-reanimated react-native-safe-area-context react-native-svg --save
yarn add react-native-gesture-handler react-native-reanimated react-native-safe-area-context react-native-svg

Features

  • Fully customizable
  • Works on Android and iOS (not tested on web should work as well)
  • Compatible with Expo Go
  • Written in Typescript

Usage

import { ToastProvider, useToast } from '@pakenfit/toast-it';

const ToastComponent = () => {
  const { show, hide } = useToast();

  return (
    <View>
      <Button
        label='Show Toast'
        onPress={() =>
          show({
            type: 'success',
            message: 'This is a success Toast🤙🏽',
          })
        }
      />
    </View>
  )
}

export default function App() {

  return (
    <SafeAreaProvider>
        <ToastProvider
          defaultConfig={{
            textNumberOfLines: 2,
            bgColor: 'white',
            textColor: 'black',
          }}
        />
        <ToastComponent/>
    </SafeAreaProvider>
  )
}

Configuration

The toast component accepts the following configuration options:

  • type (optional): The type of the toast message. Possible values are 'success', 'error', 'warning', 'info', or 'loading'. Default is 'info'.
  • message: The text message to be displayed in the toast.
  • duration (optional): The duration of the toast message in milliseconds. Use 'infinite' for an indefinite duration. Default is 3000 milliseconds.
  • textColor (optional): The text color of the toast message. Default is black.
  • iconColor (optional): The color of the toast icon. Default is undefined (uses default color for each type).
  • iconSize (optional): The size of the toast icon. Default is undefined (uses default size for each type).
  • textNumberOfLines (optional): The number of lines to display for the toast message. Default is 1.
  • withBackdrop (optional, only for type loading): If true a backdrop is set when loading. Default is false.
  • backdropColor (optional, only for type loading): Set the backdrop color.
  • backdropOpacity (optional, only for type loading): Set the backdrop opacity.
  • animationType (optional): The toast enter animation type. Possible values are 'timing' and 'spring'. Default is 'timing'.
  • containerStyle (optional): The toast container style.

API

The Toast component provides the following methods through the toastRef:

  • show(config: ToastConfig): Displays a toast message with the specified configuration.
  • hide(): Hides the currently displayed toast message.
  • isVisible(): Returns a boolean indicating whether a toast message is currently visible.

Types

ToastRef

The ToastRef type represents the reference to the Toast component, allowing access to its methods. It has the following methods:

  • show: Shows the toast with the specified configuration.
  • hide: Hides the toast.
  • isVisible: Returns a boolean indicating whether the toast is currently visible.

ToastConfig

The ToastConfig type represents the configuration options for the toast component. It has the following properties:

type ToastConfig = {
  type?: toastType;
  message: string;
  duration?: number | 'infinite';
  textColor?: string;
  iconColor?: string;
  iconSize?: number;
  textNumberOfLines?: number;
  withBackdrop?: boolean;
  backdropColor?: string;
  backdropOpacity?: number;
  animationType?: 'timing' | 'spring',
  containerStyle?: ViewStyle
}

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

Development

You can launch the example app to test your feature or bug:

yarn example ios

or

yarn example android

Run tests

yarn test

License

MIT


Made with create-react-native-library

Inspired by react-hot-toast