• Stars
    star
    549
  • Rank 80,988 (Top 2 %)
  • Language
    CSS
  • Created almost 6 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A React wrapper for the site tour library Shepherd

react-shepherd

NPM Test Status Maintainability Test Coverage JavaScript Style Guide

This is a React wrapper for the Shepherd, site tour, library. It's mainly a wrapper around the Shepherd library that exposes the tour object and methods to the context object that can be passed into props for dynamic interactivity.

Install

npm install --save react-shepherd

Usage

import React, { Component, useContext } from 'react'
import { ShepherdTour, ShepherdTourContext } from 'react-shepherd'
import newSteps from './steps'

const tourOptions = {
  defaultStepOptions: {
    cancelIcon: {
      enabled: true
    }
  },
  useModalOverlay: true
};

function Button() {
  const tour = useContext(ShepherdTourContext);

  return (
    <button className="button dark" onClick={tour.start}>
      Start Tour
    </button>
  );
}

class App extends Component {
  render() {
    return (
      <div>
        <ShepherdTour steps={newSteps} tourOptions={tourOptions}>
          <Button />
        </ShepherdTour>
      </div>
    );
  }
}

Configuration

The following configuration options for a tour can be set on the ShepherdTour to control the way that Shepherd is used. This is simply a POJO passed to Shepherd to use the options noted in the Shepherd Tour options. The only required option is steps, which is an array passed to the props.

tourOptions

PropTypes.object Used to set the options that will be applied to each step by default. You can pass in any of the options that you can with Shepherd.

steps

PropTypes.array You must pass an array of steps to steps, something like this:

const steps = [
  {
    id: 'intro',
    attachTo: { element: '.first-element', on: 'bottom' },
    beforeShowPromise: function () {
      return new Promise(function (resolve) {
        setTimeout(function () {
          window.scrollTo(0, 0);
          resolve();
        }, 500);
      });
    },
    buttons: [
      {
        classes: 'shepherd-button-secondary',
        text: 'Exit',
        type: 'cancel'
      },
      {
        classes: 'shepherd-button-primary',
        text: 'Back',
        type: 'back'
      },
      {
        classes: 'shepherd-button-primary',
        text: 'Next',
        type: 'next'
      }
    ],
    classes: 'custom-class-name-1 custom-class-name-2',
    highlightClass: 'highlight',
    scrollTo: false,
    cancelIcon: {
      enabled: true,
    },
    title: 'Welcome to React-Shepherd!',
    text: ['React-Shepherd is a JavaScript library for guiding users through your React app.'],
    when: {
      show: () => {
        console.log('show step');
      },
      hide: () => {
        console.log('hide step');
      }
    }
  },
  // ...
];

Steps

The options are the same as Shepherd options.

License

MIT

More Repositories

1

shepherd

Guide your users through a tour of your app
JavaScript
11,579
star
2

tether

A positioning engine to make overlays, tooltips and dropdowns better
JavaScript
8,489
star
3

vue-shepherd

A Vue wrapper for the site tour library Shepherd
Vue
260
star
4

angular-shepherd

An Angular wrapper for the site tour library Shepherd
TypeScript
196
star
5

ember-cli-release

Ember CLI addon for versioned release management
JavaScript
90
star
6

swach

A robust color management tool for the modern age
TypeScript
52
star
7

ember-prism

Easy ember components for syntax highlighting a-la PrismJS
TypeScript
34
star
8

ember-cli-capacitor

Add Capacitor to your Ember app.
JavaScript
29
star
9

ember-x-editable

X-editable like library for Ember
JavaScript
22
star
10

ember-3d-nav

A 3d rotating top navigation bar for Ember apps
JavaScript
21
star
11

website-ember

The code for shipshape.io
JavaScript
20
star
12

website-nuxt

Nuxt port of shipshape.io
Vue
16
star
13

ember-cli-netlify

Ember addon to configure Netlify headers and redirects
JavaScript
14
star
14

ember-drop

An Ember addon that wraps Drop.js
JavaScript
11
star
15

website-astro

The code for the current Ship Shape website
Astro
6
star
16

prember-sitemap-generator

A sitemap generator for prember apps
JavaScript
6
star
17

ember-service-worker-prember

An Ember Service Worker plugin that caches the index.html files for each prember route
JavaScript
6
star
18

ember-3d-folding-panel

An Ember addon for 3d folding panels
JavaScript
5
star
19

starpod

Starpod: Create an amazing podcast website in 5 minutes
TypeScript
5
star
20

ember-headroom

Ember addon to include headroom.js as an ES2015 module in your app
JavaScript
4
star
21

ember-performance-workshop

The code for the EmberConf 2018 Performance Workshop
HTML
4
star
22

ember-newton-cradle-loader

Ember addon for showing a newton cradle loading animation
JavaScript
4
star
23

ember-async-await-for-each

async/await aware forEach for Ember
JavaScript
4
star
24

prember-rss-feed

Ship RSS feeds for your Prember site
JavaScript
3
star
25

ember-assign-polyfill

A polyfill for Ember.assign in <= 2.4
JavaScript
2
star
26

ember-journal

A blogging engine for Ember apps
JavaScript
2
star
27

ember-isometric-grids

JavaScript
2
star
28

bootcamp-loader

TypeScript
1
star
29

1787-astro

Astro
1
star
30

ember-debonair

Get your Ember code in ship shape
JavaScript
1
star
31

ember-showdown-highlight

JavaScript
1
star
32

glimmer-context-menu

TypeScript
1
star
33

www-website

whiskeywebandwhatnot.fm
JavaScript
1
star