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-container

v1.0.3

Published

React slider with your content

Downloads

28

Readme

React Slider with your custom components in each slide (react-sliding-container)

CircleCI Build Status Build status Dependency Status devDependency Status Coverage Status Inline docs npm downloads Twitter

DEMO live: https://agitated-banach-4668c2.netlify.com

DEMO repo: https://github.com/vygandas/react-sliding-container-demo

NPM pack: https://www.npmjs.com/package/react-sliding-container

Installation

npm i --save react-sliding-container

How to include

Main component import SlidingContainer from "react-sliding-container";

Default styles import "../node_modules/react-sliding-container/lib/SlidingContainer.css";

Components

Component | Description --- | --- SlidingContainer | Main slider wrapper. It holds slide elements. Slide | Slide element that contains content. Slide content types (wrapped inside) React.ReactElement<any> | HTMLElement

Options

SlidingContainer

Option | Description --- | --- className?: string | additional class that's added to the main SlidingContainer wrapper. Default null. height?: string | Height of slides and container. Default 250px. width?: string | Width of slides and container. Default 100%. leftArrow?: React.ReactElement<any> | Left arrow component. Default <Arrow symbol='◄' />. rightArrow?: React.ReactElement<any> | Right arrow component. Default <Arrow symbol='►' />. slideXMarginPx?: number | Margin for one slide. That space from navigation arrows or side borders. Default 20. showArrows?: boolean | Whether to show arrows or not. Default true. slideTime?: number | Speed of slide travel to the right or left. Default 500. slidingType?: keyof IEasings | Type of slide easing. Default easeInQuad.

Slide

Option | Description --- | --- className?: string | Additional class that's added to the main Slide wrapper. Default null. backgroundImage?: string | Image for a whole slide background. Default null. style?: {[key: string]: string or number} | Style attributes object for a slide. It is mostly used by slider system and you shouldn't touch this. Default {}.

Simple usage

import * as React from "react";

// This is the main component that you need.
import SlidingContainer from "react-sliding-container";
// Component comes without CSS styles, so if you want to have default ones you must include this
import "react-sliding-container/lib/main.css";

import "assets/scss/App.scss";
import Slide from "react-sliding-container/lib/components/Slide";

export default class App extends React.Component<undefined, undefined> {
    render(): JSX.Element {
        return (
            <div className="container app-component">
                <div className="row">
                    <div className="col-12 text-center py-5">
                        <h1 className="display-5 mb-5">React Sliding Container Demo App</h1>
                        <SlidingContainer
                            options={{
                                className: "my-slider",
                                height: "500px",
                                slideXMarginPx: 10,
                                showArrows: true
                            }}
                        >
                            <Slide
                                backgroundImage="url('https://www.publicdomainpictures.net/pictures/130000/velka/abstract-wallpaper-1442844111BON.jpg')"
                            >
                                <div>
                                    <h2>Hello world!</h2>
                                </div>
                            </Slide>
                            <Slide
                                backgroundImage="url('https://cdn.pixabay.com/photo/2016/06/02/02/33/triangles-1430105__340.png')"
                            >
                                <div>
                                    <h2>This works!</h2>
                                </div>
                            </Slide>
                            <Slide
                                backgroundImage="url('https://images2.alphacoders.com/720/thumb-1920-72092.jpg')"
                            >
                                <div>
                                <iframe style={{position: "absolute", top: 0, bottom: 0, left: 0, right: 0, width: "100%", height: "100%"}}
                                    width="560" height="315" src="https://www.youtube.com/embed/JhKBSLRU5XA?start=10"
                                    frameBorder="0" allowFullScreen></iframe>
                                </div>
                            </Slide>
                            <Slide
                                backgroundImage="url('http://server1.intermedia.ge/pictures/original/190/190695.jpg?/ekranis-foni.jpg')"
                            >
                                <div className="container-fluid mt-5">
                                    <div className="row pt-5">
                                        <div className="col-4 py-5" style={{ background: "rgba(255, 255, 255, 0.2)" }}>1st col</div>
                                        <div className="col-4 py-5" style={{ background: "rgba(255, 255, 255, 0.3)" }}>2nd col</div>
                                        <div className="col-4 py-5" style={{ background: "rgba(255, 255, 255, 0.4)" }}>3rd col</div>
                                    </div>
                                </div>
                            </Slide>
                            <Slide
                                backgroundImage="url('https://5dwallpaper.com/wp-content/uploads/2016/06/space-wallpaper-hd6.jpg')"
                            >
                                <div>
                                    <h2>Nice picture.</h2>
                                </div>
                            </Slide>
                            <Slide
                                backgroundImage="url('http://aslania.com/wp-content/uploads/2018/03/abstract-wallpapers-11.jpg')"
                            >
                                <div>
                                    <h2>Why not this one too.</h2>
                                </div>
                            </Slide>
                        </SlidingContainer>
                    </div>
                </div>
            </div>
        );
    }
}

Custom left / right Arrows

To use your own arrows you must extend Arrow class and override methods according to your needs. This is needed because it holds callback functions attached from main component.

import Arrow from "react-sliding-container";
//<...>
const MyCustomArrow = class MyArrow extends Arrow {
    render() {
        return (
            <div>Left</div>
        );
    }
}
//<...>
<SlidingContainer
    options={{
        leftArrow: <MyCustomArrow />
    }}
/>

About this component core

It can be used as a base component for other ideas. There're implemented:

  • Run lint fix, tests and build before git commit, push and npm publish
  • Typescript, React, SCSS
  • TS, SASS Linting
  • Tests, Jest, Mocha, Enzyme
  • Configurations for systems:
    • Travis
    • Appveyor
    • CircleCI
  • Coveralls integrations for displaying how much of code is tested (You have to add your own token to .coveralls.yml or if using a CI add environment variable COVERALLS_REPO_TOKEN for submitting results)

TODO

  • Improve swiping on mobile
  • Add various callbacks
  • Add auto animation feature
  • Add navigation my keyboard left/right keys
  • Add callback onSlideLoaded

Cuntributors are welcome

Contact me if you want to help :)

React TypeScript NPM package Boilerplate Starter project

I've branched a part where everything is ready for creating a new NPM package. https://github.com/vygandas/react-sliding-container/tree/npm-package-component-skeleton-boilerplate