Skip to content

Commit 6b77a40

Browse files
authored
Initial commit
0 parents  commit 6b77a40

32 files changed

Lines changed: 1121 additions & 0 deletions

.editorconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# top-most EditorConfig file
2+
root = true
3+
4+
# Unix-style newlines with a newline ending every file
5+
[*.{js,css}]
6+
end_of_line = lf
7+
insert_final_newline = true
8+
indent_style = space
9+
indent_size = 2

.eslintrc.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
const config = {
2+
extends: [require.resolve('@umijs/fabric/dist/eslint')],
3+
rules: {
4+
'react/no-did-update-set-state': 0,
5+
'react/no-find-dom-node': 0,
6+
'import/no-extraneous-dependencies': 0,
7+
'react/sort-comp': 0,
8+
},
9+
};
10+
11+
module.exports = config;

.fatherrc.js

Lines changed: 5 additions & 0 deletions
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+
});

.github/workflows/main.yml

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [master]
6+
pull_request:
7+
branches: [master]
8+
9+
jobs:
10+
setup:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: checkout
14+
uses: actions/checkout@master
15+
16+
- uses: actions/setup-node@v1
17+
with:
18+
node-version: '12'
19+
20+
- name: cache package-lock.json
21+
uses: actions/cache@v2
22+
with:
23+
path: package-temp-dir
24+
key: lock-${{ github.sha }}
25+
26+
- name: create package-lock.json
27+
run: npm i --package-lock-only
28+
29+
- name: hack for singe file
30+
run: |
31+
if [ ! -d "package-temp-dir" ]; then
32+
mkdir package-temp-dir
33+
fi
34+
cp package-lock.json package-temp-dir
35+
36+
- name: cache node_modules
37+
id: node_modules_cache_id
38+
uses: actions/cache@v2
39+
with:
40+
path: node_modules
41+
key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }}
42+
43+
- name: install
44+
if: steps.node_modules_cache_id.outputs.cache-hit != 'true'
45+
run: npm ci
46+
47+
lint:
48+
runs-on: ubuntu-latest
49+
steps:
50+
- name: checkout
51+
uses: actions/checkout@master
52+
53+
- name: restore cache from package-lock.json
54+
uses: actions/cache@v2
55+
with:
56+
path: package-temp-dir
57+
key: lock-${{ github.sha }}
58+
59+
- name: restore cache from node_modules
60+
uses: actions/cache@v2
61+
with:
62+
path: node_modules
63+
key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }}
64+
65+
- name: lint
66+
run: npm run lint
67+
68+
- name: ts check
69+
run: npm run lint:tsc
70+
71+
needs: setup
72+
73+
compile:
74+
runs-on: ubuntu-latest
75+
steps:
76+
- name: checkout
77+
uses: actions/checkout@master
78+
79+
- name: restore cache from package-lock.json
80+
uses: actions/cache@v2
81+
with:
82+
path: package-temp-dir
83+
key: lock-${{ github.sha }}
84+
85+
- name: restore cache from node_modules
86+
uses: actions/cache@v2
87+
with:
88+
path: node_modules
89+
key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }}
90+
91+
- name: compile
92+
run: npm run compile
93+
94+
needs: setup
95+
96+
coverage:
97+
runs-on: ubuntu-latest
98+
steps:
99+
- name: checkout
100+
uses: actions/checkout@master
101+
102+
- name: restore cache from package-lock.json
103+
uses: actions/cache@v2
104+
with:
105+
path: package-temp-dir
106+
key: lock-${{ github.sha }}
107+
108+
- name: restore cache from node_modules
109+
uses: actions/cache@v2
110+
with:
111+
path: node_modules
112+
key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }}
113+
114+
- name: coverage
115+
run: npm test -- --coverage && bash <(curl -s https://codecov.io/bash)
116+
117+
needs: setup

.github/workflows/preview.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: 🔂 Surge PR Preview
2+
3+
on: [pull_request]
4+
5+
jobs:
6+
preview:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v2
10+
- uses: afc163/surge-preview@v1
11+
id: preview_step
12+
with:
13+
surge_token: ${{ secrets.SURGE_TOKEN }}
14+
github_token: ${{ secrets.GITHUB_TOKEN }}
15+
dist: .doc
16+
build: |
17+
npm install
18+
npm run docs:build
19+
- name: Get the preview_url
20+
run: echo "url => ${{ steps.preview_step.outputs.preview_url }}"

.gitignore

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
.storybook
2+
*.iml
3+
*.log
4+
.idea
5+
.ipr
6+
.iws
7+
*~
8+
~*
9+
*.diff
10+
*.patch
11+
*.bak
12+
.DS_Store
13+
Thumbs.db
14+
.project
15+
.*proj
16+
.svn
17+
*.swp
18+
*.swo
19+
*.pyc
20+
*.pyo
21+
node_modules
22+
.cache
23+
*.css
24+
build
25+
lib
26+
coverage
27+
yarn.lock
28+
/es/
29+
package-lock.json
30+
.doc
31+
32+
# umi
33+
.umi
34+
.umi-production
35+
.umi-test
36+
.env.local

.prettierrc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"endOfLine": "lf",
3+
"semi": true,
4+
"singleQuote": true,
5+
"tabWidth": 2,
6+
"trailingComma": "all",
7+
"arrowParens": "avoid"
8+
}

.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+
});

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2019-present react-component
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# rc-portal
2+
3+
React 18 supported Portal Component.
4+
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] [![Codecov][codecov-image]][codecov-url] [![npm download][download-image]][download-url]
6+
7+
[npm-image]: http://img.shields.io/npm/v/rc-portal.svg?style=flat-square
8+
[npm-url]: http://npmjs.org/package/rc-portal
9+
[github-actions-image]: https://github.com/react-component/portal/workflows/CI/badge.svg
10+
[github-actions-url]: https://github.com/react-component/portal/actions
11+
[codecov-image]: https://img.shields.io/codecov/c/github/react-component/portal/master.svg?style=flat-square
12+
[codecov-url]: https://codecov.io/gh/react-component/portal/branch/master
13+
[download-image]: https://img.shields.io/npm/dm/rc-portal.svg?style=flat-square
14+
[download-url]: https://npmjs.org/package/rc-portal
15+
16+
## Development
17+
18+
```bash
19+
npm install
20+
npm start
21+
open http://localhost:8000
22+
```
23+
24+
## Feature
25+
26+
- React life cycle support portal component
27+
28+
## Install
29+
30+
[![rc-portal](https://nodei.co/npm/rc-portal.png)](https://npmjs.org/package/rc-portal)
31+
32+
## Usage
33+
34+
```js | pure
35+
import Portal from 'rc-portal';
36+
37+
const Demo = () => {
38+
return <Portal open>Hello World</Portal>;
39+
};
40+
41+
export default Demo;
42+
```
43+
44+
## 🔥 API
45+
46+
We use typescript to create the Type definition. You can view directly in IDE. But you can still check the type definition [here](https://github.com/react-component/portal/blob/master/src/interface.ts).
47+
48+
### Portal
49+
50+
| Prop | Description | Type | Default |
51+
| ------------ | ---------------------------------- | ------------------------ | ------------- |
52+
| getContainer | Customize portal container element | Element \| () => Element | document.body |
53+
| open | Show the portal | boolean | false |
54+
| autoLock | Lock screen scroll when open | boolean | false |

0 commit comments

Comments
 (0)