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

@incent-loyalty/react-spring-slider

v1.3.5

Published

[![Hits-of-Code](https://hitsofcode.com/github/farbenmeer/react-spring-slider)](https://hitsofcode.com/view/github/farbenmeer/react-spring-slider) ![Version](https://img.shields.io/npm/v/@farbenmeer/react-spring-slider?style=flat-square) [![Minified Size]

Downloads

8

Readme

react-spring-slider

Hits-of-Code Version Minified Size Minified Zipped Size License

  1. General
  2. Installation
  3. Usage
  4. Configuration
  5. More Examples
  6. Contribution

General

This is a slider which uses react-spring under the hood.

This project aims to be flexible through configuration as well as be easy to use by sane and reasonable defaults.

You can have a real life look how this can be used within storybook (source) at: farbenmeer.github.io/react-spring-slider.

Installation

yarn add @farbenmeer/react-spring-slider
// OR
npm install --save @farbenmeer/react-spring-slider

Usage

The module provides a default export which you can import and use in your own component.

import Slider from "@farbenmeer/react-spring-slider";

const App = () => {
	return (
		<Slider>
			<div>child 1</div>
			<div>child 2</div>
			<div>child 3</div>
		</Slider>
	);
};

The slider can gain any children as long as there are a react node, so you can show images, text or some more complex components.

You can also use Typescript as the package contains type definitions.

Configuration

The slider currently provides the following interface:

| Name | Type | Default | Description | | --------------- | -------- | ------- | ----------------------------------------------------------------------------------------------------------: | | activeIndex | number | 0 | Controlles the shown index | | ArrowComponent | function | - | A custom component for the arrows | | auto | number | 0 | 0 = disabled auto sliding. Indicates the pausing time in milliseconds per slide before next slide is shown. | | BulletComponent | function | - | A custom component for the bullets | | bulletStyle | object | { } | custom styles for the bullets | | children | node | [ ] | The children of the slider, every child is a single slide | | hasArrows | boolean | false | Whether the slider should have arrows or not | | hasBullets | boolean | false | Whether the slider should have bullets or not | | onSlideChange | function | - | Callback which is triggered when the slides changed either manually or automatically | | setSlideCustom | function | - | A function to overwrite the default setSlide behavior. | | slidesAtOnce | number | 1 | A number which represents how many slides should be shown at once. |

More examples

Custom bulletStyle

<Slider hasBullets bulletStyle={{ backgroundColor: "#fff" }}>
	<MySlide />
	<MySlide />
	<MySlide />
</Slider>

Fully customized

import Slider from "@farbenmeer/react-spring-slider";

const App = () => {
	const onSlideChange = (index) => console.log(`changed to slide ${index}`);
	const setSlideCustom = () => 1;

	const BulletComponent = ({ onClick, isActive }) => (
		<li
			style={{
				width: "25px",
				height: "25px",
				backgroundColor: "red",
				margin: "0 2px",
				opacity: isActive && "0.5",
			}}
			onClick={onClick}
		/>
	);

	BulletComponent.propTypes = {
		onClick: PropTypes.func.isRequired,
		isActive: PropTypes.bool.isRequired,
	};

	const ArrowComponent = ({ onClick, direction }) => {
		return (
			<div
				style={{
					border: "1px solid black",
					padding: "1em",
					backgroundColor: "white",
				}}
				onClick={onClick}
			>
				{direction}
			</div>
		);
	};

	ArrowComponent.propTypes = {
		onClick: PropTypes.func.isRequired,
		direction: PropTypes.string.isRequired,
	};

	return (
		<Slider
			activeIndex={2}
			slidesAtOnce={2}
			auto
			hasBullets
			BulletComponent={BulletComponent}
			ArrowComponent={ArrowComponent}
			onSlideChange={onSlideChange}
			setSlideCustom={setSlideCustom}
		>
			<div>child 1</div>
			<div>child 2</div>
			<div>child 3</div>
		</Slider>
	);
};

For more examples have a look at storybook (storybook source code).

Contribution

See CONTRIBUTING.md