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

react-native-toastable

v0.5.0

Published

๐Ÿž Blazingly fast and fully customizable Toaster component for React Native

Downloads

1,422

Readme

react-native-toastable

npm npm bundle size HitCount

๐Ÿž Blazingly fast and fully customizable Toaster component for React Native

  • Supports queuinge, so you can display multiple toasts in succession without having to worry about them overlapping or interfering with each other
  • Fully typed, using TypeScript
  • Supports swipe to dismiss multiple directions (left, right, up)
  • Performant, using native animations and avoiding unnecessary re-renders
  • Zero external dependencies
  • Highly customizable, allowing you to tailor it to fit your specific needs

https://user-images.githubusercontent.com/43743872/230865010-6c1c7890-2eec-47c1-bbe4-44c6c6379037.mp4

Installation

yarn add react-native-toastable

or

npm install react-native-toastable

Usage

Place Toastable component at the root of your app, and import showToastable function anywhere in your app to show or hideToastable to hide toast.

Note: If you need to use top inset of the device, Toastable must be child of SafeAreaProvider, otherwise you can use any value for offset prop, default is 56.

import { View } from 'react-native';
import { useSafeAreaInsets, SafeAreaProvider } from 'react-native-safe-area-context';
import Toastable from 'react-native-toastable';

export default function App() {
    return (
        <SafeAreaProvider>
            <RootNavigation />
        </SafeAreaProvider>
    );
}

export default function RootNavigation() {
    const { top } = useSafeAreaInsets();

    return (
        <View style={{ flex:1 }}>
            <NavigationContainer />
            <Toastable
                statusMap={{
                    success: 'red'
                    danger: 'yellow'
                    warning: 'green'
                    info: 'blue'
                }}
                offset={top}
            />
        </View>
    );
}

import { View, Button } from 'react-native';
import { hideToastable, showToastable } from 'react-native-toastable';

export default function HomeScreen() {
    return (
        <View style={{flex:1}}>
            <Button
                title="Show Toastable"
                onPress={() => showToastable({ message: 'React Native Heroes is awesome! ๐Ÿš€', status:'success' })}
            />
            <Button
                title="Hide Toastable"
                onPress={() => hideToastable()}
            />
        </View>
    );
}

Props

Inherit all other props from ToastableBodyParams interface. Except backgroundColor, status, message, onPress, contentStyle props.

| Property | Type | Description | Default | |---------------------|----------------------|---------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------| | statusMap | StatusMap | Status map, used to determine background color based on status | success: '#00BFA6', danger: '#FF5252', warning: '#FFD600', info: '#2962FF' | | onToastableHide | Func | Callback when toast is dismissed | undefined | | containerStyle | ViewProps['style'] | Container style for toast container | undefined | position | 'top' \| 'center' | Toast position. | 'top' | offset | number | Toast offset. | 56 |

ToastableBodyParams

| Params | Type | Description | Default | | ---------------- | --------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------ | --------- | | renderContent | (props: ToastableBodyParams) => React.ReactNode | Render custom content, if this is set, message will be ignored. | undefined | | contentStyle | ViewProps['style'] | Custom content style. | undefined | | backgroundColor | ColorValue | Custom background color, if this is set, status will be ignored. | undefined | | status | ToastableMessageStatus | Message status, this will be used to determine background color based on statusMap prop. | 'info' | | message | TextProps['children'] | Message to be displayed. | undefined | | onPress | Func | On press callback. | undefined | | duration | number | Duration in milliseconds. | 3000 | | alwaysVisible | boolean | Make toast always visible, even when there is a new toast. | false | | animationOutTiming | number | Animation timing for toast out in milliseconds. | 300 | | animationInTiming | number | Animation timing for toast in in milliseconds. | 300 | | swipeDirection | 'up' \| 'left' \| 'right' \| Array<'up' \| 'left' \| 'right'> | Swipe direction to dismiss toast. | 'up' | titleColor | ColorValue | Custom title color, if this is set. | '#FFFFFF' | | messageColor | ColorValue | Custom message color, if this is set. | '#FFFFFF' | titleStyle | TextStyle | Custom title style. | undefined | messageStyle | TextStyle | Custom message style. | undefined | position | 'top' \| 'bottom'\| 'center' | Toast position. | 'top' | offset | number | Toast offset. | 56 |

Contributing

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

Roadmap

  • Add more examples
  • Support animationIn and animationOut props
  • Support stackable toasts
  • Support custom animations
  • Add custom status support

Inspiration

License

MIT


Made with create-react-native-library