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+
}

0 commit comments

Comments
 (0)