Skip to content

Commit bb13d2c

Browse files
authored
chore: user dumi (#122)
* chore: user dumi * fix lint
1 parent a107a64 commit bb13d2c

21 files changed

+113
-20
lines changed

.gitignore

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,10 @@ lib/
77
~*
88
yarn.lock
99
package-lock.json
10-
!tests/__mocks__/rc-util/lib
10+
!tests/__mocks__/rc-util/lib
11+
12+
# umi
13+
.umi
14+
.umi-production
15+
.umi-test
16+
.env.local

.umirc.ts

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

README.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,7 @@
22

33
React Virtual List Component which worked with animation.
44

5-
[![NPM version][npm-image]][npm-url]
6-
[![build status][github-actions-image]][github-actions-url]
7-
[![Test coverage][coveralls-image]][coveralls-url]
8-
[![node version][node-image]][node-url]
9-
[![npm download][download-image]][download-url]
5+
[![NPM version][npm-image]][npm-url] [![dumi](https://img.shields.io/badge/docs%20by-dumi-blue?style=flat-square)](https://github.com/umijs/dumi) [![build status][github-actions-image]][github-actions-url] [![Test coverage][coveralls-image]][coveralls-url] [![node version][node-image]][node-url] [![npm download][download-image]][download-url]
106

117
[npm-image]: http://img.shields.io/npm/v/rc-virtual-list.svg?style=flat-square
128
[npm-url]: http://npmjs.org/package/rc-virtual-list

docs/demo/animate.md

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

docs/demo/basic.md

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

docs/demo/height.md

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

docs/demo/no-virtual.md

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

docs/demo/switch.md

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

docs/index.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
title: rc-virtual-list
3+
---
4+
5+
<embed src="../README.md"></embed>

now.json

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

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
"main": "./lib/index",
3030
"module": "./es/index",
3131
"scripts": {
32-
"start": "cross-env NODE_ENV=development father doc dev --storybook",
33-
"build": "father doc build --storybook",
32+
"start": "dumi dev",
33+
"build": "dumi build",
3434
"compile": "father build",
3535
"prepublishOnly": "npm run compile && np --no-cleanup --yolo --no-publish",
3636
"lint": "eslint src/ --ext .tsx,.ts",
@@ -49,11 +49,13 @@
4949
"@types/react-dom": "^16.8.4",
5050
"@types/warning": "^3.0.0",
5151
"cross-env": "^5.2.0",
52+
"dumi": "^1.1.12",
5253
"enzyme": "^3.1.0",
5354
"enzyme-adapter-react-16": "^1.0.2",
5455
"enzyme-to-json": "^3.1.4",
5556
"eslint": "^7.6.0",
5657
"father": "^2.29.10",
58+
"glob": "^7.1.6",
5759
"np": "^5.0.3",
5860
"rc-animate": "^2.9.1",
5961
"react": "^v16.9.0-alpha.0",

src/List.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { useRef, useState } from 'react';
33
import classNames from 'classnames';
44
import Filler from './Filler';
55
import ScrollBar from './ScrollBar';
6-
import { RenderFunc, SharedConfig, GetKey } from './interface';
6+
import type { RenderFunc, SharedConfig, GetKey } from './interface';
77
import useChildren from './hooks/useChildren';
88
import useHeights from './hooks/useHeights';
99
import useScrollTo from './hooks/useScrollTo';

src/hooks/useChildren.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as React from 'react';
2-
import { SharedConfig, RenderFunc } from '../interface';
2+
import type { SharedConfig, RenderFunc } from '../interface';
33
import { Item } from '../Item';
44

55
export default function useChildren<T>(

src/hooks/useDiffItem.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as React from 'react';
22
import { findListDiffIndex } from '../utils/algorithmUtil';
3-
import { GetKey } from '../interface';
3+
import type { GetKey } from '../interface';
44

55
export default function useDiffItem<T>(
66
data: T[],

src/hooks/useHeights.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
import * as React from 'react';
22
import { useRef } from 'react';
33
import findDOMNode from 'rc-util/lib/Dom/findDOMNode';
4-
import { GetKey } from '../interface';
4+
import type { GetKey } from '../interface';
55
import CacheMap from '../utils/CacheMap';
66

7-
type RefFunc = (instance: HTMLElement) => void;
8-
97
export default function useHeights<T>(
108
getKey: GetKey<T>,
119
onItemAdd?: (item: T) => void,

src/hooks/useScrollTo.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/* eslint-disable no-param-reassign */
22
import * as React from 'react';
33
import raf from 'rc-util/lib/raf';
4-
import { ScrollTo } from '../List';
5-
import { GetKey } from '../interface';
6-
import CacheMap from '../utils/CacheMap';
4+
import type { ScrollTo } from '../List';
5+
import type { GetKey } from '../interface';
6+
import type CacheMap from '../utils/CacheMap';
77

88
export default function useScrollTo<T>(
99
containerRef: React.RefObject<HTMLDivElement>,

src/mock.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import * as React from 'react';
2-
import { RawList, ListProps, ListRef } from './List';
2+
import type { ListProps, ListRef } from './List';
3+
import { RawList } from './List';
34

45
const List = React.forwardRef((props: ListProps<any>, ref: React.Ref<ListRef>) =>
56
RawList({ ...props, virtual: false }, ref),

src/utils/CacheMap.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from 'react';
1+
import type React from 'react';
22

33
// Firefox has low performance of map.
44
class CacheMap {

src/utils/algorithmUtil.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as React from 'react';
1+
import type * as React from 'react';
22
/**
33
* Get index with specific start index one by one. e.g.
44
* min: 3, max: 9, start: 6

tsconfig.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"compilerOptions": {
3+
"target": "esnext",
4+
"moduleResolution": "node",
5+
"baseUrl": "./",
6+
"jsx": "preserve",
7+
"declaration": true,
8+
"skipLibCheck": true,
9+
"esModuleInterop": true,
10+
"paths": {
11+
"@/*": ["src/*"],
12+
"@@/*": ["src/.umi/*"],
13+
"rc-virtual-list": ["src/index.ts"]
14+
}
15+
}
16+
}

update-demo.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
用于 dumi 改造使用,
3+
可用于将 examples 的文件批量修改为 demo 引入形式,
4+
其他项目根据具体情况使用。
5+
*/
6+
7+
const fs = require('fs');
8+
const glob = require('glob');
9+
10+
const paths = glob.sync('./examples/*.tsx');
11+
12+
paths.forEach(path => {
13+
const name = path.split('/').pop().split('.')[0];
14+
fs.writeFile(
15+
`./docs/demo/${name}.md`,
16+
`## ${name}
17+
18+
<code src="../../examples/${name}.tsx">
19+
`,
20+
'utf8',
21+
function(error) {
22+
if(error){
23+
console.log(error);
24+
return false;
25+
}
26+
console.log(`${name} 更新成功~`);
27+
}
28+
)
29+
});

0 commit comments

Comments
 (0)