Code Monkey home page Code Monkey logo

reactour's Introduction

Reactour

Tourist Guide into your React Components (demo)

Edit 7kjp4nzv9q

Install

npm i -S 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

Prop Desc Type Default Is Required
badgeContent Function to customize Badge content (current, total) => {} func
className Custom class to add to the helper string
closeWithMask Close clicking the mask bool true
disableInteraction Isn't possible to interact with highlighted elements bool
highlightedMaskClassName Custom class name for element which is overlaid target element string
inViewThreshold Scroll element to show when is outiside viewport adding this threshold value number
isOpen you know… bool
lastStepNextButton Change Next button in last step into a custom button to close the Tour string
maskClassName Custom class to add to the mask string
maskSpace padding between elemente showed and mask number 10
nextButton next navigation button text string
onAfterOpen function triggered after open func () => { document.body.style.overflowY = 'hidden' }
onBeforeClose function triggered before close func () => { document.body.style.overflowY = 'auto' }
onRequestClose function triggered to close func
prevButton prev navigation button text string
scrollDuration Smooth scroll duration when positioning the target element number 1
scrollOffset Offset when positioning the target element number calculates the vertical center of the page
showButtons Show helper navigation butons bool true
showNavigation Show helper navigation dots bool true
showNavigationNumber Show number when hovers on each navigation dots bool true
showNumber Show helper number badge bool true
startAt Starting step each time the Tour is open number
steps Array of steps with info and props [view bellow]
update Value to listen if a forced update is needed string
updateDelay Delay time when forcing update. Useful when there are known animation/transitions number 1
steps: PropTypes.arrayOf(PropTypes.shape({
  'selector': PropTypes.string.isRequired,
  'content': PropTypes.oneOfType([
    PropTypes.node,
    PropTypes.element,
    PropTypes.func,
  ]).isRequired,
  'position': PropTypes.string,
  '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)}>Got 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',
    },
  },
  // ...
]

reactour's People

Contributors

elrumordelaluz avatar slivmi avatar belgac avatar justkant avatar budda avatar

Watchers

James Cloos avatar Alan HEDOUX avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.