Skip to content

Commit 27544c0

Browse files
committed
refactor: use ts
1 parent 7ffa2b9 commit 27544c0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+458
-1419
lines changed

.babelrc

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

.gitignore

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,18 @@ bower_components
33
coverage
44
npm-debug.log
55
yarn.lock
6-
Gemfile.lock
7-
yarn-error.log
86
package-lock.json
97
.DS_Store
10-
11-
# editor
128
.idea
9+
10+
11+
# vscode
1312
.vscode
1413
.history
14+
15+
# python cache
16+
__pycache__
17+
dist
18+
dist-ssr
19+
*.local
20+
.vite

.npmignore

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,27 @@
11
.idea
22
.DS_Store
3-
.prettierrc
4-
.babelrc
5-
.editorconfig
6-
Gemfile
7-
postcss.config.js
8-
Rakefile
93
**/npm-debug.log
104
**/node_modules
11-
12-
bin
5+
test
6+
__tests__
137
src
14-
docs
158
build
16-
docs
9+
gulpfile.js
10+
rollup.config.js
11+
1712
public
18-
tests
19-
postcss.config.js
20-
webpack.config.babel.js
21-
example
22-
examples
13+
.editorconfig
14+
.prettierrc
15+
.prettierignore
2316

2417
# vscode
25-
jsconfig.json
18+
.vscode
2619
.history
20+
.github
21+
api
22+
docs
2723

28-
# tests
29-
test
30-
__test__
31-
__tests__
3224
jest.config.js
33-
jest.setup.js
34-
3525
.release-it.json
26+
tsconfig.json
27+
vite.config.ts

.npmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
sass_binary_site=https://npm.taobao.org/mirrors/node-sass/
1+
registry=https://registry.npm.taobao.org
22
package-lock=false

.prettierrc

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,16 @@
11
{
22
"trailingComma": "none",
33
"arrowParens": "always",
4-
"printWidth": 80,
4+
"printWidth": 100,
55
"bracketSpacing": true,
66
"jsxBracketSameLine": true,
77
"tabWidth": 2,
8-
"semi": true,
98
"quoteProps": "consistent",
9+
"semi": true,
1010
"singleQuote": true,
1111
"overrides": [
1212
{
13-
"files": [
14-
"*.json",
15-
".eslintrc",
16-
".tslintrc",
17-
".prettierrc",
18-
".tern-project"
19-
],
13+
"files": ["*.json", ".eslintrc", ".tslintrc", ".prettierrc", ".tern-project"],
2014
"options": {
2115
"parser": "json",
2216
"tabWidth": 2
@@ -34,6 +28,14 @@
3428
"options": {
3529
"parser": "typescript"
3630
}
31+
},
32+
{
33+
"files": "*.md",
34+
"options": {
35+
"trailingComma": "none",
36+
"tabWidth": 2,
37+
"parser": "json"
38+
}
3739
}
3840
]
3941
}

.release-it.json

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
{
2+
"git": {
3+
"requireCleanWorkingDir": false
4+
},
25
"hooks": {
36
"after:init": [
4-
"t2k"
7+
"t2k",
8+
"npm run docs"
59
],
610
"after:bump": [
7-
"npm run docs",
811
"npm run build"
912
]
1013
},
1114
"github": {
12-
"release": true
15+
"release": true,
16+
"proxy": "http://127.0.0.1:9090"
1317
}
14-
}
18+
}

README.md

