Skip to content

Commit ebbf121

Browse files
authored
Merge pull request #16 from StephenWeiXu/develop
Move example app into package for easier testing
2 parents 22f9a41 + 4f4b451 commit ebbf121

File tree

17 files changed

+5159
-698
lines changed

17 files changed

+5159
-698
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
11
/node_modules
2+
build/
3+
dist/
4+
.python-version

README.md

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
`react-scrollspy-nav` is a React component that provides smooth scrolling navigation to the page. It also accounts for the factor that a React app may use different React router and therefore has different url patterns (for example the hash pathname in `HashRouter`).
44

5-
See the [Demo](https://StephenWeiXu.github.io/react-scrollspy-nav-example).
5+
See the [Demo](https://stephenweixu.github.io/react-scrollspy-nav).
66

77
## Installation
88
`npm install react-scrollspy-nav`
@@ -16,22 +16,20 @@ class App extends Component {
1616
render() {
1717
return (
1818
<div>
19-
<div>
20-
<ScrollspyNav
21-
scrollTargetIds={["section_1", "section_2", "section_3"]}
22-
offset={100}
23-
activeNavClass="is-active"
24-
scrollDuration="1000"
25-
headerBackground="true"
26-
>
27-
<ul>
28-
<li><a href="/"><span>Home</span></a></li>
29-
<li><a href="#section_1"><span>Section 1</span></a></li>
30-
<li><a href="#section_2"><span>Section 2</span></a></li>
31-
<li><a href="#section_3"><span>Section 3</span></a></li>
32-
</ul>
33-
</ScrollspyNav>
34-
</div>
19+
<ScrollspyNav
20+
scrollTargetIds={["section_1", "section_2", "section_3"]}
21+
offset={100}
22+
activeNavClass="is-active"
23+
scrollDuration="1000"
24+
headerBackground="true"
25+
>
26+
<ul>
27+
<li><a href="/"><span>Home</span></a></li>
28+
<li><a href="#section_1"><span>Section 1</span></a></li>
29+
<li><a href="#section_2"><span>Section 2</span></a></li>
30+
<li><a href="#section_3"><span>Section 3</span></a></li>
31+
</ul>
32+
</ScrollspyNav>
3533
3634
<div>
3735
<div style={{"height": "400px"}}><span>Welcome!</span></div>
@@ -60,7 +58,7 @@ Props that can be passed to Component `ScrollspyNav` for configuration.
6058
| Name | Type | Description | Example Value |
6159
|------|------|------| ------ |
6260
| scrollTargetIds | Array | List of scroll targets ids | ["section_1", "section_2", "section_3"] |
63-
| offset | Number | offset pixels to the scrollTargetIds. Default is 0 | 100 |
61+
| offset | Number | Offset pixels to the scrollTargetIds. Default is 0 | 100 |
6462
| activeNavClass | String | Class name for styling the nav link that's currently active | "is-active" |
6563
| scrollDuration | String | Scroll duration for controlling how fast the nav click scrolls to its section. Default is "1000" | "1000" |
6664
| headerBackground | String | If header has background color or not, for accurate scroll position, Default is "false" | "true" |

build/index.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

markdown/example.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
```javascript
2+
import React, { Component } from "react";
3+
import ScrollspyNav from "react-scrollspy-nav";
4+
5+
class App extends Component {
6+
render() {
7+
return (
8+
<div>
9+
<ScrollspyNav
10+
scrollTargetIds={["section_1", "section_2", "section_3"]}
11+
activeNavClass="is-active"
12+
>
13+
<ul>
14+
<li><a href="/"><span>Home</span></a></li>
15+
<li><a href="#section_1"><span>Section 1</span></a></li>
16+
<li><a href="#section_2"><span>Section 2</span></a></li>
17+
<li><a href="#section_3"><span>Section 3</span></a></li>
18+
</ul>
19+
</ScrollspyNav>
20+
21+
<div>
22+
<div style={{"height": "400px"}}><span>Welcome!</span></div>
23+
<div id="section_1" style={{"height": "500px"}}><span>Section 1</span></div>
24+
<div id="section_2" style={{"height": "500px"}}><span>Section 2</span></div>
25+
<div id="section_3" style={{"height": "500px"}}><span>Section 3</span></div>
26+
</div>
27+
</div>
28+
);
29+
}
30+
}
31+
32+
export default App;
33+
34+
```

0 commit comments

Comments
 (0)