Skip to content

Commit 8bed0f5

Browse files
authored
docs: Use dumi (#349)
* docs: Use dumi * chore: tmp fix * chore: fix dev * chore: more config
1 parent db8b843 commit 8bed0f5

13 files changed

+78
-43
lines changed

.gitignore

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,10 @@ coverage
2727
yarn.lock
2828
/es/
2929
package-lock.json
30-
.doc
30+
.doc
31+
32+
# umi
33+
.umi
34+
.umi-production
35+
.umi-test
36+
.env.local

.umirc.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// more config: https://d.umijs.org/config
2+
import { defineConfig } from 'dumi';
3+
4+
export default defineConfig({
5+
title: 'rc-util',
6+
favicon: 'https://avatars0.githubusercontent.com/u/9441414?s=200&v=4',
7+
logo: 'https://avatars0.githubusercontent.com/u/9441414?s=200&v=4',
8+
outputPath: '.doc',
9+
exportStatic: {},
10+
styles: [
11+
`
12+
.markdown table {
13+
width: auto !important;
14+
}
15+
`,
16+
],
17+
});

README.md

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Common Utils For React Component.
3232
3333
Create a function which will call all the functions with it's arguments from left to right.
3434

35-
```jsx
35+
```jsx|pure
3636
import createChainedFunction from 'rc-util/lib/createChainedFunction';
3737
```
3838

@@ -42,7 +42,7 @@ import createChainedFunction from 'rc-util/lib/createChainedFunction';
4242
4343
Log an error message to warn developers that `prop` is deprecated.
4444

45-
```jsx
45+
```jsx|pure
4646
import deprecated from 'rc-util/lib/deprecated';
4747
```
4848

@@ -52,7 +52,7 @@ import deprecated from 'rc-util/lib/deprecated';
5252
5353
To generate a mixin which will render specific component into specific container automatically.
5454

55-
```jsx
55+
```jsx|pure
5656
import getContainerRenderMixin from 'rc-util/lib/getContainerRenderMixin';
5757
```
5858

@@ -71,7 +71,7 @@ Fields in `config` and their meanings.
7171

7272
Render children to the specific container;
7373

74-
```jsx
74+
```jsx|pure
7575
import Portal from 'rc-util/lib/Portal';
7676
```
7777

@@ -88,7 +88,7 @@ Props:
8888
8989
Get the width of scrollbar.
9090

91-
```jsx
91+
```jsx|pure
9292
import getScrollBarSize from 'rc-util/lib/getScrollBarSize';
9393
```
9494

@@ -98,7 +98,7 @@ import getScrollBarSize from 'rc-util/lib/getScrollBarSize';
9898
9999
To generate a global unique id across current application.
100100

101-
```jsx
101+
```jsx|pure
102102
import guid from 'rc-util/lib/guid';
103103
```
104104

@@ -108,7 +108,7 @@ import guid from 'rc-util/lib/guid';
108108
109109
Pick valid HTML attributes and events from props.
110110

111-
```jsx
111+
```jsx|pure
112112
import pickAttrs from 'rc-util/lib/pickAttrs';
113113
```
114114

@@ -118,7 +118,7 @@ import pickAttrs from 'rc-util/lib/pickAttrs';
118118
119119
A shallow wrapper of `console.warn`.
120120

121-
```jsx
121+
```jsx|pure
122122
import warn from 'rc-util/lib/warn';
123123
```
124124

@@ -128,7 +128,7 @@ import warn from 'rc-util/lib/warn';
128128
129129
A shallow wrapper of [warning](https://github.com/BerkeleyTrue/warning), but only warning once for the same message.
130130

131-
```jsx
131+
```jsx|pure
132132
import warning, { noteOnce } from 'rc-util/lib/warning';
133133
134134
warning(false, '[antd Component] test hello world');
@@ -147,7 +147,7 @@ A collection of functions to operate React elements' children.
147147
148148
Return a shallow copy of children.
149149

150-
```jsx
150+
```jsx|pure
151151
import mapSelf from 'rc-util/lib/Children/mapSelf';
152152
```
153153

@@ -157,7 +157,7 @@ import mapSelf from 'rc-util/lib/Children/mapSelf';
157157
158158
Convert children into an array.
159159

160-
```jsx
160+
```jsx|pure
161161
import toArray from 'rc-util/lib/Children/toArray';
162162
```
163163

@@ -171,7 +171,7 @@ A collection of functions to operate DOM elements.
171171
172172
A shallow wrapper of [add-dom-event-listener](https://github.com/yiminghe/add-dom-event-listener).
173173

174-
```jsx
174+
```jsx|pure
175175
import addEventlistener from 'rc-util/lib/Dom/addEventlistener';
176176
```
177177

@@ -181,7 +181,7 @@ import addEventlistener from 'rc-util/lib/Dom/addEventlistener';
181181
182182
Check if DOM is available.
183183

184-
```jsx
184+
```jsx|pure
185185
import canUseDom from 'rc-util/lib/Dom/canUseDom';
186186
```
187187

@@ -193,7 +193,7 @@ A collection of functions to operate DOM nodes' class name.
193193
- `addClass(node: HTMLElement, className: string): void`
194194
- `removeClass(node: HTMLElement, className: string): void`
195195

196-
```jsx
196+
```jsx|pure
197197
import cssClass from 'rc-util/lib/Dom/class;
198198
```
199199

@@ -203,7 +203,7 @@ import cssClass from 'rc-util/lib/Dom/class;
203203
204204
Check if node is equal to root or in the subtree of root.
205205

206-
```jsx
206+
```jsx|pure
207207
import contains from 'rc-util/lib/Dom/contains';
208208
```
209209

@@ -220,7 +220,7 @@ A collection of functions to get or set css styles.
220220
- `getScroll(): { scrollLeft: number, scrollTop: number }`
221221
- `getOffset(node: HTMLElement): { left: number, top: number }`
222222

223-
```jsx
223+
```jsx|pure
224224
import css from 'rc-util/lib/Dom/css';
225225
```
226226

@@ -234,7 +234,7 @@ A collection of functions to operate focus status of DOM node.
234234
- `getFocusNodeList(node: HTMLElement): HTMLElement[]` get a list of focusable nodes from the subtree of node.
235235
- `limitTabRange(node: HTMLElement, e: Event): void`
236236

237-
```jsx
237+
```jsx|pure
238238
import focus from 'rc-util/lib/Dom/focus';
239239
```
240240

@@ -244,7 +244,7 @@ import focus from 'rc-util/lib/Dom/focus';
244244
245245
A flag to tell whether current environment supports `animationend` or `transitionend`.
246246

247-
```jsx
247+
```jsx|pure
248248
import support from 'rc-util/lib/Dom/support';
249249
```
250250

@@ -254,7 +254,7 @@ import support from 'rc-util/lib/Dom/support';
254254
255255
Enum of KeyCode, please check the [definition](https://github.com/react-component/util/blob/master/src/KeyCode.ts) of it.
256256

257-
```jsx
257+
```jsx|pure
258258
import KeyCode from 'rc-util/lib/KeyCode';
259259
```
260260

docs/demo/dynaymicCSS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
## dynaymicCSS
2+
<code src="../examples/dynaymicCSS.tsx">

docs/demo/getScrollBarSize.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
## getScrollBarSize
2+
<code src="../examples/getScrollBarSize.tsx">

docs/demo/portal.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
## portal
2+
<code src="../examples/portal.tsx">

docs/demo/styleChecker.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
## styleChecker
2+
<code src="../examples/styleChecker.tsx">

examples/dynaymicCSS.tsx renamed to docs/examples/dynaymicCSS.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
2-
import { updateCSS, removeCSS } from '../src/Dom/dynamicCSS';
3-
import type { Prepend } from '../src/Dom/dynamicCSS';
2+
import { updateCSS, removeCSS } from '../../src/Dom/dynamicCSS';
3+
import type { Prepend } from '../../src/Dom/dynamicCSS';
44

55
function injectStyle(id: number, prepend?: Prepend) {
66
const randomColor = Math.floor(Math.random() * 16777215).toString(16);

examples/getScrollBarSize.tsx renamed to docs/examples/getScrollBarSize.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import React from 'react';
44
import getScrollBarSize, {
55
getTargetScrollBarSize,
6-
} from '../src/getScrollBarSize';
6+
} from '../../src/getScrollBarSize';
77

88
export default () => {
99
const divRef = React.useRef<HTMLDivElement>();

examples/portal.tsx renamed to docs/examples/portal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import PortalWrapper from '../src/PortalWrapper';
2+
import PortalWrapper from '../../src/PortalWrapper';
33

44
export default () => {
55
const divRef = React.useRef();

examples/styleChecker.tsx renamed to docs/examples/styleChecker.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import { isStyleSupport } from '../src/Dom/styleChecker';
2+
import { isStyleSupport } from '../../src/Dom/styleChecker';
33

44
export default () => {
55
const supportFlex = isStyleSupport('flex');

now.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@
77
"use": "@now/static-build",
88
"config": { "distDir": ".doc" }
99
}
10-
]
10+
],
11+
"routes": [{ "src": "/(.*)", "dest": "/dist/$1" }]
1112
}

package.json

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,33 @@
66
"react",
77
"util"
88
],
9-
"files": [
10-
"lib",
11-
"es"
12-
],
139
"homepage": "http://github.com/react-component/util",
10+
"bugs": {
11+
"url": "http://github.com/react-component/util/issues"
12+
},
1413
"repository": {
1514
"type": "git",
1615
"url": "git@github.com:react-component/util.git"
1716
},
18-
"bugs": {
19-
"url": "http://github.com/react-component/util/issues"
20-
},
2117
"license": "MIT",
18+
"files": [
19+
"lib",
20+
"es"
21+
],
2222
"scripts": {
23-
"start": "cross-env NODE_ENV=development father doc dev --storybook",
24-
"lint": "eslint src/ --ext .tsx,.ts & eslint tests/ --ext .js",
2523
"compile": "father build",
26-
"prepublishOnly": "npm run compile && np --yolo --no-publish",
27-
"test": "father test",
2824
"coverage": "father test --coverage && cat ./coverage/lcov.info | coveralls",
29-
"now-build": "father doc build --storybook"
25+
"docs:build": "npm run compile && dumi build",
26+
"lint": "eslint src/ --ext .tsx,.ts & eslint tests/ --ext .js",
27+
"now-build": "npm run docs:build",
28+
"prepublishOnly": "npm run compile && np --yolo --no-publish",
29+
"start": "npm run compile && dumi dev",
30+
"test": "father test"
31+
},
32+
"dependencies": {
33+
"@babel/runtime": "^7.18.3",
34+
"react-is": "^16.12.0",
35+
"shallowequal": "^1.1.0"
3036
},
3137
"devDependencies": {
3238
"@testing-library/jest-dom": "^5.16.4",
@@ -41,18 +47,15 @@
4147
"coveralls": "^3.1.0",
4248
"create-react-class": "^15.6.3",
4349
"cross-env": "^7.0.2",
50+
"dumi": "^1.1.4",
4451
"eslint": "^6.6.0",
4552
"father": "^2.29.9",
53+
"glob": "^7.1.6",
4654
"np": "^6.2.3",
4755
"react": "^18.0.0",
4856
"react-dom": "^18.0.0",
4957
"typescript": "^4.1.3"
5058
},
51-
"dependencies": {
52-
"@babel/runtime": "^7.18.3",
53-
"react-is": "^16.12.0",
54-
"shallowequal": "^1.1.0"
55-
},
5659
"peerDependencies": {
5760
"react": ">=16.9.0",
5861
"react-dom": ">=16.9.0"

0 commit comments

Comments
 (0)