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-sliding-item

v1.0.0

Published

![npm](https://img.shields.io/npm/v/react-sliding-item) ![npm](https://img.shields.io/npm/dt/react-sliding-item) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

Downloads

29

Readme

react-sliding-item

npm npm License: MIT

react-sliding-item is a headless React component for creating mobile-friendly sliding interactions.

See it live on CodeSandbox: https://codesandbox.io/p/sandbox/epic-hofstadter-957rvm

https://github.com/iampava/react-sliding-item/assets/11327761/2e2330de-0a0f-4955-8b3f-db2ba9792f26

Installation

Make sure you have React installed in your project before installing react-sliding-item. You'll also need to have framer-motion as a peer dependency.

npm install react-sliding-item framer-motion

NOTE: this is a headless component coming with very little styling needed to correctly position things.

Usage

Here's an example that uses TailwindCSS as styling:

import { SlidingItem, resetAnimation } from 'react-sliding-item'

function App() {
  return (
    <div className='w-64 m-auto mt-20 overflow-hidden'>
      <SlidingItem
        left={<button className="bg-gray-500 text-white h-full w-full" onClick={resetAnimation}> More </button>}
        right={<button className="bg-red-500 text-white h-full w-full"> Delete </button>}
      >
        <div className="bg-gray-100 p-2">
          <h2> Fix vacuum cleaner</h2>
          <time className="text-gray-500 text-xs"> 10:03 AM</time>
        </div>
      </SlidingItem>
      <SlidingItem
        left={<button className="bg-gray-500 text-white h-full w-full" onClick={resetAnimation}> More </button>}
        right={<button className="bg-red-500 text-white h-full w-full"> Delete </button>}
      >
        <div className="bg-gray-100 p-2">
          <h2> Call pet groomer</h2>
          <time className="text-gray-500 text-xs"> 1:00 PM</time>
        </div>
      </SlidingItem>
      <SlidingItem
        left={<button className="bg-gray-500 text-white h-full w-full" onClick={resetAnimation}> More </button>}
        right={<button className="bg-red-500 text-white h-full w-full"> Delete </button>}
      >
        <div className="bg-gray-100 p-2">
          <h2> Restock cleaning suplies</h2>
          <time className="text-gray-500 text-xs"> 1:30 PM</time>
        </div>
      </SlidingItem>
    </div>
  )
}

export default App

Exports

This package exports 2 things:

  1. A React component called <SlidingItem> with the following Prop definition:
type Props =
  {
    /** Configuration options for the sliding item. */
    options?: {
      /** Width of the left/right element in pixels. */
      max?: number;
      /** How far the user has to drag before the element is considered "swiped". This is a numeric value between 0 and `max` and represents pixels. */
      threshold?: number;
    };
    children: React.ReactNode;
  } & (
    | {
      right: JSX.Element;
      left?: JSX.Element;
    }
    | {
      right?: JSX.Element;
      left: JSX.Element;
    }
    | {
      right: JSX.Element;
      left: JSX.Element;
    }
  );
  1. A function called resetAnimation that let's you return to the initial position.

Acknowledgements

Code was inspired from this Devon Govett's tweet: https://twitter.com/devongovett/status/1683882802977312770