1.8.1 • Published 6 years ago

@matsumos/reactour v1.8.1

Weekly downloads
-
License
MIT
Repository
github
Last release
6 years ago

Install

npm i --save reactour
yarn add reactour

Initialize

Add the Tour Component in your Application:

import Tour from 'reactour'

class App extends Component {
  // ...

  render  (
    <div>
      { /* other stuff */}
      <Tour
        steps={steps}
        isOpen={this.state.isTourOpen}
        onRequestClose={this.closeTour} />
    </div>
  )
}

const steps = [
  {
    selector: '.first-step',
    content: 'This is my first Step',
  },
  // ...
]

PropTypes

PropDescTypeDefaultIs Required
accentColorChange --reactour-accent color (helper number + dots)string#007aff
badgeContentFunction to customize Badge content (current, total) => {}func
classNameCustom class to add to the helperstring
closeWithMaskClose clicking the maskbooltrue
disableDotsNavigationIsn't possible to interact with helper dotsbool
disableInteractionIsn't possible to interact with highlighted elementsbool
disableKeyboardNavigationIsn't possible to interact with keyboard arrowsbool
getCurrentStepFunction triggered each time current step changefuncstep => { /* 'step' is the current step index */ }
goToStepProgrammatically change current stepnumber
highlightedMaskClassNameCustom class name for element which is overlaid target elementstring
inViewThresholdScroll element to show when is outiside viewport adding this threshold valuenumber
isOpenYou know…bool
lastStepNextButtonChange Next button in last step into a custom button to close the Tournode
maskClassNameCustom class to add to the maskstring
maskSpacePadding between elemente showed and masknumber10
nextButtonNext navigation button textnode
nextStepOverride default nextStep function to use a custom onefunc
onAfterOpenFunction triggered after openfunc() => { document.body.style.overflowY = 'hidden' }
onBeforeCloseFunction triggered before closefunc() => { document.body.style.overflowY = 'auto' }
onRequestCloseFunction triggered to closefunc
prevButtonPrev navigation button textnode
prevStepOverride default prevStep function to use a custom onefunc
roundedBeautify helper + mask with border-radius (in px)number0
scrollDurationSmooth scroll duration when positioning the target elementnumber1
scrollOffsetOffset when positioning the target elementnumbercalculates the vertical center of the page
showButtonsShow helper navigation butonsbooltrue
showNavigationShow helper navigation dotsbooltrue
showNavigationNumberShow number when hovers on each navigation dotsbooltrue
showNumberShow helper number badgebooltrue
startAtStarting step each time the Tour is opennumber
stepsArray of steps with info and propsview bellow
updateValue to listen if a forced update is neededstring
updateDelayDelay time when forcing update. Useful when there are known animation/transitionsnumber1
steps: PropTypes.arrayOf(PropTypes.shape({
  'selector': PropTypes.string,
  'content': PropTypes.oneOfType([
    PropTypes.node,
    PropTypes.element,
    PropTypes.func,
  ]).isRequired,
  'position': PropTypes.oneOf(['top', 'right', 'bottom', 'left', 'center']),
  'action': PropTypes.func,
  'style': PropTypes.object,
})),

Steps example

const steps = [
  {
    selector: '[data-tour="my-first-step"]',
    content: ({ goTo, inDOM }) => (
      <div>
        Lorem ipsum <button onClick={() => goTo(4)}>Go to Step 5</button>
        <br />
        {inDOM && '🎉 Look at your step!'}
      </div>
    ),
    position: 'top',
    action: node => {
      node.focus()
      console.log('yup, the target element is also focused!')
    },
    style: {
      backgroundColor: '#bada55',
    },
  },
  // ...
]