Skip to content

Commit 4abce43

Browse files
authored
refactor: upgrade project (#294)
* feat: Upgrade build deps * chore: update * test: replace enzyme with testing * chore: remove script * style: format code use prettier * test: update case ref: testing-library/react-testing-library#269 (comment) * style: update README.md * chore: update docs * chore: rname * style: foramt
1 parent fc32392 commit 4abce43

24 files changed

+333
-342
lines changed

.dumirc.ts

+17
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+
import path from 'path';
4+
5+
export default defineConfig({
6+
alias: {
7+
'rc-collapse$': path.resolve('src'),
8+
'rc-collapse/es': path.resolve('src'),
9+
},
10+
favicons: ['https://avatars0.githubusercontent.com/u/9441414?s=200&v=4'],
11+
themeConfig: {
12+
name: 'Collapse',
13+
logo: 'https://avatars0.githubusercontent.com/u/9441414?s=200&v=4',
14+
},
15+
outputPath: '.doc',
16+
exportStatic: {},
17+
});

.fatherrc.js

-9
This file was deleted.

.fatherrc.ts

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { defineConfig } from 'father';
2+
3+
export default defineConfig({
4+
plugins: ['@rc-component/father-plugin'],
5+
});

.gitignore

+4-4
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ package-lock.json
3131
.storybook
3232
.doc
3333

34-
# umi
35-
.umi
36-
.umi-production
37-
.umi-test
34+
# dumi
35+
.dumi/tmp
36+
.dumi/tmp-production
37+
.dumi/tmp-test
3838
.env.local

HISTORY.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# History
2-
----
2+
3+
---
34

45
## 2.0.0 `2020-05-08`
56

README.md

+26-40
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
# rc-collapse
2-
---
32

43
rc-collapse ui component for react
54

6-
[![NPM version][npm-image]][npm-url]
7-
[![build status][github-actions-image]][github-actions-url]
8-
[![Test coverage][codecov-image]][codecov-url]
9-
[![npm download][download-image]][download-url]
5+
[![NPM version][npm-image]][npm-url] [![build status][github-actions-image]][github-actions-url] [![Test coverage][codecov-image]][codecov-url] [![npm download][download-image]][download-url]
106

117
[npm-image]: http://img.shields.io/npm/v/rc-collapse.svg?style=flat-square
128
[npm-url]: http://npmjs.org/package/rc-collapse
@@ -17,23 +13,9 @@ rc-collapse ui component for react
1713
[download-image]: https://img.shields.io/npm/dm/rc-collapse.svg?style=flat-square
1814
[download-url]: https://npmjs.org/package/rc-collapse
1915

20-
## Development
21-
22-
```
23-
npm install
24-
npm start
25-
```
26-
27-
## Example
16+
## Live Demo
2817

29-
http://localhost:8000/examples/
30-
31-
online example: http://react-component.github.io/collapse/
32-
33-
34-
## Features
35-
36-
* support ie8,ie8+,chrome,firefox,safari
18+
http://react-component.github.io/collapse/
3719

3820
## Install
3921

@@ -48,20 +30,24 @@ var React = require('react');
4830
var ReactDOM = require('react-dom');
4931
require('rc-collapse/assets/index.css');
5032

51-
var collapse = (
33+
var App = (
5234
<Collapse accordion={true}>
53-
<Panel header="hello" headerClass="my-header-class">this is panel content</Panel>
35+
<Panel header="hello" headerClass="my-header-class">
36+
this is panel content
37+
</Panel>
5438
<Panel header="title2">this is panel content2 or other</Panel>
5539
</Collapse>
5640
);
57-
ReactDOM.render(collapse, container);
41+
ReactDOM.render(App, container);
5842
```
5943

60-
## API
44+
## Features
45+
46+
- support ie8,ie8+,chrome,firefox,safari
6147

62-
### Collapse
48+
## API
6349

64-
#### props:
50+
### Collapse props
6551

6652
<table class="table table-bordered table-striped">
6753
<thead>
@@ -124,15 +110,11 @@ ReactDOM.render(collapse, container);
124110
</tbody>
125111
</table>
126112

127-
If `accordion` is null or false, every panel can open. Opening another panel will not close any of the other panels.
128-
`activeKey` should be an string, if passing an array (the first item in the array will be used).
129-
130-
If `accordion` is true, only one panel can be open. Opening another panel will cause the previously opened panel to close.
131-
`activeKey` should be an string, if passing an array (the first item in the array will be used).
113+
If `accordion` is null or false, every panel can open. Opening another panel will not close any of the other panels. `activeKey` should be an string, if passing an array (the first item in the array will be used).
132114

133-
### Collapse.Panel
115+
If `accordion` is true, only one panel can be open. Opening another panel will cause the previously opened panel to close. `activeKey` should be an string, if passing an array (the first item in the array will be used).
134116

135-
#### props
117+
### Collapse.Panel props
136118

137119
<table class="table table-bordered table-striped">
138120
<thead>
@@ -207,20 +189,24 @@ If `accordion` is true, only one panel can be open. Opening another panel will
207189

208190
If `key` is not provided, the panel's index will be used instead.
209191

210-
## Test Case
192+
## Development
211193

194+
```bash
195+
npm install
196+
npm start
212197
```
198+
199+
## Test Case
200+
201+
```bash
213202
npm test
214-
npm run chrome-test
215203
```
216204

217205
## Coverage
218206

207+
```bash
208+
npm test -- --coverage
219209
```
220-
npm run coverage
221-
```
222-
223-
open coverage/ dir
224210

225211
## License
226212

docs/demo/custom-icon.md

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,8 @@
1-
## custom-icon
2-
<code src="../examples/custom-icon.tsx">
1+
---
2+
title: custom-icon
3+
nav:
4+
title: Demo
5+
path: /demo
6+
---
7+
8+
<code src="../examples/custom-icon.tsx"></code>

docs/demo/fragment.md

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,8 @@
1-
## fragment
2-
<code src="../examples/fragment.tsx">
1+
---
2+
title: fragment
3+
nav:
4+
title: Demo
5+
path: /demo
6+
---
7+
8+
<code src="../examples/fragment.tsx"></code>

docs/demo/simple.md

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,8 @@
1-
## simple
2-
<code src="../examples/simple.tsx">
1+
---
2+
title: simple
3+
nav:
4+
title: Demo
5+
path: /demo
6+
---
7+
8+
<code src="../examples/simple.tsx"></code>

docs/examples/_util/motionUtil.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { CSSMotionProps, MotionEventHandler, MotionEndEventHandler } from 'rc-motion';
1+
import type { CSSMotionProps, MotionEventHandler, MotionEndEventHandler } from 'rc-motion';
22

33
const getCollapsedHeight: MotionEventHandler = () => ({ height: 0, opacity: 0 });
44
const getRealHeight: MotionEventHandler = (node) => ({ height: node.scrollHeight, opacity: 1 });

docs/examples/custom-icon.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as React from 'react';
2-
import Collapse, { Panel } from '../../src';
2+
import Collapse, { Panel } from 'rc-collapse';
33
import motion from './_util/motionUtil';
44
import '../../assets/index.less';
55

docs/examples/fragment.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as React from 'react';
22
import { Fragment } from 'react';
3+
import Collapse, { Panel } from 'rc-collapse';
34
import '../../assets/index.less';
4-
import Collapse, { Panel } from '../../src';
55

66
const Test = () => (
77
<Collapse>

docs/examples/simple.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as React from 'react';
2-
import Collapse, { Panel } from '../../src';
2+
import Collapse, { Panel } from 'rc-collapse';
33
import motion from './_util/motionUtil';
44
import '../../assets/index.less';
55

docs/index.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
hero:
3+
title: rc-collapse
4+
description: rc-collapse ui component for react
5+
---
6+
7+
<embed src="../README.md"></embed>

jest.config.js

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
setupFilesAfterEnv: ['<rootDir>/tests/setupAfterEnv.ts'],
3+
};

package.json

+23-27
Original file line numberDiff line numberDiff line change
@@ -11,62 +11,58 @@
1111
"accordion"
1212
],
1313
"homepage": "http://github.com/react-component/collapse",
14+
"bugs": {
15+
"url": "http://github.com/react-component/collapse/issues"
16+
},
1417
"repository": {
1518
"type": "git",
1619
"url": "[email protected]:react-component/collapse.git"
1720
},
18-
"bugs": {
19-
"url": "http://github.com/react-component/collapse/issues"
20-
},
2121
"license": "MIT",
22+
"main": "./lib/index",
23+
"module": "./es/index",
2224
"files": [
2325
"lib",
2426
"es",
2527
"assets/*.css"
2628
],
27-
"main": "./lib/index",
28-
"module": "./es/index",
2929
"scripts": {
30-
"start": "dumi dev",
3130
"build": "dumi build",
3231
"compile": "father build && lessc assets/index.less assets/index.css",
33-
"gh-pages": "npm run build && father doc deploy",
34-
"prepublishOnly": "npm run compile && np --yolo --no-publish",
35-
"postpublish": "npm run gh-pages",
32+
"coverage": "father test --coverage",
3633
"lint": "eslint src/ --ext .ts,.tsx,.jsx,.js,.md",
34+
"prepublishOnly": "npm run compile && np --yolo --no-publish",
3735
"prettier": "prettier --write \"**/*.{ts,tsx,js,jsx,json,md}\"",
38-
"test": "father test",
39-
"coverage": "father test --coverage"
36+
"start": "dumi dev",
37+
"test": "rc-test"
38+
},
39+
"dependencies": {
40+
"@babel/runtime": "^7.10.1",
41+
"classnames": "2.x",
42+
"rc-motion": "^2.3.4",
43+
"rc-util": "^5.27.0"
4044
},
4145
"devDependencies": {
46+
"@rc-component/father-plugin": "^1.0.1",
47+
"@testing-library/jest-dom": "^5.16.5",
48+
"@testing-library/react": "^13.4.0",
4249
"@types/classnames": "^2.2.9",
43-
"@types/enzyme": "^3.10.6",
4450
"@types/jest": "^26.0.0",
4551
"@types/react": "^18.0.0",
4652
"@types/react-dom": "^18.0.0",
4753
"@umijs/fabric": "^2.0.0",
48-
"cross-env": "^7.0.0",
49-
"dumi": "^1.1.4",
50-
"enzyme": "^3.1.1",
51-
"enzyme-adapter-react-16": "^1.0.1",
52-
"enzyme-to-json": "^3.1.2",
54+
"dumi": "^2.1.1",
5355
"eslint": "^7.11.0",
54-
"father": "^2.22.0",
55-
"glob": "^7.1.6",
56+
"father": "^4.1.3",
5657
"jest": "^29.1.2",
5758
"less": "^3.12.2",
5859
"np": "^6.0.0",
5960
"prettier": "^2.1.2",
60-
"react": "^16.9.0",
61-
"react-dom": "^16.9.0",
61+
"rc-test": "^7.0.14",
62+
"react": "^18.2.0",
63+
"react-dom": "^18.2.0",
6264
"typescript": "^4.0.2"
6365
},
64-
"dependencies": {
65-
"@babel/runtime": "^7.10.1",
66-
"classnames": "2.x",
67-
"rc-motion": "^2.3.4",
68-
"rc-util": "^5.27.0"
69-
},
7066
"peerDependencies": {
7167
"react": ">=16.9.0",
7268
"react-dom": ">=16.9.0"

src/Collapse.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable react/prop-types */
21
import classNames from 'classnames';
32
import toArray from 'rc-util/lib/Children/toArray';
43
import * as React from 'react';

src/Panel.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable react/prop-types */
21
import classNames from 'classnames';
32
import CSSMotion from 'rc-motion';
43
import * as React from 'react';

src/PanelContent.tsx

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
/* eslint-disable no-underscore-dangle */
2-
/* eslint-disable react/prop-types */
31
import * as React from 'react';
42
import classnames from 'classnames';
5-
import { CollapsePanelProps } from './interface';
3+
import type { CollapsePanelProps } from './interface';
64

75
const PanelContent = React.forwardRef<
86
HTMLDivElement,
File renamed without changes.

0 commit comments

Comments
 (0)