Giter Club home page Giter Club logo

react-user-tour's Introduction

React User Tour

A component that allows you to give a user a guided tour around your application. Click here for a Demo!

Circle CI

Install

npm install react-user-tour

Props

active

A boolean value representing whether or not the tour should currently be displayed

step

An integer representing the current active step of the tour

onNext

function that fires when user clicks the Next button. Receives the next step integer as a callback. For example, if current step is 1 and user clicks the Next button, onNext(2) will be called.

onBack

function that fires when user clicks the Back button. Receives the previous step integer as a callback. For example, if current step is 2 and user clicks the Back button, onBack(1) will be called.

onCancel

function that fires when user clicks the X button or the Done Button.

steps

An array of steps. Each step object takes: step (integer), selector (CSS selector to be passed to document.querySelector()), title (a react element representing the header of the current step), and body (a react element representing the main body message of the tour step). Each step can also take an optional argument, position which will override the position of the tour component in relation to the selector that is determined by the application. Valid arguments for the position step are left , right, top, topLeft, bottom, and bottomLeft. Optional properties horizontalOffset and verticalOffset values allow to move tooltip around pointed element. You can control distance from the edge of pointed element by margin property (25 by default). It's not taken into account in case of top and bottom overrides.

style

Optional style object.

containerStyle

Optional style object for the top level component container.

buttonStyle

Optional style object for buttons displayed on component.

buttonContainerStyle

Optional style object for the container div around the buttons.

arrow

We provide an arrow that points to the selector, but you may optionally pass in your own React element in the place of the arrow provided.

arrowSize

If you choose to use the provided arrow, you can set the pixel size here with an integer value.

arrowColor

If you choose to use the provided arrow, you can set the color here by passing in a hex value.

nextButtonText

Text that will appear on the button that moves the tour forward. Defaults to Next

backButtonText

Text that will appear on the button that moves the tour backwards. Defaults to Back

doneButtonText

Text that will appear on the button that finishes the tour. Defaults to Done

closeButtonText

Text that will appear on the button that closes the tour. Defaults to Close

hideButtons

Boolean to disable the showing of next/back/done buttons. Set this to true if you want to insert your own buttons in the body.

hideClose

Boolean to disable the showing of the close text in the upper left of the component. Set this to true if you want to insert your own close functionality or if you would like to disable the ability for the user to prematurely exit the tour.

Use

import React, { Component }from "react";
import Tour from "react-user-tour";
export default class UserTour extends Component {
	constructor() {
		super();
		this.state = {
			isTourActive: false,
			tourStep: 1
		};
	}
	componentDidMount() {
		/* set state to active in cDM to make sure nodes being attached to have been mounted */
		this.setState({
			isTourActive: true
		});
	}
	render() {
		return (
			<div>
				<Tour
					active={this.state.isTourActive}
					step={this.state.tourStep}
					onNext={(step) => this.setState({tourStep: step})}
					onBack={(step) => this.setState({tourStep: step})}
					onCancel={() => this.setState({isTourActive: false})}
					steps={[
						{
							step: 1,
							selector: ".my-fun-website",
							title: <div style={{color: "blue"}}>My Web</div>,
							body: <div style={{color: "green"}}>Site</div>
						},
						{
							step: 2,
							selector: ".my-website-is-amazing",
							title: <div style={{color: "blue"}}>Wow</div>,
							body: <div style={{color: "yellow"}}>so good</div>
						}
					]}
				/>
			</div>
		);
	}
}

Copyright (C) 2017 Social Tables, Inc. (https://www.socialtables.com) All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

react-user-tour's People

Contributors

andrewcsontos avatar benjamingr avatar bjoernm avatar conorhastings avatar erykpiast avatar krstffr avatar rovolution avatar zvictor avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-user-tour's Issues

Missing 'tween' module

After I installed react-user-tour, i get the following error

Error: Cannot find module 'tween'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (/Users/giuseppemacri/Documents/projects/avengers/node_modules/react-user-tour/node_modules/scroll-to/index.js:5:13)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (/Users/giuseppemacri/Documents/projects/avengers/node_modules/react-user-tour/dist/helpers/scroll-to-position.js:8:17)

onTouchTap fires twice

Is there a way just to just onClick instead of onTouchTap? Currently I am having an issue with click next would move two steps because of the onTouchTap.

Content is blurring because of decimal numbers in css transform

Hey there,

the plugin works fine. Thanks a lot! :) However the placement of the react-user-tour-container insides is calculated in decimal numbers (eg. transform: translate3d(146.5px, 164px, 0px)) so it causes blurring of the actual content inside in Chrome on non Retina displays.

Is there a way to round the calculated placement so it would use CSS translate with whole pixels only?

Thanks,
Florian

Redirect

Is there a way where tour goes to another page after hitting next or toggle open a side bar?

add jsdoc

i'd be happy to help anyone through the process of documenting this as a way of becoming familar with the code.

Tour placement should "stick" when scrolling vertically

When there's a user tour attached to something in a scrollable pane, scrolling vertically will mess up the position of the tour.

Also, if there is a tour on an element that is out of view, the position of the tour is awkwardly stuck to the bottom, so when scrolling that element into view the tour will cover it up.

I would guess that the tour should scroll a hidden element into view and scroll together with it. This might be somewhat related to #28 .

Thanks

user should be able to over ride position

right now, we dynamically determine the position of the tour step based on the location of the element in the dom. The user should be able to override this setting and specifically say they want the the step to appear left/right/top/bottom.

Dynamic Usage

I am trying to write a component with <UserTour/> which I import once in the application and then give class selectors to the divs with which I want to attach the popovers, But it doesn't seem to work.
Looking for some insight.
Thank you.
My component render returns below piece.

<div style={{ position: 'absolute', top: 0 }}>
				<Tour
					active={this.state.isTourActive}
					step={this.state.tourStep}
					onNext={(step) => this.setState({tourStep: step})}
					onBack={(step) => this.setState({tourStep: step})}
					onCancel={() => this.setState({isTourActive: false})}
					steps={[
						{
					    step: 1,
							selector: '.stop-1',
							title: <div style={{color: 'blue'}}>My Web</div>,
							body: <div style={{color: 'green'}}>Site</div>
						},
						{
							step: 2,
							selector: '.stop-2',
							title: <div style={{color: 'blue'}}>Wow</div>,
							body: <div style={{color: 'yellow'}}>so good</div>
						}
					]}
				/>
			</div>

I use className='stop-1' with some div like

<div
        className='stop-1'
        style={{position: 'fixed', bottom: '10px', right: '10px'}}
      >

But that doesnot work. It doesnot show popover attached to that particular div. but shows on top where i Imported and used it

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.