Skip to content

Commit a1623fd

Browse files
committed
📚 add documentation
1 parent 6e338a7 commit a1623fd

File tree

2 files changed

+78
-1
lines changed

2 files changed

+78
-1
lines changed

README.md

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,78 @@
1+
<div align="center">
2+
13
# React UI ScrollSpy
4+
5+
[![npm](https://img.shields.io/npm/v/react-ui-scrollspy.svg)](https://npmjs.com/package/react-ui-scrollspy) [![npm](https://img.shields.io/npm/dm/react-ui-scrollspy.svg)](https://npmjs.com/package/react-ui-scrollspy)
6+
[![License MIT](https://img.shields.io/badge/license-MIT-orange.svg?style=flat)](https://raw.githubusercontent.com/pettiboy/react-ui-scrollspy/main/LICENSE)
7+
[![PRs Welcome](https://img.shields.io/badge/PRs-Welcome-brightgreen.svg)](https://github.com/pettiboy/react-ui-scrollspy/pulls)
8+
9+
![](https://img.shields.io/badge/React-20232A?style=for-the-badge&logo=react&logoColor=61DAFB)
10+
![](https://img.shields.io/badge/TypeScript-007ACC?style=for-the-badge&logo=typescript&logoColor=white)
11+
![](https://img.shields.io/badge/npm-CB3837?style=for-the-badge&logo=npm&logoColor=white)
12+
13+
</div>
14+
15+
## ✨ Installation
16+
17+
```bash
18+
npm install --save react-ui-scrollspy
19+
```
20+
21+
OR
22+
23+
```bash
24+
yarn add react-ui-scrollspy
25+
```
26+
27+
## ⚙️ Getting started
28+
29+
1. In your navigation component
30+
31+
```tsx
32+
<div>
33+
<p data-to-scrollspy-id="first">Section 1</p>
34+
<p data-to-scrollspy-id="second">Section 2</p>
35+
</div>
36+
```
37+
38+
2. Wrap the elements you want to spy on in the `<ScrollSpy>` component.
39+
40+
```tsx
41+
import ScrollSpy from "react-ui-scrollspy";
42+
43+
<ScrollSpy>
44+
<div id="first">
45+
Lorem ipsum dolor sit amet consectetur adipisicing elit. Aut dolores
46+
veritatis doloremque fugit. Soluta aperiam atque inventore deleniti,
47+
voluptatibus non fuga eos magni natus vel, rerum excepturi expedita.
48+
Tempore, vero!
49+
</div>
50+
<div id="second">
51+
Lorem ipsum dolor sit amet consectetur adipisicing elit. Aut dolores
52+
veritatis doloremque fugit. Soluta aperiam atque inventore deleniti,
53+
voluptatibus non fuga eos magni natus vel, rerum excepturi expedita.
54+
Tempore, vero!
55+
</div>
56+
</ScrollSpy>;
57+
```
58+
59+
3. Write styles for when the navigation element which is active in your `index.css`
60+
61+
```css
62+
.active-scroll-spy {
63+
background-color: yellowgreen;
64+
border-radius: 15px;
65+
}
66+
```
67+
68+
## 💡 Props
69+
70+
| Attributes | Type | Description | Default | Required |
71+
| :---------------- | :----------------------------------------- | :--------------------------------------------------------------------------------------------------------------------- | :------ | :------- |
72+
| `scrollThrottle` | `number` | in `milliseconds` to throttle the `onscroll` event. Lower the number, better the response, higher the performance cost | 300 | no |
73+
| `children` | `ReactNode` | - | - | yes |
74+
| `navContainerRef` | `MutableRefObject<HTMLDivElement \| null>` | `ref` to your navigation container containing items with `data-to-scrollspy-id` attributes | - | no |
75+
76+
## 📝 Authors
77+
78+
- Hussain Pettiwala ([@pettiboy](https://github.com/pettiboy))

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-ui-scrollspy",
3-
"version": "0.1.0",
3+
"version": "1.0.0",
44
"description": "## Comands",
55
"main": "dist/index.js",
66
"scripts": {

0 commit comments

Comments
 (0)