Skip to content

Commit cae4ba6

Browse files
authored
Create react-component-ci.yml (#158)
* Create react-component-ci.yml * add tsconfig.json * fix lint error * remove circleci
1 parent 05b3355 commit cae4ba6

File tree

5 files changed

+150
-55
lines changed

5 files changed

+150
-55
lines changed

.circleci/config.yml

Lines changed: 0 additions & 37 deletions
This file was deleted.
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
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+
needs: setup
69+
70+
compile:
71+
runs-on: ubuntu-latest
72+
steps:
73+
- name: checkout
74+
uses: actions/checkout@master
75+
76+
- name: restore cache from package-lock.json
77+
uses: actions/cache@v2
78+
with:
79+
path: package-temp-dir
80+
key: lock-${{ github.sha }}
81+
82+
- name: restore cache from node_modules
83+
uses: actions/cache@v2
84+
with:
85+
path: node_modules
86+
key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }}
87+
88+
- name: compile
89+
run: npm run compile
90+
91+
needs: setup
92+
93+
coverage:
94+
runs-on: ubuntu-latest
95+
steps:
96+
- name: checkout
97+
uses: actions/checkout@master
98+
99+
- name: restore cache from package-lock.json
100+
uses: actions/cache@v2
101+
with:
102+
path: package-temp-dir
103+
key: lock-${{ github.sha }}
104+
105+
- name: restore cache from node_modules
106+
uses: actions/cache@v2
107+
with:
108+
path: node_modules
109+
key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }}
110+
111+
- name: coverage
112+
run: npm test -- --coverage && bash <(curl -s https://codecov.io/bash)
113+
114+
needs: setup

src/DrawerWrapper.tsx

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ class DrawerWrapper extends React.Component<IDrawerProps, IState> {
2121
level: 'all',
2222
duration: '.3s',
2323
ease: 'cubic-bezier(0.78, 0.14, 0.15, 0.86)',
24-
onChange: () => { },
25-
afterVisibleChange: () => { },
24+
onChange: () => {},
25+
afterVisibleChange: () => {},
2626
handler: (
2727
<div className="drawer-handle">
2828
<i className="drawer-handle-icon" />
@@ -37,8 +37,10 @@ class DrawerWrapper extends React.Component<IDrawerProps, IState> {
3737
forceRender: false,
3838
};
3939

40-
public static getDerivedStateFromProps(props: IDrawerProps,
41-
{ prevProps }: { prevProps: IDrawerProps }) {
40+
public static getDerivedStateFromProps(
41+
props: IDrawerProps,
42+
{ prevProps }: { prevProps: IDrawerProps },
43+
) {
4244
const newState: {
4345
open?: boolean;
4446
prevProps: IDrawerProps;
@@ -55,7 +57,8 @@ class DrawerWrapper extends React.Component<IDrawerProps, IState> {
5557

5658
constructor(props: IDrawerProps) {
5759
super(props);
58-
const open = typeof props.open !== 'undefined' ? props.open : !!props.defaultOpen;
60+
const open =
61+
typeof props.open !== 'undefined' ? props.open : !!props.defaultOpen;
5962
this.state = {
6063
open,
6164
};
@@ -75,7 +78,7 @@ class DrawerWrapper extends React.Component<IDrawerProps, IState> {
7578
open: !open,
7679
});
7780
}
78-
}
81+
};
7982

8083
private onClose = (e: React.MouseEvent | React.KeyboardEvent) => {
8184
const { onClose, open } = this.props;
@@ -87,7 +90,7 @@ class DrawerWrapper extends React.Component<IDrawerProps, IState> {
8790
open: false,
8891
});
8992
}
90-
}
93+
};
9194

9295
// tslint:disable-next-line:member-ordering
9396
public render() {
@@ -105,7 +108,9 @@ class DrawerWrapper extends React.Component<IDrawerProps, IState> {
105108
return (
106109
<div
107110
className={wrapperClassName}
108-
ref={c => { this.dom = c; }}
111+
ref={c => {
112+
this.dom = c;
113+
}}
109114
>
110115
<Child
111116
{...props}
@@ -134,7 +139,9 @@ class DrawerWrapper extends React.Component<IDrawerProps, IState> {
134139
{...props}
135140
{...rest}
136141
open={visible !== undefined ? visible : open}
137-
afterVisibleChange={afterClose !== undefined ? afterClose : props.afterVisibleChange}
142+
afterVisibleChange={
143+
afterClose !== undefined ? afterClose : props.afterVisibleChange
144+
}
138145
handler={handler}
139146
onClose={this.onClose}
140147
onHandleClick={this.onHandleClick}

src/IDrawerPropTypes.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,13 @@
22
// Project: https://github.com/react-component/drawer
33
// Definitions by: jljsj33 <https://github.com/jljsj33>
44
// Definitions: https://github.com/react-component/drawer
5+
import { GetContainer } from 'rc-util/lib/PortalWrapper';
56
import * as React from 'react';
67

7-
88
export type IPlacement = 'left' | 'top' | 'right' | 'bottom';
99

1010
type ILevelMove = number | [number, number];
1111

12-
type IStringOrHtmlElement = string | HTMLElement;
13-
1412
type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
1513

1614
interface IProps extends Omit<React.HTMLAttributes<any>, 'onChange'> {
@@ -22,23 +20,25 @@ interface IProps extends Omit<React.HTMLAttributes<any>, 'onChange'> {
2220
handler?: React.ReactElement | null | false;
2321
placement?: IPlacement;
2422
level?: null | string | string[];
25-
levelMove?: ILevelMove | ((e: { target: HTMLElement, open: boolean }) => ILevelMove);
23+
levelMove?:
24+
| ILevelMove
25+
| ((e: { target: HTMLElement; open: boolean }) => ILevelMove);
2626
duration?: string;
2727
ease?: string;
2828
showMask?: boolean;
2929
maskClosable?: boolean;
3030
maskStyle?: React.CSSProperties;
31-
onChange?: ((open?: boolean) => void);
32-
afterVisibleChange?: ((open: boolean) => void);
33-
onHandleClick?: ((e: React.MouseEvent | React.KeyboardEvent) => void);
34-
onClose?: ((e: React.MouseEvent | React.KeyboardEvent) => void);
31+
onChange?: (open?: boolean) => void;
32+
afterVisibleChange?: (open: boolean) => void;
33+
onHandleClick?: (e: React.MouseEvent | React.KeyboardEvent) => void;
34+
onClose?: (e: React.MouseEvent | React.KeyboardEvent) => void;
3535
keyboard?: boolean;
3636
}
3737

3838
export interface IDrawerProps extends IProps {
3939
wrapperClassName?: string;
4040
forceRender?: boolean;
41-
getContainer?: IStringOrHtmlElement | (() => IStringOrHtmlElement) | null | false;
41+
getContainer?: GetContainer;
4242
}
4343

4444
export interface IDrawerChildProps extends IProps {

tsconfig.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"compilerOptions": {
3+
"target": "esnext",
4+
"moduleResolution": "node",
5+
"baseUrl": "./",
6+
"jsx": "preserve",
7+
"declaration": true,
8+
"skipLibCheck": true,
9+
"esModuleInterop": true
10+
}
11+
}

0 commit comments

Comments
 (0)