Lines changed: 11 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,6 @@
1111
npm install -S @jswork/react-modal-manager
1212
```
1313

14-
## properties
15-
| Name | Type | Required | Default | Description |
16-
| --------- | ------ | -------- | ------- | ------------------------------------------------------ |
17-
| className | string | false | - | The extended className for component. |
18-
| context | func | false | - | The model required context pattern. |
19-
| name | string | false | - | The only shared model name. |
20-
| inject | func | false | noop | Callback when you want to inject to some other object. |
21-
| ready | bool | false | true | If your app has ready. |
22-
23-
2414
## usage
2515
1. import css
2616
```scss
@@ -34,108 +24,28 @@ npm install -S @jswork/react-modal-manager
3424
```
3525
2. import js
3626
```js
37-
import NxOfflineSw from '@jswork/next-offline-sw';
38-
import ReactGithubCorner from '@jswork/react-github-corner';
39-
import ReactSwUpdateTips from '@jswork/react-sw-update-tips';
4027
import React from 'react';
41-
import ReactDOM from 'react-dom';
42-
import ReactModalManager, { modal } from '@jswork/react-modal-manager';
43-
import './assets/style.scss';
44-
45-
const code = `
46-
/* ---- Run in console ---- */
47-
48-
// show modal1
49-
store.present('modal1');
28+
import ReactModalManager from '@jswork/react-modal-manager';
29+
import styled from 'styled-components';
5030

51-
// show modal1 with data
52-
store.present('modal1',{ key:"1", key2: "2" });
53-
54-
// hide modal1
55-
store.present('modal1');
31+
const Container = styled.div`
32+
width: 80%;
33+
margin: 30px auto 0;
5634
`;
5735

58-
const Button = modal((props) => {
36+
export default (props: any) => {
5937
return (
60-
<React.Fragment>
61-
<button
62-
className="button"
63-
onClick={() => {
64-
props.$modal.present('modal1');
65-
}}>
66-
Open modal
67-
</button>
68-
69-
<button
70-
className="button"
71-
onClick={() => {
72-
props.$modal.present('modal2');
73-
}}>
74-
Open Modal2
75-
</button>
76-
77-
<button
78-
className="button"
79-
onClick={() => {
80-
props.$modal.present('dir1/dir2/dir3/modal');
81-
}}>
82-
Model in deep path
83-
</button>
84-
</React.Fragment>
38+
<Container>
39+
<ReactModalManager />
40+
</Container>
8541
);
86-
});
87-
88-
class App extends React.Component {
89-
state = { hasUpdate: false, items: ['value1', 'value2', 'value3', 'value4'] };
90-
91-
componentDidMount() {
92-
NxOfflineSw.install({
93-
onUpdateReady: () => {
94-
this.setState({ hasUpdate: true });
95-
}
96-
});
97-
}
98-
99-
render() {
100-
const ctx = require.context('./modals/', true, /\.js$/);
101-
return (
102-
<div className="app-container bg-gray-100">
103-
<ReactModalManager
104-
context={ctx}
105-
inject={(e) => {
106-
window.store = e;
107-
}}>
108-
<h2 style={{ marginBottom: 20 }}>My Modals App</h2>
109-
<center className="mb-4">
110-
<img src="https://himg.bdimg.com/sys/portrait/item/be10475f686d6c73db00.jpg" />
111-
</center>
112-
<Button />
113-
</ReactModalManager>
114-
115-
<pre>
116-
<code className="w-full p-2">{code}</code>
117-
</pre>
118-
119-
<ReactSwUpdateTips value={this.state.hasUpdate} />
120-
<ReactGithubCorner value="https://github.com/afeiship/react-modal-manager" />
121-
</div>
122-
);
123-
}
124-
}
125-
126-
ReactDOM.render(<App />, document.getElementById('app'));
42+
};
12743

12844
```
12945

130-
## todos
131-
- [ ]`dismiss` 的时候,会有带一些data出去的需求
132-
- [ ] 在与其它的 `@observe`r 组合的时候,会出现无法触发的情况
133-
- [ ]`present/dismiss` 的时候,配合一下全局事件,这样就可以完美处理 `data` 里带 `callback` 的需求了
134-
135-
## documentation
46+
## preview
13647
- https://afeiship.github.io/react-modal-manager/
13748

138-
13949
## license
14050
Code released under [the MIT license](https://github.com/afeiship/react-modal-manager/blob/master/LICENSE.txt).
14151

__tests__/index.spec.js

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

__tests__/index.spec.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import * as React from 'react';
2+
import { render } from '@testing-library/react';
3+
import ReactModalManager from '../src/main';
4+
5+
describe('01/basic props', () => {
6+
test('<BoilerplateReactTsComponent /> set content to body should be worked', () => {
7+
render(<ReactModalManager />);
8+
console.log(document.body.innerHTML);
9+
expect(document.body.innerHTML.includes('Enjoy coding')).toBeTruthy();
10+
});
11+
});

bin/docs.rb

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

build/TEMPLATE.md

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@
1111
npm install -S @jswork/react-modal-manager
1212
```
1313

14-
## properties
15-
__GENERATE_DOCS__
16-
1714
## usage
1815
1. import css
1916
```scss
@@ -30,15 +27,9 @@ __GENERATE_DOCS__
3027
__GENERATE_DAPP__
3128
```
3229

33-
## todos
34-
- [ ] 在 `dismiss` 的时候,会有带一些data出去的需求
35-
- [ ] 在与其它的 `@observe`r 组合的时候,会出现无法触发的情况
36-
- [ ] 在 `present/dismiss` 的时候,配合一下全局事件,这样就可以完美处理 `data` 里带 `callback` 的需求了
37-
38-
## documentation
30+
## preview
3931
- https://afeiship.github.io/react-modal-manager/
4032

41-
4233
## license
4334
Code released under [the MIT license](https://github.com/afeiship/react-modal-manager/blob/master/LICENSE.txt).
4435

0 commit comments

Comments
 (0)