Skip to content

Commit

Permalink
feat: sync code
Browse files Browse the repository at this point in the history
sync code
  • Loading branch information
zhangtengjin committed Jan 5, 2021
2 parents d452763 + acf391a commit fdb7f69
Show file tree
Hide file tree
Showing 17 changed files with 813 additions and 30,638 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ node_modules
storybook-static
lib
dist
.temporary_files
.temporary_files
coverage
package-lock.json
5 changes: 4 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,7 @@ storyshots.test.js
tsconfig.build.json
tsconfig.json
dist
gulpfile
gulpfile.js
coverage
css-plugin.js
yarn.lock
120 changes: 120 additions & 0 deletions README-zh_CN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
# dt-react-component

[![NPM version][npm-image]][npm-url] [![NPM downloads][download-img]][download-url]

[npm-image]: https://img.shields.io/npm/v/dt-react-component.svg?style=flat-square
[npm-url]: https://www.npmjs.com/package/dt-react-component

[download-img]: https://img.shields.io/npm/dm/dt-react-component.svg?style=flat
[download-url]: https://www.npmjs.com/package/dt-react-component

[English](./README.md) | 简体中文

基于 [ant-design](https://github.com/ant-design/ant-design) 的 React UI 组件库。 主要用于中,后台产品。我们的目标是**满足更具体的业务场景组件**。 当然,我们也有基于原生 javascript 实现的业务组件,例如**ContextMenu****KeyEventListener**等。

## 何时使用
+ 当发现其他组件库提供的基本组件不符合当前的业务场景,并且需要基于这些基本组件实现功能时,可以考虑使用 dt-react-component 解决问题。
+ 当业务复杂时,将沉淀越来越多的业务组件。 为了更好地管理组件并减少代码的冗余,可以使用 dt-react-component。 当然,我们欢迎 PR。 我们也将及时审查和合并常见的业务场景组件。

## 安装

```js
// use npm
npm install dt-react-component

// use yarn
yarn add dt-react-component
```

## 使用

```js
import { Circle, GoBack } from 'dt-react-component'
const App = () => (
<>
<Circle type='finished'/>
<GoBack url='/api/manage' />
</>
);
```
并手动导入样式:

```js
import 'dt-react-component/lib/style/index.css'

// or
import 'dt-react-component/lib/style/index.scss'

```

### 按需加载

下面两种方式都可以只加载用到的组件。
+ 我们强烈建议您使用 [babel-plugin-treasure](https://github.com/DTStack/babel-plugin-treasure) 完全适配 dt-react-component 的插件。

```js
// .babelrc or babel-loader option
"plugins": [
[
"treasure",
{
"libraryName": "dt-react-component",
"libraryDirectory": "lib",
"style": "css" // `style: true` Will load the scss file
}
]
]

```

然后只需从 dt-react-component 引入模块即可,无需单独引入样式。等同于下面手动引入的方式。

```js
// babel-plugin-treasure will help you load JS and CSS
import { ContextMenu } from 'dt-react-component';
```
更多请见 [babel-plugin-treasure](https://github.com/DTStack/babel-plugin-treasure).

+ 手动引入

```js
import MarkdownRender from 'dt-react-component/lib/markdownRender'; // Load JS
import 'dt-react-component/lib/markdownRender/style/css'; // Load CSS
// import 'dt-react-component/lib/markdownRender/style'; // Load SCSS
```

### TypeScript
dt-react-component 完全基于 TypeScript 编写,具有完整的类型定义,因此您将拥有更好的体验。

### 预览地址
您可以在此地址查看最新的组件和文档。

[https://dtstack.github.io/dt-react-component/](https://dtstack.github.io/dt-react-component/)


## 开发

本地克隆:

```js
$ git clone git@github.com:DTStack/dt-react-component.git
$ cd dt-react-component
$ npm install
$ npm run storybook
```
打开浏览器并访问 [http://127.0.0.1:9001](http://127.0.0.1:9001),我们基于 stroybook 管理组件。 更多信息请访问 [Storybook](https://storybook.js.org/).

## 路线图
+ 支持和改进更多组件
+ 国际化语言支持
+ 支持主题定制

## 贡献

我们欢迎所有贡献。 您可以将任何想法提交为 [pull requests](https://github.com/DTStack/dt-react-component/pulls) 或者 [issues](https://github.com/DTStack/dt-react-component/issues).

最后,感谢我们所有 [contributors](https://github.com/DTStack/dt-react-component/graphs/contributors)

## 许可证

ISC
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
# dt-react-component

React UI component library based on ant-design. Mainly used for middle and back-end products. Most importantly, its purpose is not to replace excellent component libraries such as ant-design and element-ui. 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.
[![NPM version][npm-image]][npm-url] [![NPM downloads][download-img]][download-url]

[npm-image]: https://img.shields.io/npm/v/dt-react-component.svg?style=flat-square
[npm-url]: https://www.npmjs.com/package/dt-react-component

[download-img]: https://img.shields.io/npm/dm/dt-react-component.svg?style=flat
[download-url]: https://www.npmjs.com/package/dt-react-component

English | [简体中文](./README-zh_CN.md)

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.

## When to use
+ 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.
Expand Down
13 changes: 7 additions & 6 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const mergeStream = require('merge-stream');
let existStyleCatalogName = [];
let componentCatalogName = [];
const folderName = '.temporary_files';
const basePath = 'src/components/';

function difference(array, arrCompare) {
return array.concat(arrCompare).filter(function(v, i, arr) {
Expand All @@ -30,7 +31,7 @@ function unique(arr) {

function writeStyleFile(catalogArr) {
for (let catalogName of catalogArr) {
fs.writeFile(`src/components/${catalogName}/style.scss`, '', { flag: 'wx' }, err => {
fs.writeFile(`${basePath}${catalogName}/style.scss`, '', { flag: 'wx' }, err => {
if (err) {
throw err;
}
Expand All @@ -40,15 +41,15 @@ function writeStyleFile(catalogArr) {

function delStyleFile(catalogArr) {
for (let catalogName of catalogArr) {
del([`src/components/${catalogName}/style.scss`]);
del([`${basePath}${catalogName}/style.scss`]);
}
}
/**
* traverse files
* @param isDelete Distinguish between write and delete style file
*/
function traverseExistStyleFile(isDelete) {
return src(['src/components/*/*.scss'])
return src([`${basePath}*/*.scss`])
.pipe(
through.obj(function(file, enc, callback) {
isExist = Boolean(file.contents.toString());
Expand All @@ -73,7 +74,7 @@ function traverseExistStyleFile(isDelete) {

function traverseComponent() {
console.warn('Do not edit the source file when the project is compiled !!!');
return src(['src/components/*/', '!src/components/utils/']) // exclude utils/
return src([`${basePath}*/`, `!${basePath}utils/`]) // exclude utils/
.pipe(
through.obj(function(file, enc, callback) {
componentCatalogName.push(file.relative.split('/')[0]);
Expand Down Expand Up @@ -126,7 +127,7 @@ function outputStyleTask(componentCatalogName) {
}

function globalSass() {
return src('src/components/**/*.scss')
return src(`${basePath}**/*.scss`)
.pipe(concat('index.scss'))
.pipe(dest('lib/style'));
}
Expand Down Expand Up @@ -169,7 +170,7 @@ function outputForCssFile(data){
}

function outputForCss(data) {
return src(['src/components/' + String(data) + '/*.scss'])
return src([`${basePath}` + String(data) + '/*.scss'])
.pipe(dest('lib/' + String(data) + '/style/'))
.pipe(sass())
.pipe(dest('lib/' + String(data) + '/style/'))
Expand Down
Loading

0 comments on commit fdb7f69

Please sign in to comment.