|
1 | | -# dt-react-component |
| 1 | +<h1 align="center">dt-react-component</h1> |
| 2 | + |
| 3 | +<div align="center"> |
| 4 | + |
| 5 | +React UI component library based on [Ant Design](https://github.com/ant-design/ant-design) |
2 | 6 |
|
3 | 7 | [![NPM version][npm-image]][npm-url] [![NPM downloads][download-img]][download-url] |
4 | 8 |
|
|
7 | 11 | [download-img]: https://img.shields.io/npm/dm/dt-react-component.svg?style=flat |
8 | 12 | [download-url]: https://www.npmjs.com/package/dt-react-component |
9 | 13 |
|
| 14 | +</div> |
| 15 | + |
10 | 16 | English | [简体中文](./README-zh_CN.md) |
11 | 17 |
|
12 | 18 | ## Docs |
13 | 19 |
|
| 20 | +You can view [**online document**](https://dtstack.github.io/dt-react-component/) |
| 21 | + |
| 22 | +or view legacy documents following: |
| 23 | + |
14 | 24 | - [v3.x](https://dtstack.github.io/dt-react-component/) |
15 | 25 | - [v2.x](https://liuxy0551.github.io/dt-react-component/) |
16 | 26 |
|
17 | | -React UI component library based on [ant-design](https://github.com/ant-design/ant-design). Mainly used for middle and back-end products. Our goal is to **meet more specific and more specific business scenario components**. Of course, we also have excellent business components based on native javascript, such as **ContextMenu**, **KeyEventListener** and so on. |
| 27 | +React UI component library based on [Ant Design](https://github.com/ant-design/ant-design). Mainly used for middle and back-end products. Our goal is to **meet more specific and more specific business scenario components**. Of course, we also have excellent business components based on native javascript, such as **ContextMenu**, **KeyEventListener** and so on. |
18 | 28 |
|
19 | 29 | ## When to use |
20 | 30 |
|
21 | 31 | - When you find that the basic components provided by other component libraries do not meet the current business scenario, and you need to implement functions based on the basic components, you can use dt-react-component to solve the problem. |
22 | 32 | - When the business is complex, more and more business components are deposited. In order to better manage the components and reduce the redundancy of the code, you can use dt-react-component. Of course, we welcome PR. We will review and merge common business scenario components in a timely manner. |
23 | 33 |
|
24 | | -## How to contribute |
25 | | - |
26 | | -[CONTRIBUTING](./CONTRIBUTING.md) |
27 | | - |
28 | 34 | ## Install |
29 | 35 |
|
30 | | -```js |
31 | | -// use npm |
| 36 | +```shell |
| 37 | +# use npm |
32 | 38 | npm install dt-react-component |
33 | 39 |
|
34 | | -// use yarn |
| 40 | +# use yarn |
35 | 41 | yarn add dt-react-component |
36 | | -``` |
37 | | - |
38 | | -## Usage |
39 | 42 |
|
40 | | -```js |
41 | | -import { StatusTag, GoBack } from 'dt-react-component'; |
42 | | -const App = () => ( |
43 | | - <> |
44 | | - <StatusTag type="success">已完成</StatusTag> |
45 | | - <GoBack url="/api/manage" /> |
46 | | - </> |
47 | | -); |
| 43 | +# use pnpm |
| 44 | +pnpm install dt-react-component |
48 | 45 | ``` |
49 | 46 |
|
50 | | -And import style manually: |
51 | | - |
52 | | -```js |
53 | | -import 'dt-react-component/lib/style/index.css'; |
| 47 | +## Usage |
54 | 48 |
|
55 | | -// or |
56 | | -import 'dt-react-component/lib/style/index.scss'; |
| 49 | +```jsx |
| 50 | +import React from 'react'; |
| 51 | +import { BlockHeader } from 'dt-react-component'; |
| 52 | +const App = () => <BlockHeader title="分类标题" showBackground />; |
57 | 53 | ``` |
58 | 54 |
|
59 | 55 | ### Load on demand |
60 | 56 |
|
61 | | -The following two methods can only load the components used. |
62 | | - |
63 | | -- We strongly recommend using the [babel-plugin-treasure](https://github.com/DTStack/babel-plugin-treasure) plugin that perfectly adapts to dt-react-component. |
64 | | - |
65 | | -```js |
66 | | -// .babelrc or babel-loader option |
67 | | -"plugins": [ |
68 | | - [ |
69 | | - "treasure", |
70 | | - { |
71 | | - "libraryName": "dt-react-component", |
72 | | - "libraryDirectory": "lib", |
73 | | - "style": "css" // `style: true` Will load the scss file |
74 | | - } |
75 | | - ] |
76 | | - ] |
77 | | - |
78 | | -``` |
79 | | - |
80 | | -Then just import the module from dt-react-component, no need to import style separately. It is equivalent to the manual introduction below. |
81 | | - |
82 | | -```js |
83 | | -// babel-plugin-treasure will help you load JS and CSS |
84 | | -import { ContextMenu } from 'dt-react-component'; |
85 | | -``` |
86 | | - |
87 | | -See more [babel-plugin-treasure](https://github.com/DTStack/babel-plugin-treasure). |
88 | | - |
89 | | -- Manual introduction |
90 | | - |
91 | | -```js |
92 | | -import MarkdownRender from 'dt-react-component/lib/markdownRender'; // Load JS |
93 | | -import 'dt-react-component/lib/markdownRender/style/css'; // Load CSS |
94 | | -// import 'dt-react-component/lib/markdownRender/style'; // Load SCSS |
95 | | -``` |
| 57 | +We supports tree shaking of ES modules, so using `import { BlockHeader } from 'dt-react-component';` would drop js code you didn't use. |
96 | 58 |
|
97 | 59 | ### TypeScript |
98 | 60 |
|
99 | 61 | dt-react-component is written in TypeScript with complete definitions, So you will have a better smart reminder experience. |
100 | 62 |
|
101 | | -### Preview address |
102 | | - |
103 | | -You can view the latest components and documents at this address |
| 63 | +## How to contribute |
104 | 64 |
|
105 | | -[https://dtstack.github.io/dt-react-component/](https://dtstack.github.io/dt-react-component/) |
| 65 | +[CONTRIBUTING](./CONTRIBUTING.md) |
106 | 66 |
|
107 | 67 | ## Development |
108 | 68 |
|
109 | 69 | clone locally: |
110 | 70 |
|
111 | | -```js |
| 71 | +```bash |
112 | 72 | $ git clone [email protected]:DTStack/dt-react-component.git |
113 | 73 | $ cd dt-react-component |
114 | | -$ npm install |
115 | | -$ npm run storybook |
| 74 | +$ pnpm install |
| 75 | +$ pnpm run dev |
116 | 76 | ``` |
117 | 77 |
|
118 | | -Open your browser and visit [http://127.0.0.1:9001](http://127.0.0.1:9001),We manage components based on storybook. see more at [Storybook](https://storybook.js.org/). |
| 78 | +Open your browser and visit [http://127.0.0.1:8000](http://127.0.0.1:8000),We manage components based on dumi. see more at [dumi](https://d.umijs.org/). |
119 | 79 |
|
120 | 80 | ## Publish |
121 | 81 |
|
122 | 82 | ```bash |
123 | | -yarn compile |
124 | | -yarn release -r 3.0.1 |
125 | | -npm publish --registry https://registry.npmjs.org/ |
| 83 | +pnpm build |
| 84 | +pnpm release -r 3.0.1 |
| 85 | +pnpm publish --registry https://registry.npmjs.org/ |
126 | 86 | ``` |
127 | 87 |
|
128 | | -## Roadmap |
| 88 | +### Publish website |
129 | 89 |
|
130 | | -- We will support and improve more components |
131 | | -- Internationalized language support |
132 | | -- Support theme customization |
| 90 | +```bash |
| 91 | +pnpm docs:build |
| 92 | +pnpm deploy |
| 93 | +``` |
133 | 94 |
|
134 | 95 | ## Contributing |
135 | 96 |
|
|
0 commit comments