File tree Expand file tree Collapse file tree 12 files changed +31
-28
lines changed Expand file tree Collapse file tree 12 files changed +31
-28
lines changed Original file line number Diff line number Diff line change 1
1
template /
2
2
* .js
3
- ** /demo
3
+ ** /demo /
4
+ ** /__tests__ /
Original file line number Diff line number Diff line change 16
16
/dist
17
17
/lib
18
18
/esm
19
- /.docz
20
19
/doc-site
21
20
/types
22
21
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ import { defineConfig } from 'dumi';
4
4
let base = '/react-ui-library-tutorial' ;
5
5
let publicPath = '/react-ui-library-tutorial/' ;
6
6
7
- if ( process . env . DOC_BUILD_ENV === 'local ' ) {
7
+ if ( process . env . SITE_BUILD_ENV === 'PREVIEW ' ) {
8
8
base = undefined ;
9
9
publicPath = undefined ;
10
10
}
Original file line number Diff line number Diff line change 14
14
15
15
于是在部门内搭了一个简单的组件库,组件不多,但在搭建过程中掌握了很多知识,再看 antd 等热门组件库,对其中的一些设计也有了更深的感悟,故记录下来,希望能帮助到其他的同学。
16
16
17
- [ 🚀 在线预览] ( https://happy-ui.now.sh )
17
+ [ 🚀 在线预览] ( https://worldzhao.github.io/react-ui-library-tutorial )
18
18
19
19
🚆 本地预览
20
20
@@ -27,15 +27,15 @@ yarn start
27
27
28
28
按顺序执行完命令后,即可在 localhost:3000 端口看到以下内容:
29
29
30
- ![ preview] ( https://raw.githubusercontent.com/worldzhao/blog/master/images/rc-lib-1.jpg )
30
+ ![ preview] ( https://raw.githubusercontent.com/worldzhao/blog/master/images/rc-lib-v1- 1.jpg )
31
31
32
32
## 概览
33
33
34
34
本系列文章主要包含以下内容:
35
35
36
36
- 项目初始化: 组件库前期开发准备工作。` eslint ` /` commit lint ` /` typescript ` 等等;
37
- - 开发阶段: 使用[ docz ] ( https://github.com/doczjs/docz ) 进行开发调试以及文档编写;
37
+ - 开发阶段: 使用[ dumi ] ( https://d.umijs.org/zh-CN ) 进行开发调试以及文档编写;
38
38
- 打包阶段: 输出~~ ` umd ` ~~ /` cjs ` /` esm ` 产物并支持按需加载;
39
39
- 组件测试: 使用` @testing-library/react ` 及其相关生态进行组件测试;
40
- - 发布 npm: 编写脚本完成自动化发布 ;
41
- - 部署文档站点: 使用[ now ] ( https://zeit.co/home ) 部署文档站点 。
40
+ - 发布 npm: 编写脚本完成发布或直接使用 [ np ] ( https://www.npmjs.com/package/np ) 发布 ;
41
+ - 部署文档站点: 使用 Github Pages 以及 Github Actions 完成文档站点自动部署 。
Original file line number Diff line number Diff line change 11
11
** 使用 npm 或 yarn 安装**
12
12
13
13
``` shell
14
- $ npm install @zzzzw/happy-ui --save
14
+ npm install @zzzzw/happy-ui
15
15
```
16
16
17
17
``` shell
Original file line number Diff line number Diff line change 22
22
"dev" : " dumi dev" ,
23
23
"start" : " npm run dev" ,
24
24
"build:site" : " rimraf doc-site && dumi build" ,
25
- "preview:site" : " cross-env DOC_BUILD_ENV=local npm run build:site && serve doc-site" ,
25
+ "preview:site" : " cross-env SITE_BUILD_ENV=PREVIEW npm run build:site && serve doc-site" ,
26
26
"deploy:site" : " npm run build:site && gh-pages -d doc-site" ,
27
27
"clean" : " rimraf lib esm dist" ,
28
28
"build:types" : " tsc -p tsconfig.build.json && cpr lib esm" ,
Original file line number Diff line number Diff line change 1
1
import React from 'react' ;
2
2
import { render } from '@testing-library/react' ;
3
- import Alert from '../alert ' ;
3
+ import Alert from '..' ;
4
4
5
5
describe ( '<Alert />' , ( ) => {
6
6
test ( 'should render default' , ( ) => {
Original file line number Diff line number Diff line change 1
1
import React from 'react' ;
2
- import Alert from '../alert ' ;
2
+ import Alert from '../' ;
3
3
import '../style' ;
4
4
5
5
export default ( ) => < Alert kind = "warning" > 这是一条警告提示</ Alert > ;
Original file line number Diff line number Diff line change 8
8
order : 1
9
9
---
10
10
11
+ # Alert 警告提示
12
+
13
+ 警告提示,展现需要关注的信息。
14
+
15
+ ## 代码演示
16
+
17
+ ### 基本用法
18
+
11
19
<code src =" ./demo/basic.tsx " ></code >
20
+
21
+ <API src =" ./index.tsx " ></API >
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1
1
import React from 'react' ;
2
2
import t from 'prop-types' ;
3
3
4
- import { AlertProps , KindMap } from './interface' ;
4
+ export interface AlertProps {
5
+ /**
6
+ * @description Alert 的类型
7
+ * @default 'info'
8
+ */
9
+ kind ?: 'info' | 'positive' | 'negative' | 'warning' ;
10
+ }
11
+
12
+ export type KindMap = Record < Required < AlertProps > [ 'kind' ] , string > ;
5
13
6
14
const prefixCls = 'happy-alert' ;
7
15
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments