1.1.2 • Published 6 months ago

stories-react-bd v1.1.2

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months 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
ansi-stylesautoprefixerboolbaseacornbracesbrowserslistbuffer-frombalanced-matchcaniuse-apibrace-expansionbuiltin-moduleschalkci-infocolor-namecolor-convertcaniuse-litecommondirconvert-source-mapcolordconcat-with-sourcemapscss-blank-pseudocommandercss-declaration-sortercss-selectcss-prefers-color-schemecss-has-pseudocss-treecss-whatcssdbcssesccssnano-utilsdebugdiff-sequencescssodeepmergedomelementtypedom-serializerdomhandlerdomutilscssnano-preset-defaultcsstypeentitiesestree-walkerescape-string-regexpelectron-to-chromiumescaladeexpecteventemitter3find-cache-dirfill-rangefs.realpathfraction.jsfind-upfseventsgeneric-namesfs-extraglobfunction-bindgensynchas-flaggraceful-fsicss-utilsicss-replace-symbolsimport-cwdglobalshasowninflightinheritsis-moduleimport-fromis-builtin-moduleis-core-moduleis-numberis-referencejest-diffjest-matcher-utilsjest-message-utiljs-tokensjest-get-typejest-utiljsonfilejest-workerjson5lilconfigjsesclodash.camelcaselocate-pathloader-utilslru-cachelodash.memoizelodash.uniqmagic-stringloose-envifymdn-datamake-dirmsminimatchmerge-streammicromatchnanoidoncenode-releasesnormalize-urlp-limitnormalize-rangep-finallyp-locatenth-checkp-tryp-timeoutpath-existspath-parsep-queuepicocolorspifypkg-dirpostcss-calcpostcss-attribute-case-insensitivepicomatchpostcss-clamppostcsspostcss-color-functional-notationpostcss-color-hex-alphapostcss-colorminpostcss-convert-valuespostcss-color-rebeccapurplepostcss-custom-mediapostcss-custom-propertiespostcss-discard-commentspostcss-custom-selectorspostcss-dir-pseudo-classpostcss-discard-overriddenpostcss-discard-duplicatespostcss-discard-emptypostcss-focus-visiblepostcss-font-variantpostcss-focus-withinpostcss-double-position-gradientspostcss-gap-propertiespostcss-image-set-functionpostcss-initialpostcss-logicalpostcss-load-configpostcss-merge-rulespostcss-lab-functionpostcss-merge-longhandpostcss-minify-gradientspostcss-minify-paramspostcss-minify-font-valuespostcss-modules-extract-importspostcss-modules-scopepostcss-modulespostcss-minify-selectorspostcss-modules-local-by-defaultpostcss-nestingpostcss-modules-valuespostcss-normalize-display-valuespostcss-normalize-positionspostcss-normalize-repeat-stylepostcss-normalize-stringpostcss-normalize-unicodepostcss-normalize-whitespacepostcss-normalize-charsetpostcss-normalize-timing-functionspostcss-normalize-urlpostcss-opacity-percentagepostcss-ordered-valuespostcss-overflow-shorthandpostcss-page-breakpostcss-placepostcss-pseudo-class-any-linkpostcss-reduce-initialpostcss-selector-notpostcss-reduce-transformspostcss-replace-overflow-wrappostcss-unique-selectorspostcss-selector-parserpretty-formatpromise.seriesrandombytesreact-dompostcss-svgopostcss-value-parserreact-isreactresolverollup-pluginutilsresolve-fromsafe-identifiersafe-bufferschedulersemverserialize-javascriptslashsource-mapsource-map-jsstack-utilssource-map-supportstablestring-hashstylehacksstyle-injectsupports-colorsvgotersersupports-preserve-symlinks-flagto-regex-rangetslibto-fast-propertiesuniversalifyutil-deprecateupdate-browserslist-dbwrappyyallistundici-typesyaml
1.1.2

6 months ago