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-items-carousel

v2.8.0

Published

React Items Carousel

Downloads

30,598

Readme

react-items-carousel

Installation

$ npm install react-items-carousel --save

Demos

Example

import React, { useState } from 'react';
import ItemsCarousel from 'react-items-carousel';

export default () => {
  const [activeItemIndex, setActiveItemIndex] = useState(0);
  const chevronWidth = 40;
  return (
    <div style={{ padding: `0 ${chevronWidth}px` }}>
      <ItemsCarousel
        requestToChangeActive={setActiveItemIndex}
        activeItemIndex={activeItemIndex}
        numberOfCards={2}
        gutter={20}
        leftChevron={<button>{'<'}</button>}
        rightChevron={<button>{'>'}</button>}
        outsideChevron
        chevronWidth={chevronWidth}
      >
        <div style={{ height: 200, background: '#EEE' }}>First card</div>
        <div style={{ height: 200, background: '#EEE' }}>Second card</div>
        <div style={{ height: 200, background: '#EEE' }}>Third card</div>
        <div style={{ height: 200, background: '#EEE' }}>Fourth card</div>
      </ItemsCarousel>
    </div>
  );
};

Component Props

| Property | Type | Default | Description | |--------------------------|----------------------------------|---------|---------------------------------------------------------------------------------------| | children * | node[] | | The cards to render in the carousel. You must specify a height for each card. | | requestToChangeActive * | function | | This function accepts the new activeItemIndex and should update your component state. | | activeItemIndex * | int | | This defines which item should be active. | | numberOfCards | number | 3 | Number of cards to show per slide. | | infiniteLoop | boolean | false | Enable infinite loop. see Infinite loop limitations | | gutter | number | 0 | Space between cards. | | showSlither | boolean | false | If true a slither of next card will be shown. | | firstAndLastGutter | boolean | false | If true first and last cards will have twice the space. | | enablePlaceholder | boolean | false | If true, component will render placeholderItem until children are passed. | | placeholderItem | node | null | If enablePlaceholder is true, this will be rendered until children are passed. | | numberOfPlaceholderItems | number | 0 | This controls how many placeholderItem to render if enablePlaceholder is true. | | activePosition | enum ('left', 'center', 'right') | left | The position of the active item. | | rightChevron | node | null | Right chevron node. | | leftChevron | node | null | Left chevron node. | | chevronWidth | number | 0 | This value should be the width of left and right chevron. | | outsideChevron | boolean | false | If true the chevron will be rendered outside the carousel. | | alwaysShowChevrons | boolean | false | If true the chevrons will always be visible even if there were no cards to scroll. | | slidesToScroll | number | 1 | Number of cards to scroll when right and left chevrons are clicked. | | disableSwipe | boolean | false | Disables left and right swiping on touch devices. | | onStateChange | func | null | This function will be called when state change with { isFirstScroll: Boolean, isLastScroll: Boolean }. It can be used to fetch more data for example. | | classes | { wrapper: string, itemsWrapper: string, itemsInnerWrapper: string, itemWrapper: string, rightChevronWrapper: string, leftChevronWrapper: string } | {} | An object of classes to pass to the carousel inner elements |

Infinite Loop Limitations

If infiniteLoop was set to true, the following props are ignored

  • activePosition: will always be left
  • alwaysShowChevrons: will always be true

Contributing

To contribute, follow these steps:

  • Fork this repo.
  • Clone your fork.
  • Run yarn
  • Run yarn start:gh
  • Goto localhost:9000
  • Add your patch then push to your fork and submit a pull request

License

MIT