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

uux-react-carousel

v1.0.0

Published

A pluggable carousel build with react for generic use.

Downloads

143

Readme

UUX React Carousel Build Status

A virtualized, responsive and highly customizable react carousel.

Installation

npm i uux-react-carousel --save-dev

import Carousel from 'uux-react-carousel'
// The default style should be imported too, and the module bundler needs to be configured to deal with it.
require('uux-react-carousel/styles.css')

Running the sample

npm start

Browse http://localhost:8081/sample.html

Using the carousel in a React app

The carousel component requires the following props:

  • carouselId: The identifier of the carousel on the page.
  • title: An optional object with two properties:
    • text: The carousel label
    • link: If you need a link for the title, use this property
  • styles: An object with css class names to customize the look of the carousel:
    • mainClass: This property will be used on the carousel wrapper element
    • navigationLeftArrow: This property will be used on the left arrow wrapper element
    • navigationRightArrow: This property will be used on the right arrow wrapper element
    • paginationDotContainer: This property will be used on the page bullets wrapper element
    • itemClass: This property will be used on the carousel item wrapper element
  • data: A list of plain objects that composes the carousel. It can be a list of anything because the page builder will work with it.
  • pageBuilder: Is an object with three functions (the carousel will call the appropriate function based on the current screen width):
    • large: A function used to build pages for screens wider than 1025px.
    • medium: A function used to build pages for screens with width between 700 and 1024px.
    • small: A function used to build pages for screens with the maximum width of 700px. The interface/contract of the function is as follows:
      • It must receive two parameters:
        • data: The complete data list that needs to be paged.
        • page: The page the carousel is requesting.
      • It must return an object with the following information:
        • currentPageItems: The list of components that should be placed/rendered on the page.
        • maxPageSize: The maximum number of items per page.
        • totalPagesCount: The total number of pages of the carousel.
Example of a styles object:
const carouselStyle = {
  mainClass: 'now-carousel',
  navigationLeftArrow: 'nav-left net-ico-arrow-left',
  navigationRightArrow: 'nav-right net-ico-arrow-right',
  paginationDotContainer: 'now-carousel-dots',
  itemClass: 'poster-horizontal-two-row'
};
Example of a data object:
const data = ['simple1', 'simple2', 'simple3','simple','simple','simple','simple','simple','simple',
  'simple', 'simple', 'simple23','simple24','simple25','simple26'];
Example of a page builder:
'use strict';

import React from 'react';
import { ComponentItem } from '../component-item';

const LARGE_PAGE_SIZE = 6;
const MEDIUM_PAGE_SIZE = 4;
const SMALL_PAGE_SIZE = 3;

export const getOneRowPage = (data, page, pageSize) => {

  return new Promise((resolve, reject) => {
    let pageIndex = page * pageSize;
    let currentPage = [];
    let pageData = data.slice(pageIndex, pageIndex + pageSize);

    for (let i = 0; i < pageData.length; i++)
      currentPage.push(<ComponentItem value={pageData[i]} />);

    resolve({
      currentPageItems: currentPage,
      maxPageSize: pageSize,
      totalPagesCount: Math.ceil(data.length / pageSize)
    });
  });
};

export default {
  large: (data, page) => { return getOneRowPage(data, page, LARGE_PAGE_SIZE); },
  medium: (data, page) => { return getOneRowPage(data, page, MEDIUM_PAGE_SIZE); },
  small: (data, page) => { return getOneRowPage(data, page, SMALL_PAGE_SIZE); }
};
Using the carousel
let title = {
  text = 'Lable to carousel',
  link = '/link-to-carousel'
};

ReactDOM.render(
  <Carousel
    key="sample-01" 
    carouselId="sample"
    title={title}
    styles={carouselStyle}
    data={data}
    pageBuilder={pageBuilder} />, 
  document.querySelector('#app-container'));

Will generate something like:

alt text