1.1.2 • Published 1 year ago

stories-react v1.1.2

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Install

npm install --save stories-react

Demo

You can find working demo here

Usage

import React from 'react';
import Stories from 'stories-react';
import 'stories-react/dist/index.css';

export default function ImagesStories() {
  const stories = [
    {
      type: 'image',
      url: 'https://images.pexels.com/photos/9470805/pexels-photo-9470805.jpeg?w=300',
      duration: 5000,
    },
    {
      type: 'image',
      duration: 6000,
      url: 'https://images.pexels.com/photos/9733197/pexels-photo-9733197.jpeg?w=300',
    },
    {
      duration: 7000,
      type: 'image',
      url: 'https://images.pexels.com/photos/9470805/pexels-photo-9470805.jpeg?w=300',
    },
  ];

  return <Stories width="400px" height="600px" stories={stories} />;
}

Props

PropertyTypeDefaultDescription
storiesIStoryObject[][]An array of story objects. description of IStoryObject is mentioned below
heightstring100%Height of story container
widthstring100%Width of story container
onStoryChangefunction(index:number)-Callback called when story changes
onStoriesStartfunction-Callback called when first story is rendered. it get called only once,
onAllStoriesEndfunction-Callback called when last story gets completed. it will get called only once
currentIndexnumber-Current index of the story which should be selected first
defaultDurationnumber10000default duration in ms of stories if duration is not provided in the IStoryObject
classNamesIStoryClassNames{}classnames to overide different sections of a story renderer
pauseStoryWhenInActiveWindowbooleantruepauses story when window goes out of focus (user changes tab/minimizes browser etc

IStoryObject

PropertyTypeDefaultDescription
typeimage , video , component-type of story to render
urlstring-url of a story (image & video only)
durationduration10000duration in ms of the story
componentReact Component-custom component to render as a story
headerReact Component-header of a story
seeMorestring , boolean , React ComponenttrueSee more action text
seeMoreComponentReact Component-see more component opens after clicking see more
onSeeMoreClickfunction(index:number)-Callback called when story see more is clicked

IStoryClassNames

PropertyTypeDefaultDescription
mainstring-classname for main container
progressContainerstring-classname for progress line container
progressBarContainerstring-classname for single progress bar box container
progressBarstring-classname for progress bar
storyContainerstring-classname for story container

Custom Component Story Props

PropertyTypeDescription
pausefunctioncall it to pause a story
resumefunctioncall it to resume a story
storyIStoryObjectcurrent story properties
isPausedbooleanstate of a story
1.1.1

1 year ago

1.1.0

1 year ago

1.1.2

1 year ago

1.0.18

2 years ago

1.0.17

2 years ago

1.0.16

2 years ago

1.0.13

2 years ago

1.0.12

2 years ago

1.0.11

2 years ago

1.0.10

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.6

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago