Skip to content

Commit 88b9efe

Browse files
author
zhaozhiwen
committed
feat: chapter-1 准备工作
0 parents  commit 88b9efe

16 files changed

+5410
-0
lines changed

.commitlintrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = { extends: ['@commitlint/config-conventional'] };

.editorconfig

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# http://editorconfig.org
2+
root = true
3+
4+
[*]
5+
indent_style = space
6+
indent_size = 2
7+
end_of_line = lf
8+
charset = utf-8
9+
trim_trailing_whitespace = true
10+
insert_final_newline = true
11+
12+
[*.md]
13+
trim_trailing_whitespace = false
14+
15+
[Makefile]
16+
indent_style = tab

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.js

.eslintrc.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module.exports = {
2+
extends: [require.resolve('@umijs/fabric/dist/eslint')],
3+
rules: {
4+
'react/require-default-props': 0,
5+
},
6+
};

.gitignore

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
/.vscode
4+
5+
# dependencies
6+
/node_modules
7+
/.pnp
8+
.pnp.js
9+
10+
/site
11+
# testing
12+
/coverage
13+
14+
# production
15+
/build
16+
/dist
17+
/lib
18+
/es
19+
/.docz
20+
/.doc-site
21+
/types
22+
23+
# misc
24+
.DS_Store
25+
.env.local
26+
.env.development.local
27+
.env.test.local
28+
.env.production.local
29+
30+
npm-debug.log*
31+
yarn-debug.log*
32+
yarn-error.log*

.prettierrc.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
const fabric = require('@umijs/fabric');
2+
3+
module.exports = {
4+
...fabric.prettier,
5+
};

.stylelintrc.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
extends: [require.resolve('@umijs/fabric/dist/stylelint')],
3+
};

components/alert/alert.tsx

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import React from 'react';
2+
import t from 'prop-types';
3+
4+
import { AlertProps, KindMap } from './interface';
5+
6+
const prefixCls = 'happy-alert';
7+
8+
const kinds: KindMap = {
9+
info: '#5352ED',
10+
positive: '#2ED573',
11+
negative: '#FF4757',
12+
warning: '#FFA502',
13+
};
14+
15+
const Alert: React.FC<AlertProps> = ({ children, kind = 'info', ...rest }) => (
16+
<div
17+
className={prefixCls}
18+
style={{
19+
background: kinds[kind],
20+
}}
21+
{...rest}
22+
>
23+
{children}
24+
</div>
25+
);
26+
27+
Alert.propTypes = {
28+
kind: t.oneOf(['info', 'positive', 'negative', 'warning']),
29+
};
30+
31+
export default Alert;

components/alert/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import Alert from './alert';
2+
3+
export default Alert;
4+
5+
export * from './interface';

components/alert/interface.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
export type Kind = 'info' | 'positive' | 'negative' | 'warning';
2+
export type KindMap = Record<Kind, string>;
3+
4+
export interface AlertProps {
5+
/**
6+
* Set this to change alert kind
7+
* @default info
8+
*/
9+
kind?: 'info' | 'positive' | 'negative' | 'warning';
10+
}

components/alert/style/index.less

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
@popupPrefix: happy-alert;
2+
3+
.@{popupPrefix} {
4+
padding: 20px;
5+
color: white;
6+
background: white;
7+
border-radius: 3;
8+
}

components/alert/style/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import './index.less';

components/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default as Alert } from './alert';

package.json

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
{
2+
"name": "react-ui-library-tutorial",
3+
"version": "1.0.0",
4+
"description": "",
5+
"main": "index.js",
6+
"scripts": {
7+
"commit": "git-cz",
8+
"test": "echo \"Error: no test specified\" && exit 1"
9+
},
10+
"repository": {
11+
"type": "git",
12+
"url": "git+https://github.com/worldzhao/react-ui-library-tutorial.git"
13+
},
14+
"keywords": [],
15+
"author": "",
16+
"license": "ISC",
17+
"bugs": {
18+
"url": "https://github.com/worldzhao/react-ui-library-tutorial/issues"
19+
},
20+
"homepage": "https://github.com/worldzhao/react-ui-library-tutorial#readme",
21+
"peerDependencies": {
22+
"react": ">=16.0.0",
23+
"react-dom": ">=16.0.0"
24+
},
25+
"devDependencies": {
26+
"@commitlint/cli": "^8.2.0",
27+
"@commitlint/config-conventional": "^8.2.0",
28+
"@umijs/fabric": "^1.2.12",
29+
"commitizen": "^4.0.3",
30+
"cz-conventional-changelog": "^3.0.2",
31+
"husky": "^3.1.0",
32+
"lint-staged": "^9.5.0",
33+
"prettier": "^1.19.1",
34+
"react": "^16.12.0",
35+
"react-dom": "^16.12.0",
36+
"typescript": "^3.7.3"
37+
},
38+
"lint-staged": {
39+
"components/**/*.ts?(x)": [
40+
"prettier --write",
41+
"eslint --fix",
42+
"git add"
43+
],
44+
"components/**/*.less": [
45+
"stylelint --syntax less --fix",
46+
"git add"
47+
]
48+
},
49+
"husky": {
50+
"hooks": {
51+
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS",
52+
"pre-commit": "lint-staged"
53+
}
54+
},
55+
"config": {
56+
"commitizen": {
57+
"path": "cz-conventional-changelog"
58+
}
59+
},
60+
"dependencies": {
61+
"prop-types": "^15.7.2"
62+
}
63+
}

tsconfig.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"compilerOptions": {
3+
"rootDir": "components",
4+
"baseUrl": "components",
5+
"target": "esnext",
6+
"module": "commonjs",
7+
"jsx": "react",
8+
"declaration": true,
9+
"outDir": "types",
10+
"strict": true,
11+
"moduleResolution": "node",
12+
"allowSyntheticDefaultImports": true,
13+
"esModuleInterop": true
14+
}
15+
}

0 commit comments

Comments
 (0)