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-swipeable-button

v1.3.0

Published

A component to create swipeable button in react

Downloads

1,526

Readme

react-swipeable-button

NPM licenseinstall sizenpm bundle sizenpm downloads

A npm pacakge for Swipeable button in react

Changes:

v1.3.0

  • Added textColor props to customize the button text color.

v1.2.0

  • Added buttonReset method to handle resetting the button's swipe state programmatically.
  • Added buttonComplete method to handle completing the button's swipe state programmatically.

Check all the changes in the Release Notes

Installs

npm install react-swipeable-button

or

yarn add react-swipeable-button

Demo

react-swipeable-button

Usage

General Usage

import { SwipeableButton } from "react-swipeable-button";

function App() {
  const onSuccess = () => {
    console.log("Successfully Swiped!");
  };

  const onFailure = () => {
    console.log("Failed to Swipe!");
  };

  return (
    <SwipeableButton
      onSuccess={onSuccess}
      onFailure={onFailure}
      text="Swipe me!"
      text_unlocked="yeee"
      sliderColor="#16362d"
      sliderTextColor="#fff"
      sliderIconColor="#fff"
      background_color="#eee"
      borderRadius={30}
      circle
      autoWidth
      disabled={false}
      name="react-swipeable-button"
    />
  );
}

export default App;

With Ref : buttonReset and buttonComplete methods

import { useRef } from "react";
import { SwipeableButton } from "react-swipeable-button";

function App() {

  const swipeableButtonRef = useRef<SwipeableButton | null>(null); // Create a ref for the component

  const handleReset = () => {
    swipeableButtonRef.current?.buttonReset(); // Call the reset method
  };

  const handleComplete = () => {
    swipeableButtonRef.current?.buttonComplete(); // Call the complete method
  };
  return (
      <SwipeableButton
        text="Swipe me!"
        text_unlocked="yeee"
        color="16362d"
        sliderTextColor="#fff"
        sliderIconColor="#fff"
        background_color="#eee"
        circle
        name="react-swipeable-button"
        ref={swipeableButtonRef} // Expose the ref to the component
      />
      //example usage of the reset and complete methods
      <button onClick={handleReset}>Reset</button>
      <button onClick={handleComplete}>Complete</button>
    </div>
  );
}

export default App;

Props

| Prop | Type | Default | Description | | ------------------ | ------------------- | ------------------------ | ------------------------------------------------------------------------------------------------------------- | | name | String | "react-swipeable-button" | Unique ID, in case of using several components on one page | | text | String | "SWIPE" | The text that will be displayed on the swipe button | | text_unlocked | String | "UNLOCKED!" | The text that will displayed if swiping is successful | | color (Depricated) | String | "#333" | Depricated, use sliderColor instead | | sliderColor | String | "#16362d" | The color of the slider | | sliderTextColor | String | "#fff" | The color of the Slider Text | | TextColor | String | "#000" | The color of the Text (without slider) | | sliderIconColor | String | "#fff" | The color of the icon | | background_color | String | "#eee" | The background color of the container | | borderRadius | Number | 30 | The border radius of the container lets you control the roundness of the corners (ignored if circle is false) | | noAnimate | Boolean | false | Disable css transition | | width | Number | 300 | Width of element (ignored if autoWidth is true) | | height | Number | 50 | Height of element | | autoWidth | Boolean | false | takes 100% width of parent div | | circle | Boolean | true | All parts of component will be with border-radius and rounded handler | | disabled | Boolean | false | Disable interaction with component | | onSuccess | Function (optional) | null | The function that will be called when a swipe is successful | | onFailure | Function (optional) | null | The function that will be called when a swipe is failed |

Contribution

Contributing on this project is always welcome! Just fork, update, push to your respective branch and make a pull request after testing. Make sure to open an issue before contribute.

License

MIT © Abdur Rahman