kamrify commited on
Commit
25ec032
Β·
1 Parent(s): 00da064

Add examples and UI for the demo page

Browse files
demo/images/separator.png ADDED
demo/{demo.js β†’ scripts/demo.js} RENAMED
@@ -1,11 +1,12 @@
1
  /* eslint-disable */
2
- const sholo = new Sholo({
 
3
  animate: true,
4
  opacity: 0.8,
5
  padding: 5,
6
  });
7
 
8
- sholo.defineSteps([
9
  {
10
  element: '.section__header',
11
  popover: {
@@ -14,6 +15,20 @@ sholo.defineSteps([
14
  position: 'bottom',
15
  },
16
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
  {
18
  element: '.section__how',
19
  popover: {
@@ -43,5 +58,49 @@ sholo.defineSteps([
43
 
44
  document.querySelector('.btn__example')
45
  .addEventListener('click', () => {
46
- sholo.start();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
47
  });
 
1
  /* eslint-disable */
2
+
3
+ const tourSholo = new Sholo({
4
  animate: true,
5
  opacity: 0.8,
6
  padding: 5,
7
  });
8
 
9
+ tourSholo.defineSteps([
10
  {
11
  element: '.section__header',
12
  popover: {
 
15
  position: 'bottom',
16
  },
17
  },
18
+ {
19
+ element: '.btn__dark',
20
+ popover: {
21
+ title: 'This is Button',
22
+ description: 'Yeah I know I dont need to tell that but anyways, we need a step in the listing so yeah!'
23
+ }
24
+ },
25
+ {
26
+ element: '#free-use',
27
+ popover: {
28
+ title: 'Free to Use',
29
+ description: 'Yes, you can use it in your personal or commercial products'
30
+ }
31
+ },
32
  {
33
  element: '.section__how',
34
  popover: {
 
58
 
59
  document.querySelector('.btn__example')
60
  .addEventListener('click', () => {
61
+ tourSholo.start();
62
+ });
63
+
64
+
65
+ document.querySelectorAll('pre code').forEach((element) => {
66
+ hljs.highlightBlock(element);
67
+ });
68
+
69
+
70
+ /////////////////////////////////////////////
71
+ // First example – highlighting without popover
72
+ /////////////////////////////////////////////
73
+ const singleSholoNoPopover = new Sholo();
74
+ document.querySelector('#run-single-element-no-popover')
75
+ .addEventListener('click', (e) => {
76
+ e.preventDefault();
77
+ singleSholoNoPopover.highlight('#single-element-no-popover');
78
+ });
79
+
80
+ /////////////////////////////////////////////
81
+ // Form focus examples
82
+ /////////////////////////////////////////////
83
+ const focusSholo = new Sholo({ padding: 0 });
84
+ const inputIds = ['creation-input', 'creation-input-2', 'creation-input-3', 'creation-input-4'];
85
+ inputIds.forEach(inputId => {
86
+ // Highlight the section on focus
87
+ document.getElementById(inputId).addEventListener('focus', () => {
88
+ focusSholo.highlight(`#${inputId}`);
89
+ });
90
+ });
91
+
92
+ /////////////////////////////////////////////
93
+ // Highlighting single element with popover
94
+ /////////////////////////////////////////////
95
+ const singleSholoWithPopover = new Sholo();
96
+ document.querySelector('#run-single-element-with-popover')
97
+ .addEventListener('click', (e) => {
98
+ e.preventDefault();
99
+ singleSholoWithPopover.highlight({
100
+ element: '#single-element-with-popover',
101
+ popover: {
102
+ title: 'Did you know?',
103
+ description: 'You can add HTML in title or description also!',
104
+ }
105
+ });
106
  });
demo/{emoji.js β†’ scripts/emoji.js} RENAMED
File without changes
demo/{base.scss β†’ styles/base.scss} RENAMED
@@ -50,16 +50,21 @@ label {
50
  p {
51
  margin-top: 0;
52
  margin-bottom: 20px;
 
53
  }
54
 
55
- hr {
56
  display: block;
57
  margin: $global-guttering*1.25 0;
58
  border: 0;
59
  border-bottom: 1px solid #eaeaea;
60
- background: url(https://i.imgur.com/MoU1Mn4.png) repeat-y;
61
- height: 5px;
62
- background-size: cover;
 
 
 
 
63
  }
64
 
65
  h1, h2, h3, h4, h5, h6 {
@@ -85,6 +90,7 @@ a, a:visited, a:focus {
85
  font-size: 14px;
86
  -webkit-appearance: none;
87
  appearance: none;
 
88
  margin-bottom: $global-guttering;
89
  }
90
 
@@ -115,6 +121,7 @@ h6, .h6 {
115
  ul li, ol li {
116
  list-style-type: none;
117
  line-height: 1.5;
 
118
  }
119
 
120
  blockquote {
@@ -124,41 +131,8 @@ blockquote {
124
  border-radius: 10px;
125
  }
126
 
127
- .container {
128
- display: block;
129
- margin: auto;
130
- max-width: 40em;
131
- padding: $global-guttering*2;
132
- @media (max-width: 620px) {
133
- padding: 0;
134
- }
135
- }
136
-
137
- .section {
138
- background-color: #FFFFFF;
139
- padding: $global-guttering;
140
- color: #333;
141
- a, a:visited, a:focus {
142
- color: #00bcd4;
143
- }
144
- }
145
-
146
- .logo {
147
- display: block;
148
- margin-bottom: $global-guttering/2;
149
- }
150
-
151
- .logo__img {
152
- width: 100%;
153
- height: auto;
154
- display: inline-block;
155
- max-width: 100%;
156
- vertical-align: top;
157
- padding: $global-guttering/4 0;
158
- }
159
-
160
- .visible-ie {
161
- display: none;
162
  }
163
 
164
  .zero-bottom {
 
50
  p {
51
  margin-top: 0;
52
  margin-bottom: 20px;
53
+ line-height: 1.5;
54
  }
55
 
56
+ hr, .hr {
57
  display: block;
58
  margin: $global-guttering*1.25 0;
59
  border: 0;
60
  border-bottom: 1px solid #eaeaea;
61
+ height: 1px;
62
+
63
+ &.hr__fancy {
64
+ background: url("./separator.png") repeat-y;
65
+ height: 5px;
66
+ background-size: cover;
67
+ }
68
  }
69
 
70
  h1, h2, h3, h4, h5, h6 {
 
90
  font-size: 14px;
91
  -webkit-appearance: none;
92
  appearance: none;
93
+ outline: none;
94
  margin-bottom: $global-guttering;
95
  }
96
 
 
121
  ul li, ol li {
122
  list-style-type: none;
123
  line-height: 1.5;
124
+ margin-bottom: 3px;
125
  }
126
 
127
  blockquote {
 
131
  border-radius: 10px;
132
  }
133
 
134
+ .top-20 {
135
+ margin-top: 20px;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
136
  }
137
 
138
  .zero-bottom {
demo/{demo.scss β†’ styles/demo.scss} RENAMED
@@ -1,5 +1,5 @@
1
- @import "base";
2
- @import "../src/sholo";
3
 
4
  $container-width: 500px !default;
5
  $logo-font-size: 55px !default;
@@ -23,14 +23,12 @@ img.emoji {
23
  padding: 10px 30px;
24
  border-radius: 5px;
25
  color: #333333;
26
- }
27
 
28
- .btn {
29
- font-size: $button-font-size;
30
- padding: 7px 10px;
31
- border-radius: 3px;
32
 
33
- &.btn__dark {
34
  color: #FFFFFF;
35
  background-color: #F44336;
36
  padding: 0 18px;
@@ -45,6 +43,16 @@ img.emoji {
45
  margin: auto;
46
  display: block;
47
  }
 
 
 
 
 
 
 
 
 
 
48
  }
49
 
50
  section {
@@ -67,4 +75,24 @@ section {
67
  position: relative;
68
  }
69
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
70
  }
 
1
+ @import "./base";
2
+ @import "../../src/sholo";
3
 
4
  $container-width: 500px !default;
5
  $logo-font-size: 55px !default;
 
23
  padding: 10px 30px;
24
  border-radius: 5px;
25
  color: #333333;
 
26
 
27
+ a, a:visited, a:focus {
28
+ color: #333333;
29
+ }
 
30
 
31
+ a.btn__dark {
32
  color: #FFFFFF;
33
  background-color: #F44336;
34
  padding: 0 18px;
 
43
  margin: auto;
44
  display: block;
45
  }
46
+
47
+ a.btn__run-demo {
48
+ background: #f54336;
49
+ padding: 5px;
50
+ border-radius: 20px;
51
+ color: white;
52
+ display: block;
53
+ margin: 15px 0 10px;
54
+ text-align: center;
55
+ }
56
  }
57
 
58
  section {
 
75
  position: relative;
76
  }
77
  }
78
+ }
79
+
80
+ .section__examples {
81
+ .section__example {
82
+ margin-bottom: 20px;
83
+ }
84
+
85
+ #creation-input {
86
+ margin-top: 20px;
87
+ }
88
+
89
+ input {
90
+ padding: 10px;
91
+ background-color: #fafbfc;
92
+ border: 3px solid #e1e4e8;
93
+ border-radius: 3px;
94
+ box-shadow: inset 0 0 10px rgba(27,31,35,0.05);
95
+ margin-bottom: 0;
96
+ margin-top: 7px;
97
+ }
98
  }
index.html CHANGED
@@ -7,66 +7,108 @@
7
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
8
  <title>Sholo</title>
9
  <link rel="stylesheet" href="./dist/demo.css">
 
10
  </head>
11
  <body>
12
  <div class="page-wrap">
13
  <section class="section__header" data-sholo="Hey welcome to presenter!">
14
  <h1><span class="emoji">πŸ‘¨β€πŸ”§οΈ</span> Driver</h1>
15
- <p class="text-muted">A light-weight, no-dependency, vanilla JavaScript library to drive the user's focus across the page</p>
16
- <a href="javascript:void(0)" class="btn btn__example btn__dark">Quick Example</a>
 
17
  </section>
18
 
19
  <blockquote>
20
  <p>A lightweight (~4kb gzipped) yet powerful JavaScript engine that helps you drive the user's focus on page.</p>
21
- <p class="zero-bottom">Some sample use-cases can be creating powerful feature introductions, call-to-action components, focus shifters etc.</p>
 
22
  </blockquote>
23
 
24
  <section class="section__purpose">
25
- <h3>Features</h3>
 
 
26
  <ul>
27
- <li>Highlight any item on page</li>
28
- <li>Block user interactions</li>
29
- <li>Create feature introductions</li>
30
- <li>User Friendly – Controllable by keys</li>
31
- <li>Free for personal and commercial use</li>
32
- <li>Lightweight – Only ~4kb when gzipped</li>
33
- <li>Supports all major browsers</li>
34
- <li></li>
 
35
  </ul>
36
  </section>
37
- <hr>
38
  <section class="section__how">
39
  <h3>How does it do that?</h3>
40
- <p>Ever heard of magic? ...it is not that, it just uses some canvas manipulation to put the focus on some
41
- element</p>
42
- <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Animi assumenda, at consectetur cupiditate inventore
43
- ipsa molestias, natus nulla odit optio pariatur perspiciatis, quae quam quasi quibusdam recusandae repellendus
44
- reprehenderit tempora!</p>
45
  </section>
 
46
  <section class="section__examples">
47
  <h3>Can you show some Examples?</h3>
48
- <p>Here are some of the examples</p>
49
- <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Animi assumenda, at consectetur cupiditate inventore
50
- ipsa molestias, natus nulla odit optio pariatur perspiciatis, quae quam quasi quibusdam recusandae repellendus
51
- reprehenderit tempora!</p>
52
- </section>
53
- <section class="section__learn">
54
- <h3>I want to learn more</h3>
55
- <p>Here are some of the examples</p>
56
- <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Animi assumenda, at consectetur cupiditate inventore
57
- ipsa molestias, natus nulla odit optio pariatur perspiciatis, quae quam quasi quibusdam recusandae repellendus
58
- reprehenderit tempora!</p>
59
- </section>
60
- <section class="section__contributing">
61
- <h3>Contributing</h3>
62
- <p>Here are some of the examples</p>
63
- <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Animi assumenda, at consectetur cupiditate inventore
64
- ipsa molestias, natus nulla odit optio pariatur perspiciatis, quae quam quasi quibusdam recusandae repellendus
65
- reprehenderit tempora!</p>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
66
  </section>
67
  </div>
68
 
69
  <script src="//twemoji.maxcdn.com/2/twemoji.min.js?2.5"></script>
 
70
 
71
  <script src="./dist/sholo.js"></script>
72
  <script src="./dist/demo.js"></script>
 
7
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
8
  <title>Sholo</title>
9
  <link rel="stylesheet" href="./dist/demo.css">
10
+ <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/monokai.min.css">
11
  </head>
12
  <body>
13
  <div class="page-wrap">
14
  <section class="section__header" data-sholo="Hey welcome to presenter!">
15
  <h1><span class="emoji">πŸ‘¨β€πŸ”§οΈ</span> Driver</h1>
16
+ <p class="text-muted">A light-weight, no-dependency, vanilla JavaScript library to drive the user's focus across the
17
+ page</p>
18
+ <a href="javascript:void(0)" class="btn btn__example btn__dark">Quick Tour</a>
19
  </section>
20
 
21
  <blockquote>
22
  <p>A lightweight (~4kb gzipped) yet powerful JavaScript engine that helps you drive the user's focus on page.</p>
23
+ <p class="zero-bottom">Some sample use-cases can be creating powerful feature introductions, call-to-action
24
+ components, focus shifters etc.</p>
25
  </blockquote>
26
 
27
  <section class="section__purpose">
28
+ <h3>What are the features?</h3>
29
+ <p>Driver is compatible with all the major browsers and can be used for any of your overlay needs. Feature
30
+ introductions, focus shifters, call-to-action are just a few examples.</p>
31
  <ul>
32
+ <li>πŸ”† <strong>Highlight</strong> any item on page</li>
33
+ <li>βœ‹ <strong>Block user interactions</strong></li>
34
+ <li>πŸ“£ Create <strong>feature introductions</strong></li>
35
+ <li>πŸ‘“ Add <strong>focus shifters</strong> for users</li>
36
+ <li>πŸ› οΈ Highly customizable – <strong>Use it anywhere</strong> for overlay</li>
37
+ <li>⌨️ User Friendly – <strong>Controllable by keys</strong></li>
38
+ <li id="free-use">πŸ†“ <strong>MIT Licensed</strong> – Free for personal and commercial use</li>
39
+ <li>πŸ•ŠοΈ Lightweight – Only <strong>~4kb</strong> when gzipped</li>
40
+ <li>πŸŒ€ <strong>Consistent behavior</strong> across all major browsers</li>
41
  </ul>
42
  </section>
43
+ <hr class="hr__fancy">
44
  <section class="section__how">
45
  <h3>How does it do that?</h3>
46
+ <p>In it simplest, it puts the canvas on top of the whole page and then cuts the part that is over the element to be
47
+ highlighted and provides you several hooks when highlighting, highlighted or un-highlighting elements making it
48
+ highly customizable.</p>
 
 
49
  </section>
50
+ <hr class="hr__fancy">
51
  <section class="section__examples">
52
  <h3>Can you show some Examples?</h3>
53
+ <p>Below you find some of the examples and sample use-cases on how you can use it. Run by clicking the
54
+ <code>RUN</code> button.</p>
55
+ <div id="single-element-no-popover" class="section__example">
56
+ <h4>Highlighting a Single Element – Without Popover</h4>
57
+ <p class="zero-bottom">If all you want is just highlight a single element, you can do that simply by passing the
58
+ selector</p>
59
+ <a href="#" class="btn__run-demo" id="run-single-element-no-popover">Run it</a>
60
+ <pre><code class="javascript">const driver = new Driver();
61
+ driver.highlight('#create-post');
62
+ </code></pre>
63
+ </div>
64
+
65
+ <hr class="hr__fancy">
66
+
67
+ <div class="section__example">
68
+ <p>A <strong>real world use-case</strong> for this could be highlighting an element when user is interacting with
69
+ it</p>
70
+ <pre><code class="javascript">const focusDriver = new Driver();
71
+
72
+ // Highlight the section on focus
73
+ document.getElementById('creation-input')
74
+ .addEventListener('focus', (e) => {
75
+ focusDriver.focus('#creation-input');
76
+ });
77
+ </code></pre>
78
+ <p class="top-20">Focus any of the inputs and see how it moves the highlight from one element to the other</p>
79
+ <div id="creation-forms">
80
+ <input type="text" id="creation-input" class="form-control" placeholder="Focus any of the inputs">
81
+ <input type="text" id="creation-input-2" class="form-control" placeholder="Focus any of the inputs">
82
+ <input type="text" id="creation-input-3" class="form-control" placeholder="Focus any of the inputs">
83
+ <input type="text" id="creation-input-4" class="form-control" placeholder="Focus any of the inputs">
84
+ </div>
85
+ </div>
86
+
87
+ <p>You can also turn off the animation or set the padding around the corner. More on it later.</p>
88
+
89
+ <hr class="hr__fancy">
90
+
91
+ <div id="single-element-with-popover" class="section__example">
92
+ <h4>Highlighting a Single Element – With Popover</h4>
93
+ <p>If you would like to show some details alongside the highlighted element, you can do that easily by specifying
94
+ title and description</p>
95
+ <a href="#" class="btn__run-demo" id="run-single-element-with-popover">Run it</a>
96
+ <pre><code class="javascript">const driver = new Driver();
97
+ driver.highlight({
98
+ element: '#some-element',
99
+ popover: {
100
+ title: 'Title for the Popover',
101
+ description: 'Description for it',
102
+ }
103
+ });
104
+ </code></pre>
105
+ </div>
106
+
107
  </section>
108
  </div>
109
 
110
  <script src="//twemoji.maxcdn.com/2/twemoji.min.js?2.5"></script>
111
+ <script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js"></script>
112
 
113
  <script src="./dist/sholo.js"></script>
114
  <script src="./dist/demo.js"></script>
webpack.config.dev.js CHANGED
@@ -6,7 +6,7 @@ module.exports = {
6
  mode: 'development',
7
  entry: [
8
  'webpack-dev-server/client?http://localhost:3000',
9
- './demo/demo.scss',
10
  './src/index.js',
11
  ],
12
  output: {
@@ -39,7 +39,7 @@ module.exports = {
39
  },
40
  {
41
  test: /.scss$/,
42
- loader: ExtractTextPlugin.extract(['css-loader', 'sass-loader']),
43
  },
44
  ],
45
  },
@@ -49,8 +49,9 @@ module.exports = {
49
  allChunks: true,
50
  }),
51
  new CopyWebpackPlugin([
52
- './demo/demo.js',
53
- './demo/emoji.js',
 
54
  ]),
55
  ],
56
  stats: {
 
6
  mode: 'development',
7
  entry: [
8
  'webpack-dev-server/client?http://localhost:3000',
9
+ './demo/styles/demo.scss',
10
  './src/index.js',
11
  ],
12
  output: {
 
39
  },
40
  {
41
  test: /.scss$/,
42
+ loader: ExtractTextPlugin.extract(['css-loader?url=false', 'sass-loader']),
43
  },
44
  ],
45
  },
 
49
  allChunks: true,
50
  }),
51
  new CopyWebpackPlugin([
52
+ './demo/scripts/emoji.js',
53
+ './demo/scripts/demo.js',
54
+ './demo/images/separator.png',
55
  ]),
56
  ],
57
  stats: {