Skip to content

Commit 2dc872b

Browse files
orzyyyyzombieJ
authored andcommitted
refactor: with hooks (#195)
* chore: init with your father * refactor: with tsx * test: update cases * chore: update demo * chore: remove useless deps * chore: remove useless deps * chore: remove forcePopupAlign, use ResizeObserver in rc-trigger * chore: fix type definition * fix: lint & type definition * ci: update * perf: wrapper with forwardRef for access of ref * test: update cases * chore: upgrade rc-trigger to 4.0.0-alpha.5
1 parent f6f5266 commit 2dc872b

23 files changed

+493
-433
lines changed

.eslintrc.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
const base = require('@umijs/fabric/dist/eslint');
2+
3+
module.exports = {
4+
...base,
5+
rules: {
6+
...base.rules,
7+
'no-template-curly-in-string': 0,
8+
'prefer-promise-reject-errors': 0,
9+
'react/no-array-index-key': 0,
10+
'react/sort-comp': 0,
11+
'@typescript-eslint/no-explicit-any': 0,
12+
'jsx-a11y/label-has-associated-control': 0,
13+
'jsx-a11y/label-has-for': 0,
14+
},
15+
};

.fatherrc.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export default {
2+
cjs: 'babel',
3+
esm: { type: 'babel', importLibToEs: true },
4+
preCommit: {
5+
eslint: true,
6+
prettier: true,
7+
},
8+
};

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
.storybook
12
*.iml
23
*.log
34
*.log.*

.travis.yml

Lines changed: 6 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,17 @@
11
language: node_js
22

3-
sudo: false
4-
5-
notifications:
6-
email:
7-
8-
9-
103
node_js:
11-
- 6
4+
- 10
125

13-
before_install:
14-
- |
15-
if ! git diff --name-only $TRAVIS_COMMIT_RANGE | grep -qvE '(\.md$)|(^(docs|examples))/'
16-
then
17-
echo "Only docs were updated, stopping build process."
18-
exit
19-
fi
20-
npm install [email protected] -g
21-
phantomjs --version
226
script:
23-
- |
7+
- |
248
if [ "$TEST_TYPE" = test ]; then
25-
npm test
9+
npm run coverage && \
10+
bash <(curl -s https://codecov.io/bash)
2611
else
2712
npm run $TEST_TYPE
2813
fi
2914
env:
3015
matrix:
31-
- TEST_TYPE=lint
32-
- TEST_TYPE=test
33-
- TEST_TYPE=coverage
34-
35-
36-
matrix:
37-
allow_failures:
38-
- env: "TEST_TYPE=saucelabs"
16+
- TEST_TYPE=lint
17+
- TEST_TYPE=test

examples/arrowContent.html

Whitespace-only changes.

examples/arrowContent.js

Lines changed: 41 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import React from 'react';
2-
import ReactDOM from 'react-dom';
3-
import Tooltip from 'rc-tooltip';
4-
import 'rc-tooltip/assets/bootstrap_white.less';
2+
import Tooltip from '../src';
3+
import '../assets/bootstrap_white.less';
54

65
const text = <span>Tooltip Text</span>;
76
const styles = {
@@ -18,67 +17,82 @@ const rowStyle = {
1817
display: 'table-row',
1918
};
2019

21-
2220
const Test = () => (
23-
<div style={{ display: 'table' }}>
21+
<div style={{ display: 'table', padding: 120 }}>
2422
<div style={rowStyle}>
2523
<Tooltip
2624
placement="left"
2725
overlay={text}
2826
arrowContent={<div className="rc-tooltip-arrow-inner"></div>}
2927
>
30-
<a href="#" style={styles}>Left</a>
28+
<a href="#" style={styles}>
29+
Left
30+
</a>
3131
</Tooltip>
3232
<Tooltip
3333
placement="top"
3434
overlay={text}
3535
arrowContent={<div className="rc-tooltip-arrow-inner"></div>}
3636
>
37-
<a href="#" style={styles}>Top</a>
37+
<a href="#" style={styles}>
38+
Top
39+
</a>
3840
</Tooltip>
3941
<Tooltip
4042
placement="bottom"
4143
overlay={text}
4244
arrowContent={<div className="rc-tooltip-arrow-inner"></div>}
4345
>
44-
<a href="#" style={styles}>Bottom</a>
46+
<a href="#" style={styles}>
47+
Bottom
48+
</a>
4549
</Tooltip>
4650
<Tooltip
4751
placement="right"
4852
overlay={text}
4953
arrowContent={<div className="rc-tooltip-arrow-inner"></div>}
5054
>
51-
<a href="#" style={styles}>Right</a>
55+
<a href="#" style={styles}>
56+
Right
57+
</a>
5258
</Tooltip>
53-
</ div>
59+
</div>
5460
<div style={rowStyle}>
5561
<Tooltip
5662
placement="leftTop"
5763
overlay={text}
5864
arrowContent={<div className="rc-tooltip-arrow-inner"></div>}
5965
>
60-
<a href="#" style={styles}>Left Top</a>
66+
<a href="#" style={styles}>
67+
Left Top
68+
</a>
6169
</Tooltip>
6270
<Tooltip
6371
placement="leftBottom"
6472
overlay={text}
6573
arrowContent={<div className="rc-tooltip-arrow-inner"></div>}
6674
>
67-
<a href="#" style={styles}>Left Bottom</a>
75+
<a href="#" style={styles}>
76+
Left Bottom
77+
</a>
6878
</Tooltip>
6979
<Tooltip
7080
placement="rightTop"
7181
overlay={text}
7282
arrowContent={<div className="rc-tooltip-arrow-inner"></div>}
7383
>
74-
<a href="#" style={styles}>Right Top</a>
84+
<a href="#" style={styles}>
85+
Right Top
86+
</a>
7587
</Tooltip>
7688
<Tooltip
7789
placement="rightBottom"
7890
overlay={text}
7991
arrowContent={<div className="rc-tooltip-arrow-inner"></div>}
8092
>
81-
<a href="#" style={styles}>Right Bottom</a>
93+
<a href="#" style={styles}>
94+
Right Bottom
95+
</a>
8296
</Tooltip>
8397
</div>
8498
<div style={rowStyle}>
@@ -87,31 +101,39 @@ const Test = () => (
87101
overlay={text}
88102
arrowContent={<div className="rc-tooltip-arrow-inner"></div>}
89103
>
90-
<a href="#" style={styles}>Top Left</a>
104+
<a href="#" style={styles}>
105+
Top Left
106+
</a>
91107
</Tooltip>
92108
<Tooltip
93109
placement="topRight"
94110
overlay={text}
95111
arrowContent={<div className="rc-tooltip-arrow-inner"></div>}
96112
>
97-
<a href="#" style={styles}>Top Right</a>
113+
<a href="#" style={styles}>
114+
Top Right
115+
</a>
98116
</Tooltip>
99117
<Tooltip
100118
placement="bottomLeft"
101119
overlay={text}
102120
arrowContent={<div className="rc-tooltip-arrow-inner"></div>}
103121
>
104-
<a href="#" style={styles}>Bottom Left</a>
122+
<a href="#" style={styles}>
123+
Bottom Left
124+
</a>
105125
</Tooltip>
106126
<Tooltip
107127
placement="bottomRight"
108128
overlay={text}
109129
arrowContent={<div className="rc-tooltip-arrow-inner"></div>}
110130
>
111-
<a href="#" style={styles}>Bottom Right</a>
131+
<a href="#" style={styles}>
132+
Bottom Right
133+
</a>
112134
</Tooltip>
113135
</div>
114136
</div>
115137
);
116138

117-
ReactDOM.render(<Test />, document.getElementById('__react-content'));
139+
export default Test;

examples/formError.html

Whitespace-only changes.

examples/formError.js

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,25 @@
11
import React, { Component } from 'react';
2-
import ReactDOM from 'react-dom';
3-
import Tooltip from 'rc-tooltip';
2+
import Tooltip from '../src';
43

5-
import 'rc-tooltip/assets/bootstrap.less';
4+
import '../assets/bootstrap.less';
65

76
class Test extends Component {
87
state = {
98
visible: false,
109
};
10+
1111
handleDestroy = () => {
1212
this.setState({
1313
destroy: true,
1414
});
15-
}
16-
handleChange = (e) => {
15+
};
16+
17+
handleChange = e => {
1718
this.setState({
1819
visible: !e.target.value,
1920
});
20-
}
21+
};
22+
2123
render() {
2224
if (this.state.destroy) {
2325
return null;
@@ -32,13 +34,15 @@ class Test extends Component {
3234
overlayStyle={{ zIndex: 1000 }}
3335
overlay={<span>required!</span>}
3436
>
35-
<input onChange={this.handleChange}/>
37+
<input onChange={this.handleChange} />
3638
</Tooltip>
3739
</div>
38-
<button onClick={this.handleDestroy}>destroy</button>
40+
<button type="button" onClick={this.handleDestroy}>
41+
destroy
42+
</button>
3943
</div>
4044
);
4145
}
4246
}
4347

44-
ReactDOM.render(<Test />, document.getElementById('__react-content'));
48+
export default Test;

examples/onVisibleChange.html

Whitespace-only changes.

examples/onVisibleChange.js

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import React, { Component } from 'react';
2-
import ReactDOM from 'react-dom';
3-
import Tooltip from 'rc-tooltip';
4-
import 'rc-tooltip/assets/bootstrap.less';
2+
import Tooltip from '../src';
3+
import '../assets/bootstrap.less';
54

65
function preventDefault(e) {
76
e.preventDefault();
@@ -11,35 +10,44 @@ class Test extends Component {
1110
state = {
1211
visible: false,
1312
};
14-
onVisibleChange = (visible) => {
13+
14+
onVisibleChange = visible => {
1515
this.setState({
1616
visible,
1717
});
18-
}
18+
};
19+
1920
onDestroy = () => {
2021
this.setState({
2122
destroy: true,
2223
});
23-
}
24+
};
25+
2426
render() {
2527
if (this.state.destroy) {
2628
return null;
2729
}
28-
return (<div>
29-
<div style={{ marginTop: 300, marginLeft: 100, marginBottom: 100 }}>
30-
<Tooltip
31-
visible={this.state.visible}
32-
animation="zoom"
33-
onVisibleChange={this.onVisibleChange}
34-
trigger="click"
35-
overlay={<span>I am a tooltip</span>}
36-
>
37-
<a href="#" onClick={preventDefault}>trigger</a>
38-
</Tooltip>
30+
return (
31+
<div>
32+
<div style={{ marginTop: 300, marginLeft: 100, marginBottom: 100 }}>
33+
<Tooltip
34+
visible={this.state.visible}
35+
animation="zoom"
36+
onVisibleChange={this.onVisibleChange}
37+
trigger="click"
38+
overlay={<span>I am a tooltip</span>}
39+
>
40+
<a href="#" onClick={preventDefault}>
41+
trigger
42+
</a>
43+
</Tooltip>
44+
</div>
45+
<button type="button" onClick={this.onDestroy}>
46+
destroy
47+
</button>
3948
</div>
40-
<button onClick={this.onDestroy}>destroy</button>
41-
</div>);
49+
);
4250
}
4351
}
4452

45-
ReactDOM.render(<Test />, document.getElementById('__react-content'));
53+
export default Test;

0 commit comments

Comments
 (0)