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-confirm-dialog

v0.1.0

Published

Custom confirmation and alert dialogs for react native

Downloads

141

Readme

React Native Confirm Dialog

Fully customizable, plug-and-play confirmation and alert dialogs for your react-native / expo app.


Features

  • Get going fast with basic styling and sensible defaults.
  • Action buttons with loading states.
  • Theme-able.
  • Dissmisable on outside clicks.

Usage

  • Wrap your application in <ConfirmProvider>
  • Use anywhere with useConfirm() hook

Demo

Try it out on Expo snack

Basic Demo

import React from 'react';
import { Button } from 'react-native'
import { ConfirmProvider, useConfirm } from 'react-native-confirm-dialog'

const ConfirmableButton = () => {
  const confirm = useConfirm()
  const handlePress = () => {
    confirm({
      // ...config options
    })
  }
  
  return <Button onPress={ handlePress } title='Confirm this!' />
}

export default function App() {

  return (
    <ConfirmProvider>
        <ConfirmableButton />
    </ConfirmProvider>
  );
}

Check out the example folder for a full example.

Download & Installation

$ yarn add react-native-confirm-dialog

Configuration Options

All of the configurations are optional with sensible defaults, and can be overriden when calling confirm or provided to ConfirmProvider as a config prop. Configuration options provided when calling confirm take precedence over options provided to ConfirmProvider

| Name | Description | Type | Default | |-------------------------|-----------------------------------------------------|-------------------------------------------------------------|-----------------------| | actions | Override the dialog buttons with a custom component | (dismiss: VoidFunction) => JSX.Element | JSX.Element[] | undefined | | body | Description of the confirmation | String | undefined | | bodyStyle | Style overrides for dialog body | TextStyle | undefined | | ButtonComponent | Override the component used for the buttons | Function Component | EnhancedButton | | buttonProps | custom props to pass to both buttons | any | undefined | | buttonLabelStyle | Style overrides for both button labels | TextStyle | undefined | | buttonStyle | Style overrides for both buttons | ViewStyle | undefined | | cancelLabel | Text of the secondary button | String | "Cancel" | | cancelButtonProps | custom props to pass to secondary button | any | undefined | | cancelButtonLabelStyle | Style overrides for secondary button label | TextStyle | undefined | | cancelButtonStyle | Style overrides for secondary button | ViewStyle | undefined | | confirmButtonProps | custom props to pass to primary button | any | undefined | | confirmButtonLabelStyle | Style overrides for primary button label | TextStyle | undefined | | confirmButtonStyle | Style overrides for primary button | ViewStyle | undefined | | confirmLabel | Text of the primary button | String | "OK" | | dismissOnOutsideClick | Should the dialog be dismissed on an outside click? | Boolean | true | | onConfirm | Callback action for primary button | VoidFunction | () => {} | | showCancel | Set to default to hide the secondary button | Boolean | true | | subtitle | Dimmed text right below the title | String | undefined | | subtitleStyle | Style overrides for subtitle | TextStyle | undefined | | theme | Theme overrides | Object | see Theme section | | title | The title displayed in the confirm dialog | String | "Are you sure?" | | titleStyle | Style overrides for title | TextStyle | undefined |

Theme

Control dialog look with a theme. Theme can be passed the same way as all the props above.

| Name | Description | Type | Default | |-----------------|------------------------------------|--------|------------------------| | spacing | Spacing between elements base unit | number | 8 | | primaryColor | Color of primary elements | string | "rgba(0, 0, 255, 0.5)" | | backshadowColor | Color of dialog's backdrop | string | "rgba(0, 0, 0, 0.4)" |

Contributing

Keep it simple. Keep it minimal. Add tests.

License

This project is licensed under the MIT License