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

card-flick-react

v1.8.0

Published

Card-flick is a type of card swipe user interface that allows users to interact with a stack of cards by flicking them left or right. This UI element is commonly used in mobile applications and websites to provide a more intuitive and engaging user experi

Downloads

17

Readme

npm version Build Status License

Card Flick React - a card swiping effect in your React web application.

Card Flick React is a React component that allows you to add a card swiping effect to your web application.

Demo

Card Flick React Demo

Installation

To install Card Flick React, simply run the following command in your terminal:

npm install card-flick-react

or

yarn add card-flick-react

Usage

To use Card Flick React:

  1. Import the CardFlick component from the package.
  2. Pass an array of cards to the CardFlick component.
  3. Define callback functions to handle the swiping effect.
  4. Render the CardFlick component in your React component.
import React from 'react'
import CardFlick from 'card-flick-react'

const cards = [
  { id: 1, content: 'Card 1' },
  { id: 2, content: 'Card 2' },
  { id: 3, content: 'Card 3' },
]

function MyComponent() {
  const handleSwipeRight = (cardIndex) => {
    console.log(`Swiped right on cardIndex with ID ${cardIndex}`)
  }

  const handleSwipeLeft = (cardIndex) => {
    console.log(`Swiped left on cardIndex with ID ${cardIndex}`)
  }

  const handleSwipe = (cardIndex) => {
    console.log(`Swiped on cardIndex with ID ${cardIndex}`)
  }

  return (
    <CardFlick
      className="card-flick-container"
      cards={cards}
      onSwipeRight={handleSwipeRight}
      onSwipeLeft={handleSwipeLeft}
      onSwipe={handleSwipe}
    />
  )
}

In this example, we define an array of cards and pass it to the CardFlick component. We also define three callback functions: handleSwipeRight, handleSwipeLeft, and handleSwipe, which are called when the user swipes right, left, or either direction on a card, respectively.

The CardFlick component renders the cards and handles the swiping effect. By default, cards are swiped by dragging them with the mouse or touch gestures.

Don't forget to style your component!

.cardContainer {
  width: 160px;
  height: 270px;
  margin: 100px auto;
  box-shadow: 0px 0px 74px -31px rgba(0, 0, 0, 0.6);
  -webkit-box-shadow: 0px 0px 74px -31px rgba(0, 0, 0, 0.6);
  -moz-box-shadow: 0px 0px 74px -31px rgba(0, 0, 0, 0.6);
}

.card {
  /* background-color: aqua; */
  height: 100%;
}

.card img {
  width: 100%;
  height: 100%;
}

Props

The CardFlick component accepts the following props:

cards

An array of objects representing the cards to be displayed. Each object should have a unique id property and a content property, which can be any valid React element or string.

const cards = [
  { id: 1, content: 'Card 1' },
  { id: 2, content: 'Card 2' },
  { id: 3, content: 'Card 3' },
]

...

<CardFlick cards={cards} />

The content property can also be a React element, such as a div or a component.

const cards = [
  {
    id: 1,
    content: (
      <div>
        <h1>Card 1</h1>
        <p>Some content</p>
      </div>
    ),
  },
  {
    id: 2,
    content: (
      <div>
        <h1>Card 2</h1>
        <p>Some content</p>
      </div>
    ),
  },
  {
    id: 3,
    content: (
      <div>
        <h1>Card 3</h1>
        <p>Some content</p>
      </div>
    ),
  },
]

onSwipeRight

A callback function called when the user swipes right on a card. The function is passed the card object as an argument.

const handleSwipeRight = (card) => {
  console.log(`Swiped right on card with ID ${card.id}`)
}

...

<CardFlick onSwipeRight={handleSwipeRight} />

onSwipeLeft

A callback function called when the user swipes left on a card. The function is passed the card object as an argument.

const handleSwipeLeft = (card) => {
  console.log(`Swiped left on card with ID ${card.id}`)
}

...

<CardFlick onSwipeLeft={handleSwipeLeft} />

onSwipe

A callback function called when the user swipes either direction on a card. The function is passed the card object as an argument.

const handleSwipe = (card) => {
  console.log(`Swiped on card with ID ${card.id}`)
}

...

<CardFlick onSwipe={handleSwipe} />

Contributing

If you find a bug or want to suggest a new feature, feel free to open an issue on the GitHub repository. Pull requests are also welcome.

License

Card-Flick is open-source software licensed under the MIT license. See the LICENSE file for more details.

Author

Created by Jorge Jimenez