kamrify commited on
Commit
79edf8b
·
1 Parent(s): 77c7af4

Add tour progress example

Browse files
docs/src/content/guides/tour-progress.mdx ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: "Tour Progress"
3
+ groupTitle: "Examples"
4
+ sort: 2
5
+ ---
6
+
7
+ import { CodeSample } from "../../components/CodeSample.tsx";
8
+
9
+ You can use `showProgress` option to show the progress of the tour. It is shown in the bottom left corner of the screen. There is also `progressText` option which can be used to customize the text shown for the progress.
10
+
11
+ Please note that `showProgress` is `false` by default. Also the default text for `progressText` is `{{current}} of {{total}}`. You can use `{{current}}` and `{{total}}` in your `progressText` template to show the current and total steps.
12
+
13
+ <CodeSample
14
+ config={{
15
+ showProgress: true,
16
+ showButtons: ['next', 'previous'],
17
+ }}
18
+ tour={[
19
+ { element: '#tour-example', popover: { title: 'Progress Example', description: 'Notice the text at the bottom left corner showing the progress', side: "left", align: 'start' }},
20
+ { element: '.line:nth-child(1)', popover: { title: 'Import the Library', description: 'It works the same in vanilla JavaScript as well as frameworks.', side: "bottom", align: 'start' }},
21
+ { element: '.line:nth-child(2)', popover: { title: 'Importing CSS', description: 'Import the CSS which gives you the default styling for popover and overlay.', side: "bottom", align: 'start' }},
22
+ { element: '.line:nth-child(4) span:nth-child(7)', popover: { title: 'Create Driver', description: 'Simply call the driver function to create a driver.js instance', side: "left", align: 'start' }},
23
+ { element: '.line:nth-child(16)', popover: { title: 'Start Tour', description: 'Call the drive method to start the tour and your tour will be started.', side: "top", align: 'start' }},
24
+ ]}
25
+ id={"tour-example"}
26
+ client:load
27
+ >
28
+ ```js
29
+ import { driver } from "driver.js";
30
+ import "driver.js/dist/driver.css";
31
+
32
+ const driverObj = driver({
33
+ showProgress: true,
34
+ showButtons: ['next', 'previous'],
35
+ steps: [
36
+ { element: '#tour-example', popover: { title: 'Animated Tour Example', description: 'Here is the code example showing animated tour. Let\'s walk you through it.', side: "left", align: 'start' }},
37
+ { element: 'code .line:nth-child(1)', popover: { title: 'Import the Library', description: 'It works the same in vanilla JavaScript as well as frameworks.', side: "bottom", align: 'start' }},
38
+ { element: 'code .line:nth-child(2)', popover: { title: 'Importing CSS', description: 'Import the CSS which gives you the default styling for popover and overlay.', side: "bottom", align: 'start' }},
39
+ { element: 'code .line:nth-child(4) span:nth-child(7)', popover: { title: 'Create Driver', description: 'Simply call the driver function to create a driver.js instance', side: "left", align: 'start' }},
40
+ { element: 'code .line:nth-child(16)', popover: { title: 'Start Tour', description: 'Call the drive method to start the tour and your tour will be started.', side: "top", align: 'start' }},
41
+ ]
42
+ });
43
+
44
+ driverObj.drive();
45
+ ```
46
+ </CodeSample>
47
+
48
+ <CodeSample
49
+ buttonText={"Different Progress Text"}
50
+ config={{
51
+ stagePadding: 5,
52
+ progressText: "Step {{current}} of {{total}}",
53
+ showProgress: true,
54
+ showButtons: ['next', 'previous'],
55
+ }}
56
+ tour={[
57
+ { element: 'p code:nth-child(2)', popover: { title: 'progressText', description: 'You can use progressText to modify the progress text template.', side: "bottom", align: 'start' }},
58
+ { element: '#tour-example', popover: { title: 'Progress Example', description: 'Notice the text at the bottom left corner showing the progress', side: "left", align: 'start' }},
59
+ { element: '.line:nth-child(1)', popover: { title: 'Import the Library', description: 'It works the same in vanilla JavaScript as well as frameworks.', side: "bottom", align: 'start' }},
60
+ { element: '.line:nth-child(2)', popover: { title: 'Importing CSS', description: 'Import the CSS which gives you the default styling for popover and overlay.', side: "bottom", align: 'start' }},
61
+ { element: '.line:nth-child(4) span:nth-child(7)', popover: { title: 'Create Driver', description: 'Simply call the driver function to create a driver.js instance', side: "left", align: 'start' }},
62
+ { element: '.line:nth-child(16)', popover: { title: 'Start Tour', description: 'Call the drive method to start the tour and your tour will be started.', side: "top", align: 'start' }},
63
+ ]}
64
+ id={"tour-example"}
65
+ client:load
66
+ />