Skip to content

Commit f9eeeec

Browse files
committed
Add demo, update documentation
1 parent cae6291 commit f9eeeec

File tree

3 files changed

+81
-3
lines changed

3 files changed

+81
-3
lines changed

README.md

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ NProgress.configure({ parent: "#container" });
238238
Colors can be customized using CSS variables.
239239

240240
```css
241-
:root {
241+
#nprogress {
242242
--nprogress-color: #29d;
243243
--nprogress-height: 2px;
244244
--nprogress-spinner-opacity: 1;
@@ -247,6 +247,30 @@ Colors can be customized using CSS variables.
247247
}
248248
```
249249

250+
## Customization examples
251+
252+
<summary>
253+
<details>Hiding the spinner</details>
254+
255+
```css
256+
#nprogress {
257+
--nprogress-spinner-opacity: 0;
258+
}
259+
```
260+
261+
</summary>
262+
263+
<summary>
264+
<details>Changing the color</details>
265+
266+
```css
267+
#nprogress {
268+
--nprogress-color: #29d;
269+
}
270+
```
271+
272+
</summary>
273+
250274
## Resources
251275

252276
- [New UI Pattern: Website Loading Bars](http://www.usabilitypost.com/2013/08/19/new-ui-pattern-website-loading-bars/) (usabilitypost.com)

demo.html

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8" />
5+
<script src="dist/nprogress.umd.js"></script>
6+
<link rel="stylesheet" href="css/nprogress.css">
7+
<style data-js-dynamic-style></style>
8+
</head>
9+
<body>
10+
<div class="actions">
11+
<button data-js-start>Start</button>
12+
<button data-js-done>Done</button>
13+
<button data-js-style-0>Reset</button>
14+
<button data-js-style-1>Style 1</button>
15+
</div>
16+
17+
<script>
18+
function qs(selector) {
19+
return document.querySelector(selector);
20+
}
21+
22+
console.log('NProgress demo')
23+
24+
qs("[data-js-start]").addEventListener("click", () => {
25+
NProgress.start();
26+
});
27+
28+
qs("[data-js-done]").addEventListener("click", () => {
29+
NProgress.done();
30+
});
31+
32+
qs("[data-js-style-0]").addEventListener("click", () => {
33+
qs("[data-js-dynamic-style]").innerHTML = "";
34+
});
35+
36+
qs("[data-js-style-1]").addEventListener("click", () => {
37+
qs("[data-js-dynamic-style]").innerHTML = `
38+
#nprogress {
39+
--nprogress-color: #f00;
40+
--nprogress-height: 1px;
41+
--nprogress-spinner-size: 32px;
42+
--nprogress-spinner-stroke-width: 3px;
43+
}
44+
`;
45+
});
46+
</script>
47+
</body>
48+
</html>

package.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@
1616
"microbundle": "^0.11.0",
1717
"prettier": "^2.0.4"
1818
},
19+
"files": [
20+
"demo.html",
21+
"dist",
22+
"css",
23+
"src"
24+
],
1925
"homepage": "https://github.com/rstacruz/nprogress#readme",
2026
"keywords": [
2127
"bar",
@@ -35,8 +41,8 @@
3541
"url": "git+https://github.com/rstacruz/nprogress.git"
3642
},
3743
"scripts": {
38-
"build": "microbundle",
39-
"dev": "microbundle watch",
44+
"build": "microbundle --name NProgress",
45+
"dev": "npm run build -- watch",
4046
"format": "prettier --write 'src/*.js' 'css/*.{css,scss}'",
4147
"prettier:check": "prettier --check 'src/*.js' 'css/*.{css,scss}'",
4248
"test": "jest"

0 commit comments

Comments
 (0)