Update demo and webpack build
Browse files- .gitignore +2 -1
- demo/scripts/demo.js +29 -1
- index.html +33 -5
- package.json +1 -0
- webpack.config.dev.js +18 -8
.gitignore
CHANGED
@@ -4,4 +4,5 @@ npm-debug.log
|
|
4 |
.idea
|
5 |
.vscode
|
6 |
package-lock.json
|
7 |
-
yarn-error.log
|
|
|
|
4 |
.idea
|
5 |
.vscode
|
6 |
package-lock.json
|
7 |
+
yarn-error.log
|
8 |
+
dist/demo
|
demo/scripts/demo.js
CHANGED
@@ -145,7 +145,7 @@ document.addEventListener("DOMContentLoaded", function () {
|
|
145 |
/////////////////////////////////////////////
|
146 |
// Form focus examples
|
147 |
/////////////////////////////////////////////
|
148 |
-
const focusDriver = new Driver({
|
149 |
const inputIds = ['creation-input', 'creation-input-2', 'creation-input-3', 'creation-input-4'];
|
150 |
inputIds.forEach(inputId => {
|
151 |
// Highlight the section on focus
|
@@ -293,6 +293,34 @@ document.addEventListener("DOMContentLoaded", function () {
|
|
293 |
});
|
294 |
});
|
295 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
296 |
/////////////////////////////////////////////////////
|
297 |
// Highlighting single element with popover position
|
298 |
/////////////////////////////////////////////////////
|
|
|
145 |
/////////////////////////////////////////////
|
146 |
// Form focus examples
|
147 |
/////////////////////////////////////////////
|
148 |
+
const focusDriver = new Driver({padding: 0});
|
149 |
const inputIds = ['creation-input', 'creation-input-2', 'creation-input-3', 'creation-input-4'];
|
150 |
inputIds.forEach(inputId => {
|
151 |
// Highlight the section on focus
|
|
|
293 |
});
|
294 |
});
|
295 |
|
296 |
+
/////////////////////////////////////////////
|
297 |
+
// Single no close demo
|
298 |
+
/////////////////////////////////////////////
|
299 |
+
const singleNoClose = new Driver({
|
300 |
+
allowClose: false,
|
301 |
+
position: 'top'
|
302 |
+
});
|
303 |
+
|
304 |
+
singleNoClose.defineSteps([{
|
305 |
+
element: '#single-element-no-close',
|
306 |
+
popover: {
|
307 |
+
title: 'Uh-huh!',
|
308 |
+
description: 'You cannot close by clicking outside'
|
309 |
+
}
|
310 |
+
}, {
|
311 |
+
element: '#third-element-introduction',
|
312 |
+
popover: {
|
313 |
+
title: 'Title on Popover',
|
314 |
+
description: 'Body of the popover',
|
315 |
+
position: 'top'
|
316 |
+
}
|
317 |
+
}]);
|
318 |
+
|
319 |
+
document.querySelector('#run-single-element-no-close').addEventListener('click', function (e) {
|
320 |
+
e.preventDefault();
|
321 |
+
singleNoClose.start();
|
322 |
+
});
|
323 |
+
|
324 |
/////////////////////////////////////////////////////
|
325 |
// Highlighting single element with popover position
|
326 |
/////////////////////////////////////////////////////
|
index.html
CHANGED
@@ -6,9 +6,9 @@
|
|
6 |
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
|
7 |
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
8 |
<title>Driver</title>
|
9 |
-
<meta name=description itemprop=description
|
10 |
content="A light-weight, no-dependency, vanilla JavaScript library to drive the user's focus across the page"/>
|
11 |
-
<link rel="stylesheet" href="./dist/demo.css">
|
12 |
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/monokai.min.css">
|
13 |
</head>
|
14 |
<body>
|
@@ -167,7 +167,28 @@ driver.highlight({
|
|
167 |
<p class="top-20">And of course it can be any valid HTML.</p>
|
168 |
|
169 |
<hr class="hr__fancy">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
170 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
171 |
<div id="third-element-introduction" class="section__example">
|
172 |
<h4 id="first-element-introduction">Creating Feature Introductions</h4>
|
173 |
<p id="second-para-feature-introductions">You can also make powerful feature introductions to guide the users
|
@@ -343,8 +364,15 @@ activeElement.getNode(); // Gets the DOM Element behind this element
|
|
343 |
<script src="//twemoji.maxcdn.com/2/twemoji.min.js?2.5"></script>
|
344 |
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js"></script>
|
345 |
|
346 |
-
<script src="./dist/driver.js"></script>
|
347 |
-
|
348 |
-
<script
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
349 |
</body>
|
350 |
</html>
|
|
|
6 |
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
|
7 |
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
8 |
<title>Driver</title>
|
9 |
+
<meta name="description" itemprop="description"
|
10 |
content="A light-weight, no-dependency, vanilla JavaScript library to drive the user's focus across the page"/>
|
11 |
+
<link rel="stylesheet" href="./dist/demo/driver-demo.css">
|
12 |
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/monokai.min.css">
|
13 |
</head>
|
14 |
<body>
|
|
|
167 |
<p class="top-20">And of course it can be any valid HTML.</p>
|
168 |
|
169 |
<hr class="hr__fancy">
|
170 |
+
<div id="single-element-no-close" class="section__example">
|
171 |
+
<h4>Disable Close on Outside Click</h4>
|
172 |
+
<p>By default, driver.js gets reset if user clicks outside the highlighted element, you can disable this:</p>
|
173 |
+
<a href="#" class="btn__run-demo" id="run-single-element-no-close">Show Demo</a>
|
174 |
+
<pre><code class="javascript">const driver = new Driver({
|
175 |
+
allowClose: false,
|
176 |
+
});
|
177 |
|
178 |
+
driver.highlight({
|
179 |
+
element: '#some-element',
|
180 |
+
popover: {
|
181 |
+
title: '<em>An italicized title</em>',
|
182 |
+
description: 'Description may also contain <strong>HTML</strong>'
|
183 |
+
}
|
184 |
+
});
|
185 |
+
</code></pre>
|
186 |
+
<p class="top-20">
|
187 |
+
If you use this option, for multi-step driver, it would close after you are done with the popover or you can close it programmatically. For single element popover, you need to close it properly, otherwise it won't be closed
|
188 |
+
</p>
|
189 |
+
<pre><code class="javascript">driver.reset()</code></div>
|
190 |
+
|
191 |
+
<hr class="hr__fancy">
|
192 |
<div id="third-element-introduction" class="section__example">
|
193 |
<h4 id="first-element-introduction">Creating Feature Introductions</h4>
|
194 |
<p id="second-para-feature-introductions">You can also make powerful feature introductions to guide the users
|
|
|
364 |
<script src="//twemoji.maxcdn.com/2/twemoji.min.js?2.5"></script>
|
365 |
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js"></script>
|
366 |
|
367 |
+
<script src="./dist/demo/driver-demo.js"></script>
|
368 |
+
|
369 |
+
<script>
|
370 |
+
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
371 |
+
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
372 |
+
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
373 |
+
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
|
374 |
+
ga('create', 'UA-58155965-1', 'auto');
|
375 |
+
ga('send', 'pageview');
|
376 |
+
</script>
|
377 |
</body>
|
378 |
</html>
|
package.json
CHANGED
@@ -6,6 +6,7 @@
|
|
6 |
"types": "types/index.d.ts",
|
7 |
"scripts": {
|
8 |
"start": "node server.js",
|
|
|
9 |
"build": "webpack --config webpack.config.prod.js"
|
10 |
},
|
11 |
"bugs": {
|
|
|
6 |
"types": "types/index.d.ts",
|
7 |
"scripts": {
|
8 |
"start": "node server.js",
|
9 |
+
"build-demo": "NODE_ENV=production webpack --config webpack.config.dev.js",
|
10 |
"build": "webpack --config webpack.config.prod.js"
|
11 |
},
|
12 |
"bugs": {
|
webpack.config.dev.js
CHANGED
@@ -2,17 +2,23 @@ const path = require('path');
|
|
2 |
const CopyWebpackPlugin = require('copy-webpack-plugin');
|
3 |
const ExtractTextPlugin = require('extract-text-webpack-plugin');
|
4 |
|
|
|
|
|
|
|
|
|
5 |
module.exports = {
|
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: {
|
13 |
-
path: path.join(__dirname, '/dist'),
|
14 |
-
publicPath: '/dist/',
|
15 |
-
filename:
|
16 |
libraryTarget: 'umd',
|
17 |
library: 'Driver',
|
18 |
},
|
@@ -49,18 +55,22 @@ module.exports = {
|
|
49 |
},
|
50 |
{
|
51 |
test: /.scss$/,
|
52 |
-
loader: ExtractTextPlugin.extract([
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
},
|
54 |
],
|
55 |
},
|
56 |
plugins: [
|
57 |
new ExtractTextPlugin({
|
58 |
-
filename:
|
59 |
allChunks: true,
|
60 |
}),
|
61 |
new CopyWebpackPlugin([
|
62 |
-
'./demo/scripts/emoji.js',
|
63 |
-
'./demo/scripts/demo.js',
|
64 |
'./demo/images/separator.png',
|
65 |
]),
|
66 |
],
|
|
|
2 |
const CopyWebpackPlugin = require('copy-webpack-plugin');
|
3 |
const ExtractTextPlugin = require('extract-text-webpack-plugin');
|
4 |
|
5 |
+
const isProduction = process.env.NODE_ENV === 'production';
|
6 |
+
const scriptFileName = isProduction ? 'driver-demo.min.js' : 'driver-demo.js';
|
7 |
+
const styleFileName = isProduction ? 'driver-demo.min.css' : 'driver-demo.css';
|
8 |
+
|
9 |
module.exports = {
|
10 |
+
mode: isProduction ? 'production' : 'development',
|
11 |
entry: [
|
12 |
'webpack-dev-server/client?http://localhost:3000',
|
13 |
'./demo/styles/demo.scss',
|
14 |
+
'./demo/scripts/emoji.js',
|
15 |
+
'./demo/scripts/demo.js',
|
16 |
'./src/index.js',
|
17 |
],
|
18 |
output: {
|
19 |
+
path: path.join(__dirname, '/dist/demo'),
|
20 |
+
publicPath: '/dist/demo/',
|
21 |
+
filename: scriptFileName,
|
22 |
libraryTarget: 'umd',
|
23 |
library: 'Driver',
|
24 |
},
|
|
|
55 |
},
|
56 |
{
|
57 |
test: /.scss$/,
|
58 |
+
loader: ExtractTextPlugin.extract([
|
59 |
+
{
|
60 |
+
loader: 'css-loader',
|
61 |
+
options: { minimize: isProduction, url: false },
|
62 |
+
},
|
63 |
+
'sass-loader',
|
64 |
+
]),
|
65 |
},
|
66 |
],
|
67 |
},
|
68 |
plugins: [
|
69 |
new ExtractTextPlugin({
|
70 |
+
filename: styleFileName,
|
71 |
allChunks: true,
|
72 |
}),
|
73 |
new CopyWebpackPlugin([
|
|
|
|
|
74 |
'./demo/images/separator.png',
|
75 |
]),
|
76 |
],
|