kamrify commited on
Commit
1337c0d
·
1 Parent(s): 0797fb7

Add animated or non-animated tours

Browse files
Files changed (3) hide show
  1. demo/scripts/demo.js +55 -51
  2. demo/styles/demo.scss +21 -5
  3. index.html +4 -2
demo/scripts/demo.js CHANGED
@@ -1,117 +1,121 @@
1
  /* eslint-disable */
2
  document.addEventListener("DOMContentLoaded", function () {
3
- const tourDriver = new Driver({
4
- animate: false,
5
- opacity: 0.8,
6
- padding: 5,
7
- showButtons: true,
8
- });
9
 
10
- tourDriver.defineSteps([
11
  {
12
  element: '#driver-demo-head',
13
  popover: {
14
  title: 'Before we start',
15
  description: 'This is just one use-case, make sure to check out the rest of the docs below.',
16
- nextBtnText: 'Okay, Start!',
17
- },
18
- },
19
- {
20
  element: '#logo_emoji',
21
  popover: {
22
  title: 'Focus Anything',
23
  description: 'You can use it to highlight literally anything, images, text, div, span, li etc.',
24
- position: 'bottom',
25
- },
26
- },
27
- {
28
  element: '#name_driver',
29
  popover: {
30
  title: 'Why Driver?',
31
- description: 'Because it lets you drive the user across the page',
32
- position: 'bottom',
33
- },
34
- },
35
- {
36
  element: '#driver-demo-head',
37
  popover: {
38
  title: 'Lets talk features',
39
  description: 'You may leave your mouse and use the <strong>arrow keys</strong> to move next and back or <strong>escape key</strong> anytime to close this',
40
- position: 'bottom',
41
- },
42
- },
43
- {
44
  element: '#highlight_feature',
45
  popover: {
46
  title: 'Highlight Feature',
47
  description: 'You may use it to highlight single elements (with or without popover) e.g. like facebook does while creating posts'
48
  }
49
- },
50
- {
51
  element: '#feature_introductions_feature',
52
  popover: {
53
  title: 'Feature Introductions',
54
  description: 'With it\'s powerful API you can use it to make programmatic or user driven feature introductions',
55
- position: 'bottom',
56
  }
57
- },
58
- {
59
  element: '#focus_shifters_feature',
60
  popover: {
61
  title: 'Focus Shifters',
62
  description: 'If some element or part of the page needs user\'s interaction, you can just call the highlight method. Driver will take care of driving the user there',
63
- position: 'bottom',
64
  }
65
- },
66
- {
67
  element: '#customizable_feature',
68
  popover: {
69
  title: 'Highly Customizable',
70
  description: 'Driver has a powerful API allowing you to customize the experience as much as you can.',
71
- position: 'bottom',
72
  }
73
- },
74
- {
75
  element: '#keyboard_feature',
76
  popover: {
77
  title: 'User Friendly',
78
  description: 'Your users can control it with the arrow keys on keyboard, or escape to close it',
79
- position: 'bottom',
80
  }
81
- },
82
- {
83
  element: '#free_use_feature',
84
  popover: {
85
  title: 'MIT License',
86
- description: 'I believe in open=source and thus Driver is completely free for both personal or commercial use'
87
  }
88
- },
89
- {
90
  element: '#lightweight_feature',
91
  popover: {
92
  title: 'Only ~4KB',
93
  description: 'Driver is free of bloat and written in Vanilla JS. There is no external dependency at all, thus keeping it smaller in size.'
94
  }
95
- },
96
- {
97
  element: '#examples_section',
98
  popover: {
99
  title: 'Usage Examples',
100
  description: 'Have a look at the usage examples and see how you can use it.'
101
  }
102
- },
103
- {
104
  element: '#driver-demo-head',
105
  popover: {
106
  title: 'Quick Tour Ends',
107
- description: 'This was just a sneak peak, have a look at the API section and examples to learn more!',
108
- },
109
- },
110
- ]);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
111
 
112
- document.querySelector('.btn__example')
113
  .addEventListener('click', () => {
114
- tourDriver.start();
115
  });
116
 
117
 
 
1
  /* eslint-disable */
2
  document.addEventListener("DOMContentLoaded", function () {
 
 
 
 
 
 
3
 
4
+ const tourSteps = [
5
  {
6
  element: '#driver-demo-head',
7
  popover: {
8
  title: 'Before we start',
9
  description: 'This is just one use-case, make sure to check out the rest of the docs below.',
10
+ nextBtnText: 'Okay, Start!'
11
+ }
12
+ }, {
 
13
  element: '#logo_emoji',
14
  popover: {
15
  title: 'Focus Anything',
16
  description: 'You can use it to highlight literally anything, images, text, div, span, li etc.',
17
+ position: 'bottom'
18
+ }
19
+ }, {
 
20
  element: '#name_driver',
21
  popover: {
22
  title: 'Why Driver?',
23
+ description: 'Because it let\'s you drive the user across the page',
24
+ position: 'bottom'
25
+ }
26
+ }, {
 
27
  element: '#driver-demo-head',
28
  popover: {
29
  title: 'Lets talk features',
30
  description: 'You may leave your mouse and use the <strong>arrow keys</strong> to move next and back or <strong>escape key</strong> anytime to close this',
31
+ position: 'bottom'
32
+ }
33
+ }, {
 
34
  element: '#highlight_feature',
35
  popover: {
36
  title: 'Highlight Feature',
37
  description: 'You may use it to highlight single elements (with or without popover) e.g. like facebook does while creating posts'
38
  }
39
+ }, {
 
40
  element: '#feature_introductions_feature',
41
  popover: {
42
  title: 'Feature Introductions',
43
  description: 'With it\'s powerful API you can use it to make programmatic or user driven feature introductions',
44
+ position: 'bottom'
45
  }
46
+ }, {
 
47
  element: '#focus_shifters_feature',
48
  popover: {
49
  title: 'Focus Shifters',
50
  description: 'If some element or part of the page needs user\'s interaction, you can just call the highlight method. Driver will take care of driving the user there',
51
+ position: 'bottom'
52
  }
53
+ }, {
 
54
  element: '#customizable_feature',
55
  popover: {
56
  title: 'Highly Customizable',
57
  description: 'Driver has a powerful API allowing you to customize the experience as much as you can.',
58
+ position: 'bottom'
59
  }
60
+ }, {
 
61
  element: '#keyboard_feature',
62
  popover: {
63
  title: 'User Friendly',
64
  description: 'Your users can control it with the arrow keys on keyboard, or escape to close it',
65
+ position: 'bottom'
66
  }
67
+ }, {
 
68
  element: '#free_use_feature',
69
  popover: {
70
  title: 'MIT License',
71
+ description: 'I believe in open-source and thus Driver is completely free for both personal or commercial use'
72
  }
73
+ }, {
 
74
  element: '#lightweight_feature',
75
  popover: {
76
  title: 'Only ~4KB',
77
  description: 'Driver is free of bloat and written in Vanilla JS. There is no external dependency at all, thus keeping it smaller in size.'
78
  }
79
+ }, {
 
80
  element: '#examples_section',
81
  popover: {
82
  title: 'Usage Examples',
83
  description: 'Have a look at the usage examples and see how you can use it.'
84
  }
85
+ }, {
 
86
  element: '#driver-demo-head',
87
  popover: {
88
  title: 'Quick Tour Ends',
89
+ description: 'This was just a sneak peak, have a look at the API section and examples to learn more!'
90
+ }
91
+ }
92
+ ];
93
+
94
+ const animatedTourDriver = new Driver({
95
+ animate: true,
96
+ opacity: 0.8,
97
+ padding: 5,
98
+ showButtons: true,
99
+ });
100
+
101
+ const boringTourDriver = new Driver({
102
+ animate: false,
103
+ opacity: 0.8,
104
+ padding: 5,
105
+ showButtons: true,
106
+ });
107
+
108
+ boringTourDriver.defineSteps(tourSteps);
109
+ animatedTourDriver.defineSteps(tourSteps);
110
+
111
+ document.querySelector('#animated-tour')
112
+ .addEventListener('click', () => {
113
+ animatedTourDriver.start();
114
+ });
115
 
116
+ document.querySelector('#boring-tour')
117
  .addEventListener('click', () => {
118
+ boringTourDriver.start();
119
  });
120
 
121
 
demo/styles/demo.scss CHANGED
@@ -9,7 +9,7 @@ img.emoji {
9
  }
10
 
11
  .page-wrap {
12
- width: 500px;
13
  margin: 50px auto;
14
  background: white;
15
  padding: 10px 30px;
@@ -28,14 +28,24 @@ img.emoji {
28
  padding: 0 18px;
29
  height: 40px;
30
  line-height: 40px;
31
- border-radius: 20px;
32
  cursor: pointer;
33
  transition: background-color 0.2s, color 0.2s;
34
  font-weight: 500;
35
- width: 240px;
36
  font-size: 17px;
37
- margin: auto;
38
- display: block;
 
 
 
 
 
 
 
 
 
 
39
  }
40
 
41
  a.btn__run-demo {
@@ -70,6 +80,12 @@ section {
70
  position: relative;
71
  }
72
  }
 
 
 
 
 
 
73
  }
74
 
75
  .section__examples {
 
9
  }
10
 
11
  .page-wrap {
12
+ width: 725px;
13
  margin: 50px auto;
14
  background: white;
15
  padding: 10px 30px;
 
28
  padding: 0 18px;
29
  height: 40px;
30
  line-height: 40px;
31
+ border-radius: 8px;
32
  cursor: pointer;
33
  transition: background-color 0.2s, color 0.2s;
34
  font-weight: 500;
35
+ width: 195px;
36
  font-size: 17px;
37
+ display: inline-block;
38
+
39
+ &.btn-right {
40
+ margin-left: -5px;
41
+ border-radius: 0 8px 8px 0;
42
+ filter: grayscale(2);
43
+ border-left: 1px solid #2e2e30;
44
+ }
45
+
46
+ &.btn-left {
47
+ border-radius: 8px 0 0 8px;
48
+ }
49
  }
50
 
51
  a.btn__run-demo {
 
80
  position: relative;
81
  }
82
  }
83
+
84
+ .tagline {
85
+ width: 450px;
86
+ margin: 0 auto 25px;
87
+ text-align: center;
88
+ }
89
  }
90
 
91
  .section__examples {
index.html CHANGED
@@ -15,9 +15,11 @@
15
  <div class="page-wrap">
16
  <section class="section__header" id="driver-demo-head">
17
  <h1><span id="logo_emoji" class="emoji">👨‍🔧️</span> <span id="name_driver">Driver</span></h1>
18
- <p class="text-muted">A light-weight, no-dependency, vanilla JavaScript library to drive the user's focus across the
19
  page</p>
20
- <a href="javascript:void(0)" class="btn btn__example btn__dark">Quick Tour</a>
 
 
21
  </section>
22
 
23
  <blockquote>
 
15
  <div class="page-wrap">
16
  <section class="section__header" id="driver-demo-head">
17
  <h1><span id="logo_emoji" class="emoji">👨‍🔧️</span> <span id="name_driver">Driver</span></h1>
18
+ <p class="text-muted tagline">Light-weight, no-dependency, vanilla JavaScript engine to drive user's focus across the
19
  page</p>
20
+
21
+ <a id="animated-tour" href="javascript:void(0)" class="btn btn__example btn__dark btn-left">With Animation</a>
22
+ <a id="boring-tour" href="javascript:void(0)" class="btn btn__example btn__dark btn-right">without Animation</a>
23
  </section>
24
 
25
  <blockquote>