Skip to content

Commit b0dc3d8

Browse files
authored
Merge pull request #3 from sakhnyuk/dev
Documentation website based on Dumi
2 parents 15a0332 + 8ab4090 commit b0dc3d8

36 files changed

+12175
-14531
lines changed

.eslintignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
lib
22
**/node_modules
3-
examples/**/server.js

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,8 @@ lib
66
coverage
77
examples/simple/static
88
.idea/
9+
10+
# umi
11+
.umi
12+
.umi-production
13+
.env.local

.npmignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ test
55
examples
66
coverage
77
.idea
8+
docs

.nvmrc

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

.travis.yml

Lines changed: 0 additions & 3 deletions
This file was deleted.

.umirc.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { defineConfig } from 'dumi';
2+
3+
export default defineConfig({
4+
title: 'rc-scrollbar',
5+
mode: 'docs',
6+
logo: '/logo.svg',
7+
favicon: '/favicon.ico',
8+
exportStatic: {},
9+
hash: true,
10+
resolve: {
11+
includes: ['docs'],
12+
},
13+
});

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ This assumes that you’re using [npm](http://npmjs.com/) package manager with a
3232

3333
This is the minimal configuration. [Check out the Documentation for advanced usage](https://github.com/sakhnyuk/rc-scrollbars/tree/master/docs).
3434

35-
```jsx
35+
```javascript
3636
import { Scrollbars } from 'rc-scrollbars';
3737

3838
class App extends Component {
@@ -48,7 +48,7 @@ class App extends Component {
4848

4949
The `<Scrollbars>` component is completely customizable. Check out the following code:
5050

51-
```jsx
51+
```javascript
5252
import { Scrollbars } from 'rc-scrollbars';
5353

5454
class CustomScrollbars extends Component {

docs/README.md

Lines changed: 118 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,118 @@
1-
# Table of Contents
2-
3-
* [Usage](usage.md)
4-
* [Auto hide](usage.md#auto-hide)
5-
* [Auto height](usage.md#auto-height)
6-
* [Working with events](usage.md#events)
7-
* [Universal rendering](usage.md#universal-rendering)
8-
* [Customization](customization.md)
9-
* [API](API.md)
1+
---
2+
title: Getting started
3+
order: 1
4+
---
5+
6+
# rc-scrollbars
7+
rejuvenated project of <a href="https://github.com/malte-wessel/react-custom-scrollbars" target="_blank">react-custom-scrollbars</a>
8+
9+
[![npm](https://img.shields.io/badge/npm-rc--scrollbars-brightgreen.svg?style=flat-square)](https://www.npmjs.com/package/rc-scrollbars)
10+
[![npm version](https://img.shields.io/npm/v/rc-scrollbars.svg?style=flat-square)](https://www.npmjs.com/package/rc-scrollbars)
11+
[![npm downloads](https://img.shields.io/npm/dm/rc-scrollbars.svg?style=flat-square)](https://www.npmjs.com/package/rc-scrollbars)
12+
13+
* frictionless native browser scrolling
14+
* native scrollbars for mobile devices
15+
* [fully customizable](/customization)
16+
* [auto hide](/usage#auto-hide)
17+
* [auto height](/usage#auto-height)
18+
* [universal](/usage#universal-rendering) (runs on client & server)
19+
* `requestAnimationFrame` for 60fps
20+
* no extra stylesheets
21+
* well tested, 100% code coverage
22+
23+
**[Demos](/demo) · [API](/api)**
24+
25+
## Installation
26+
```bash
27+
npm install rc-scrollbars --save
28+
29+
# OR
30+
31+
yarn add rc-scrollbars
32+
```
33+
34+
This assumes that you’re using [npm](http://npmjs.com/) package manager with a module bundler like [Webpack](http://webpack.github.io) or [Browserify](http://browserify.org/) to consume [CommonJS modules](http://webpack.github.io/docs/commonjs.html).
35+
36+
## Usage
37+
38+
This is the minimal configuration. [Check out the Documentation for advanced usage](https://github.com/sakhnyuk/rc-scrollbars/tree/master/docs).
39+
40+
```javascript
41+
import { Scrollbars } from 'rc-scrollbars';
42+
43+
class App extends Component {
44+
render() {
45+
return (
46+
<Scrollbars style={{ width: 500, height: 300 }}>
47+
<p>Some great content...</p>
48+
</Scrollbars>
49+
);
50+
}
51+
}
52+
```
53+
54+
The `<Scrollbars>` component is completely customizable. Check out the following code:
55+
56+
```javascript
57+
import { Scrollbars } from 'rc-scrollbars';
58+
59+
class CustomScrollbars extends Component {
60+
render() {
61+
return (
62+
<Scrollbars
63+
onScroll={this.handleScroll}
64+
onScrollFrame={this.handleScrollFrame}
65+
onScrollStart={this.handleScrollStart}
66+
onScrollStop={this.handleScrollStop}
67+
onUpdate={this.handleUpdate}
68+
renderView={this.renderView}
69+
renderTrackHorizontal={this.renderTrackHorizontal}
70+
renderTrackVertical={this.renderTrackVertical}
71+
renderThumbHorizontal={this.renderThumbHorizontal}
72+
renderThumbVertical={this.renderThumbVertical}
73+
autoHide
74+
autoHideTimeout={1000}
75+
autoHideDuration={200}
76+
autoHeight
77+
autoHeightMin={0}
78+
autoHeightMax={200}
79+
thumbMinSize={30}
80+
universal={true}
81+
{...this.props} />
82+
);
83+
}
84+
}
85+
```
86+
87+
All properties are documented in the [API docs](/API)
88+
89+
## Examples
90+
91+
Run the simple example:
92+
```bash
93+
# Make sure that you've installed the dependencies
94+
yarn install
95+
# Move to example directory
96+
cd example/
97+
yarn install
98+
yarn start
99+
```
100+
101+
## Tests (WIP)
102+
```bash
103+
# Make sure that you've installed the dependencies
104+
yarn install
105+
# Run tests
106+
yarn test
107+
```
108+
109+
### Code Coverage (WIP)
110+
```bash
111+
# Run code coverage. Results can be found in `./coverage`
112+
yarn test:cov
113+
```
114+
115+
116+
## License
117+
118+
MIT

example/src/components/ColoredScrollbars/ColoredScrollbars.js renamed to docs/components/ColoredScrollbars.tsx

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,51 @@
1-
import { Component } from "react";
2-
import { Scrollbars } from "rc-scrollbars";
1+
import { Component, HTMLAttributes } from 'react';
2+
import { Scrollbars } from 'rc-scrollbars';
3+
import { ScrollValues } from 'lib/Scrollbars/types';
4+
5+
type State = {
6+
top: number;
7+
};
38

49
export default class ColoredScrollbars extends Component {
5-
constructor(props, ...rest) {
6-
super(props, ...rest);
10+
state: State;
11+
12+
constructor(props) {
13+
super(props);
714
this.state = { top: 0 };
815
this.handleUpdate = this.handleUpdate.bind(this);
916
this.renderView = this.renderView.bind(this);
1017
this.renderThumb = this.renderThumb.bind(this);
1118
}
1219

13-
handleUpdate(values) {
20+
handleUpdate = (values: ScrollValues) => {
1421
const { top } = values;
1522
this.setState({ top });
16-
}
23+
};
1724

18-
renderView({ style, ...props }) {
25+
renderView = ({ style, ...props }: HTMLAttributes<HTMLDivElement>) => {
1926
const { top } = this.state;
2027
const viewStyle = {
2128
padding: 15,
22-
backgroundColor: `rgb(${Math.round(255 - top * 255)}, ${Math.round(
23-
top * 255
24-
)}, ${Math.round(255)})`,
25-
color: `rgb(${Math.round(255 - top * 255)}, ${Math.round(
26-
255 - top * 255
27-
)}, ${Math.round(255 - top * 255)})`,
29+
backgroundColor: `rgb(${Math.round(255 - top * 255)}, ${Math.round(top * 255)}, ${Math.round(
30+
255,
31+
)})`,
32+
color: `rgb(${Math.round(255 - top * 255)}, ${Math.round(255 - top * 255)}, ${Math.round(
33+
255 - top * 255,
34+
)})`,
2835
};
29-
return (
30-
<div className="box" style={{ ...style, ...viewStyle }} {...props} />
31-
);
32-
}
36+
return <div className="box" style={{ ...style, ...viewStyle }} {...props} />;
37+
};
3338

34-
renderThumb({ style, ...props }) {
39+
renderThumb = ({ style, ...props }: HTMLAttributes<HTMLDivElement>) => {
3540
const { top } = this.state;
3641
const thumbStyle = {
3742
backgroundColor: `rgb(${Math.round(255 - top * 255)}, ${Math.round(
38-
255 - top * 255
43+
255 - top * 255,
3944
)}, ${Math.round(255 - top * 255)})`,
40-
borderRadius: 'inherit'
45+
borderRadius: 'inherit',
4146
};
4247
return <div style={{ ...style, ...thumbStyle }} {...props} />;
43-
}
48+
};
4449

4550
render() {
4651
return (

0 commit comments

Comments
 (0)