react-shepherd 4.3.0 → 5.0.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -116
- package/dist/index.d.ts +24 -23
- package/dist/index.js +4132 -0
- package/dist/index.umd.cjs +27 -0
- package/package.json +39 -84
- package/src/index.tsx +50 -0
- package/dist/Shepherd.es.js +0 -4460
- package/dist/Shepherd.es.js.map +0 -1
- package/dist/Shepherd.js +0 -4471
- package/dist/Shepherd.js.map +0 -1
- package/dist/__tests__/shepherd.test.d.ts +0 -1
package/README.md
CHANGED
|
@@ -1,50 +1,43 @@
|
|
|
1
|
-
# react
|
|
1
|
+
# react
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
<a href="https://shipshape.io">
|
|
5
|
-
<img align="left" src="http://i.imgur.com/DWHQjA5.png" alt="Ship Shape" width="50" height="50"/>
|
|
6
|
-
</a>
|
|
3
|
+
[](https://www.npmjs.com/package/@shepherdpro/react)
|
|
7
4
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
</div>
|
|
11
|
-
|
|
12
|
-
[](https://www.npmjs.com/package/react-shepherd)
|
|
13
|
-
[](https://github.com/shipshapecode/react-shepherd/actions?query=workflow%3ATest)
|
|
14
|
-
[](https://codeclimate.com/github/shipshapecode/react-shepherd/maintainability)
|
|
15
|
-
[](https://codeclimate.com/github/shipshapecode/react-shepherd/test_coverage)
|
|
16
|
-
[](https://standardjs.com)
|
|
17
|
-
|
|
18
|
-
This is a React wrapper for the [Shepherd](https://github.com/shipshapecode/shepherd), site tour, library.
|
|
5
|
+
This is a React wrapper for the [Shepherd](https://github.com/@shepherdpro/react) tour library.
|
|
19
6
|
It's mainly a wrapper around the Shepherd library that exposes the tour object and methods to the context object
|
|
20
7
|
that can be passed into props for dynamic interactivity.
|
|
21
8
|
|
|
22
9
|
## Install
|
|
23
10
|
|
|
11
|
+
Use this simple NPM command or whatever package manager is your favorite.
|
|
12
|
+
|
|
24
13
|
```bash
|
|
25
|
-
npm install --save react
|
|
14
|
+
npm install --save @shepherdpro/react
|
|
26
15
|
```
|
|
27
16
|
|
|
28
17
|
## Usage
|
|
29
18
|
|
|
30
19
|
### Via Provider/Context
|
|
31
20
|
|
|
32
|
-
```
|
|
33
|
-
import
|
|
34
|
-
import {
|
|
35
|
-
import newSteps from
|
|
21
|
+
```tsx
|
|
22
|
+
import { Component, useContext } from 'react';
|
|
23
|
+
import { ShepherdJourneyProvider, useShepherd } from '@shepherdpro/react';
|
|
24
|
+
import newSteps from './steps';
|
|
36
25
|
|
|
37
26
|
const tourOptions = {
|
|
38
27
|
defaultStepOptions: {
|
|
39
28
|
cancelIcon: {
|
|
40
|
-
enabled: true
|
|
41
|
-
}
|
|
29
|
+
enabled: true
|
|
30
|
+
}
|
|
42
31
|
},
|
|
43
|
-
useModalOverlay: true
|
|
32
|
+
useModalOverlay: true
|
|
44
33
|
};
|
|
45
34
|
|
|
46
35
|
function Button() {
|
|
47
|
-
const
|
|
36
|
+
const shepherd = useShepherd(ShepherdTourContext);
|
|
37
|
+
const tour = shepherd.Tour({
|
|
38
|
+
...tourOptions,
|
|
39
|
+
steps: newSteps
|
|
40
|
+
});
|
|
48
41
|
|
|
49
42
|
return (
|
|
50
43
|
<button className="button dark" onClick={tour.start}>
|
|
@@ -56,106 +49,22 @@ function Button() {
|
|
|
56
49
|
export default function App() {
|
|
57
50
|
return (
|
|
58
51
|
<div>
|
|
59
|
-
<
|
|
52
|
+
<ShepherdJourneyProvider>
|
|
60
53
|
<Button />
|
|
61
|
-
</
|
|
54
|
+
</ShepherdJourneyProvider>
|
|
62
55
|
</div>
|
|
63
56
|
);
|
|
64
57
|
}
|
|
65
58
|
```
|
|
66
59
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
```jsx
|
|
70
|
-
import React, { Component } from "react";
|
|
71
|
-
import { useShepherdTour } from "react-shepherd";
|
|
72
|
-
import newSteps from "./steps";
|
|
73
|
-
|
|
74
|
-
const tourOptions = {
|
|
75
|
-
defaultStepOptions: {
|
|
76
|
-
cancelIcon: {
|
|
77
|
-
enabled: true,
|
|
78
|
-
},
|
|
79
|
-
},
|
|
80
|
-
useModalOverlay: true,
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
export default function App() {
|
|
84
|
-
const tour = useShepherdTour({ tourOptions, steps: newSteps });
|
|
60
|
+
## Configuration
|
|
85
61
|
|
|
86
|
-
|
|
87
|
-
<button class="button dark" onClick={tour.start}>
|
|
88
|
-
Start Tour
|
|
89
|
-
</button>
|
|
90
|
-
);
|
|
91
|
-
}
|
|
92
|
-
```
|
|
62
|
+
The following configuration options for a tour can be set on the `useShepherd` hook 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](https://shepherdjs.dev/docs/Tour.html). You can also pass an API Key to use [Shepherd Pro](https://shepherdpro.com) features for analytics related events tracking.
|
|
93
63
|
|
|
94
|
-
|
|
64
|
+
### apiKey
|
|
95
65
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
### tourOptions
|
|
100
|
-
|
|
101
|
-
`PropTypes.object`
|
|
102
|
-
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.
|
|
103
|
-
|
|
104
|
-
### steps
|
|
105
|
-
|
|
106
|
-
`PropTypes.array`
|
|
107
|
-
You must pass an array of steps to `steps`, something like this:
|
|
108
|
-
|
|
109
|
-
```js
|
|
110
|
-
const steps = [
|
|
111
|
-
{
|
|
112
|
-
id: 'intro',
|
|
113
|
-
attachTo: { element: '.first-element', on: 'bottom' },
|
|
114
|
-
beforeShowPromise: function () {
|
|
115
|
-
return new Promise(function (resolve) {
|
|
116
|
-
setTimeout(function () {
|
|
117
|
-
window.scrollTo(0, 0);
|
|
118
|
-
resolve();
|
|
119
|
-
}, 500);
|
|
120
|
-
});
|
|
121
|
-
},
|
|
122
|
-
buttons: [
|
|
123
|
-
{
|
|
124
|
-
classes: 'shepherd-button-secondary',
|
|
125
|
-
text: 'Exit',
|
|
126
|
-
type: 'cancel'
|
|
127
|
-
},
|
|
128
|
-
{
|
|
129
|
-
classes: 'shepherd-button-primary',
|
|
130
|
-
text: 'Back',
|
|
131
|
-
type: 'back'
|
|
132
|
-
},
|
|
133
|
-
{
|
|
134
|
-
classes: 'shepherd-button-primary',
|
|
135
|
-
text: 'Next',
|
|
136
|
-
type: 'next'
|
|
137
|
-
}
|
|
138
|
-
],
|
|
139
|
-
classes: 'custom-class-name-1 custom-class-name-2',
|
|
140
|
-
highlightClass: 'highlight',
|
|
141
|
-
scrollTo: false,
|
|
142
|
-
cancelIcon: {
|
|
143
|
-
enabled: true,
|
|
144
|
-
},
|
|
145
|
-
title: 'Welcome to React-Shepherd!',
|
|
146
|
-
text: ['React-Shepherd is a JavaScript library for guiding users through your React app.'],
|
|
147
|
-
when: {
|
|
148
|
-
show: () => {
|
|
149
|
-
console.log('show step');
|
|
150
|
-
},
|
|
151
|
-
hide: () => {
|
|
152
|
-
console.log('hide step');
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
},
|
|
156
|
-
// ...
|
|
157
|
-
];
|
|
158
|
-
```
|
|
66
|
+
`PropTypes.string`
|
|
67
|
+
Used to connect your tours to a Pro instance to get additional user information and feedback.
|
|
159
68
|
|
|
160
69
|
## Steps
|
|
161
70
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,23 +1,24 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
declare
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
export
|
|
23
|
-
|
|
1
|
+
import { Consumer } from 'react';
|
|
2
|
+
import { Context } from 'react';
|
|
3
|
+
import { FC } from 'react';
|
|
4
|
+
import { ReactNode } from 'react';
|
|
5
|
+
import { ShepherdPro } from 'shepherd.js/tour';
|
|
6
|
+
|
|
7
|
+
export declare const JourneyMethods: Consumer<ShepherdContextType | undefined>;
|
|
8
|
+
|
|
9
|
+
declare interface ShepherdContextType {
|
|
10
|
+
Shepherd: typeof ShepherdPro;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export declare const ShepherdJourneyContext: Context<ShepherdContextType | undefined>;
|
|
14
|
+
|
|
15
|
+
export declare const ShepherdJourneyProvider: FC<ShepherdProviderProps>;
|
|
16
|
+
|
|
17
|
+
declare interface ShepherdProviderProps {
|
|
18
|
+
apiKey?: string;
|
|
19
|
+
children?: ReactNode;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export declare const useShepherd: () => ShepherdPro;
|
|
23
|
+
|
|
24
|
+
export { }
|