From aebfb1cad079ea27341a559c33c69674fe5ebb74 Mon Sep 17 00:00:00 2001 From: xrkffgg Date: Thu, 3 Dec 2020 18:02:46 +0800 Subject: [PATCH 1/3] chore: use dumi --- .editorconfig | 17 ++++++--- .eslintrc.js | 1 + .gitignore | 6 ++++ .umirc.ts | 17 +++++++++ HISTORY.md => docs/changelog.md | 36 +++++++++++++++++-- docs/demo/ant-design.md | 3 ++ docs/demo/bootstrap.md | 3 ++ docs/demo/draggable.md | 3 ++ docs/demo/multiple-Portal.md | 3 ++ {examples => docs/examples}/ant-design.tsx | 4 +-- {examples => docs/examples}/bootstrap.tsx | 4 +-- {examples => docs/examples}/draggable.tsx | 4 +-- .../examples}/multiple-Portal.tsx | 4 +-- README.md => docs/index.md | 18 ++++------ now.json | 3 ++ package.json | 14 ++++++-- script/update-content.js | 29 +++++++++++++++ tsconfig.json | 16 +++++++++ typings.d.ts | 2 ++ 19 files changed, 158 insertions(+), 29 deletions(-) create mode 100644 .umirc.ts rename HISTORY.md => docs/changelog.md (79%) create mode 100644 docs/demo/ant-design.md create mode 100644 docs/demo/bootstrap.md create mode 100644 docs/demo/draggable.md create mode 100644 docs/demo/multiple-Portal.md rename {examples => docs/examples}/ant-design.tsx (98%) rename {examples => docs/examples}/bootstrap.tsx (98%) rename {examples => docs/examples}/draggable.tsx (95%) rename {examples => docs/examples}/multiple-Portal.tsx (94%) rename README.md => docs/index.md (94%) create mode 100644 script/update-content.js create mode 100644 tsconfig.json create mode 100644 typings.d.ts diff --git a/.editorconfig b/.editorconfig index 604c94ef..7e3649ac 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,9 +1,16 @@ -# top-most EditorConfig file +# http://editorconfig.org root = true -# Unix-style newlines with a newline ending every file -[*.{js,css}] -end_of_line = lf -insert_final_newline = true +[*] indent_style = space indent_size = 2 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[*.md] +trim_trailing_whitespace = false + +[Makefile] +indent_style = tab diff --git a/.eslintrc.js b/.eslintrc.js index 54d1afd5..c49235ed 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -12,6 +12,7 @@ module.exports = { "@typescript-eslint/no-inferrable-types": 0, "react/require-default-props": 0, "no-confusing-arrow": 0, + 'import/no-extraneous-dependencies': 0, "import/no-named-as-default-member": 0, "jsx-a11y/label-has-for": 0, "jsx-a11y/label-has-associated-control": 0, diff --git a/.gitignore b/.gitignore index d7e68431..a599dfd5 100644 --- a/.gitignore +++ b/.gitignore @@ -34,3 +34,9 @@ coverage yarn.lock .storybook .doc + +# umi +.umi +.umi-production +.umi-test +.env.local diff --git a/.umirc.ts b/.umirc.ts new file mode 100644 index 00000000..62f42288 --- /dev/null +++ b/.umirc.ts @@ -0,0 +1,17 @@ +// more config: https://d.umijs.org/config +import { defineConfig } from 'dumi'; + +export default defineConfig({ + title: 'rc-dialog', + favicon: + 'https://avatars0.githubusercontent.com/u/9441414?s=200&v=4', + logo: + 'https://avatars0.githubusercontent.com/u/9441414?s=200&v=4', + outputPath: '.doc', + exportStatic: {}, + styles: [ + `a img + svg { + display: none; + }` + ] +}); diff --git a/HISTORY.md b/docs/changelog.md similarity index 79% rename from HISTORY.md rename to docs/changelog.md index 355b1d35..e155ef3e 100644 --- a/HISTORY.md +++ b/docs/changelog.md @@ -1,5 +1,37 @@ -# History ----- +# Changelog + +## 8.4.4 + +`2020-12-03` + +- fix: dialog dont close when mouseDown in content and mouseUp in wrapper. [#210](https://github.com/react-component/dialog/pull/210) + +- chore: Should not re-render when dialog is invisible. [#212](https://github.com/react-component/dialog/pull/212) + + +## 8.4.3 + +`2020-10-21` + +- chore: support react 17. [#207](https://github.com/react-component/dialog/pull/207) + +## 8.4.2 + +`2020-10-14` + +- fix: Dialog should not auto destroy. [#206](https://github.com/react-component/dialog/pull/206) + +## 8.4.1 + +`2020-10-11` + +- fix: Portal event bubble. [#204](https://github.com/react-component/dialog/pull/204) + +## 8.4.0 + +`2020-09-29` + +- refactor: Use `rc-motion`. [#203](https://github.com/react-component/dialog/pull/203) ## 8.3.4 (8.2.2, 8.1.2) / 2020-09-04 - fix: prevent scroll behavior when focus trigger. [ant-design/ant-design#26582](https://github.com/ant-design/ant-design/issues/26582) diff --git a/docs/demo/ant-design.md b/docs/demo/ant-design.md new file mode 100644 index 00000000..a8441c94 --- /dev/null +++ b/docs/demo/ant-design.md @@ -0,0 +1,3 @@ +## ant-design + + diff --git a/docs/demo/bootstrap.md b/docs/demo/bootstrap.md new file mode 100644 index 00000000..10c34535 --- /dev/null +++ b/docs/demo/bootstrap.md @@ -0,0 +1,3 @@ +## bootstrap + + diff --git a/docs/demo/draggable.md b/docs/demo/draggable.md new file mode 100644 index 00000000..eced05ac --- /dev/null +++ b/docs/demo/draggable.md @@ -0,0 +1,3 @@ +## draggable + + diff --git a/docs/demo/multiple-Portal.md b/docs/demo/multiple-Portal.md new file mode 100644 index 00000000..d2e30ecb --- /dev/null +++ b/docs/demo/multiple-Portal.md @@ -0,0 +1,3 @@ +## multiple-Portal + + diff --git a/examples/ant-design.tsx b/docs/examples/ant-design.tsx similarity index 98% rename from examples/ant-design.tsx rename to docs/examples/ant-design.tsx index b4679296..5b68ee15 100644 --- a/examples/ant-design.tsx +++ b/docs/examples/ant-design.tsx @@ -1,9 +1,9 @@ /* eslint no-console:0 */ -import '../assets/index.less'; import * as React from 'react'; import Select from 'rc-select'; import 'rc-select/assets/index.less'; -import Dialog from '../src/DialogWrap'; +import Dialog from 'rc-dialog'; +import '../../assets/index.less'; const clearPath = 'M793 242H366v-74c0-6.7-7.7-10.4-12.9' + diff --git a/examples/bootstrap.tsx b/docs/examples/bootstrap.tsx similarity index 98% rename from examples/bootstrap.tsx rename to docs/examples/bootstrap.tsx index 1420329b..2b696ac1 100644 --- a/examples/bootstrap.tsx +++ b/docs/examples/bootstrap.tsx @@ -1,7 +1,7 @@ import 'bootstrap/dist/css/bootstrap.css'; -import '../assets/bootstrap.less'; import * as React from 'react'; -import Dialog from '../src/DialogWrap'; +import Dialog from 'rc-dialog'; +import '../../assets/index.less'; // Check for memo update should work const InnerRender = () => { diff --git a/examples/draggable.tsx b/docs/examples/draggable.tsx similarity index 95% rename from examples/draggable.tsx rename to docs/examples/draggable.tsx index 92cbc10c..789d5666 100644 --- a/examples/draggable.tsx +++ b/docs/examples/draggable.tsx @@ -1,8 +1,8 @@ import 'bootstrap/dist/css/bootstrap.css'; -import '../assets/bootstrap.less'; import * as React from 'react'; import Draggable from 'react-draggable'; -import Dialog from '../src/DialogWrap'; +import Dialog from 'rc-dialog'; +import '../../assets/index.less'; const MyControl = () => { const [visible, setVisible] = React.useState(false); diff --git a/examples/multiple-Portal.tsx b/docs/examples/multiple-Portal.tsx similarity index 94% rename from examples/multiple-Portal.tsx rename to docs/examples/multiple-Portal.tsx index 81350206..b7d6c120 100644 --- a/examples/multiple-Portal.tsx +++ b/docs/examples/multiple-Portal.tsx @@ -1,8 +1,8 @@ import * as React from 'react'; import Drawer from 'rc-drawer'; -import Dialog from '../src/DialogWrap'; import 'rc-drawer/assets/index.css'; -import '../assets/index.less'; +import Dialog from 'rc-dialog'; +import '../../assets/index.less'; const { useState } = React; diff --git a/README.md b/docs/index.md similarity index 94% rename from README.md rename to docs/index.md index 3fb3b760..c7177b54 100644 --- a/README.md +++ b/docs/index.md @@ -3,13 +3,7 @@ react dialog component -[![NPM version][npm-image]][npm-url] -[![build status][github-actions-image]][github-actions-url] -[![Test coverage][coveralls-image]][coveralls-url] -[![Dependencies][david-image]][david-url] -[![DevDependencies][david-dev-image]][david-dev-url] -[![npm download][download-image]][download-url] -[![bundle size][bundlephobia-image]][bundlephobia-url] +[![NPM version][npm-image]][npm-url] [![build status][github-actions-image]][github-actions-url] [![Test coverage][coveralls-image]][coveralls-url] [![Dependencies][david-image]][david-url] [![DevDependencies][david-dev-image]][david-dev-url] [![npm download][download-image]][download-url] [![bundle size][bundlephobia-image]][bundlephobia-url] [npm-image]: http://img.shields.io/npm/v/rc-dialog.svg?style=flat-square [npm-url]: http://npmjs.org/package/rc-dialog @@ -32,6 +26,12 @@ react dialog component +## Example + +http://localhost:8007/examples/ + +online example: http://react-component.github.io/dialog/ + ## Install [![rc-dialog](https://nodei.co/npm/rc-dialog.png)](https://npmjs.org/package/rc-dialog) @@ -90,11 +90,7 @@ npm install npm start ``` -## Example -http://localhost:8007/examples/ - -online example: http://react-component.github.io/dialog/ ## Test Case diff --git a/now.json b/now.json index 1d18e2a0..6eaa4d61 100644 --- a/now.json +++ b/now.json @@ -7,5 +7,8 @@ "use": "@now/static-build", "config": { "distDir": ".doc" } } + ], + "routes": [ + { "src": "/(.*)", "dest": "/dist/$1" } ] } diff --git a/package.json b/package.json index 8cdb85e6..c45928d6 100644 --- a/package.json +++ b/package.json @@ -28,15 +28,19 @@ "main": "./lib/index", "module": "./es/index", "scripts": { - "start": "cross-env NODE_ENV=development father doc dev --storybook", + "start": "dumi dev", + "docs:build": "dumi build", + "docs:deploy": "gh-pages -d .doc", "build": "father doc build --storybook", "compile": "father build && lessc assets/index.less assets/index.css && lessc assets/bootstrap.less assets/bootstrap.css", - "gh-pages": "npm run build && father doc deploy", + "deploy": "npm run docs:build && npm run docs:deploy", "prepublishOnly": "npm run compile && np --yolo --no-publish", "lint": "eslint src/ --ext .ts,.tsx,.jsx,.js,.md", + "lint:tsc": "tsc -p tsconfig.json --noEmit", "prettier": "prettier --write \"**/*.{ts,tsx,js,jsx,json,md}\"", "test": "father test", - "coverage": "father test --coverage" + "coverage": "father test --coverage", + "now-build": "npm run docs:build" }, "peerDependencies": { "react": ">=16.9.0", @@ -57,6 +61,7 @@ "bluebird": "~3.7.2", "bootstrap": "^4.3.1", "cross-env": "^7.0.0", + "dumi": "^1.0.37", "enzyme": "^3.1.1", "enzyme-adapter-react-16": "^1.0.1", "enzyme-to-json": "^3.1.2", @@ -64,6 +69,9 @@ "eslint-config-airbnb": "^18.2.0", "eslint-plugin-react": "^7.20.6", "father": "^2.29.6", + "father-build": "^1.18.6", + "gh-pages": "^3.1.0", + "glob": "^7.1.6", "jquery": "^3.3.1", "less": "^3.12.2", "np": "^6.4.0", diff --git a/script/update-content.js b/script/update-content.js new file mode 100644 index 00000000..c898f9e3 --- /dev/null +++ b/script/update-content.js @@ -0,0 +1,29 @@ +/* + 用于 dumi 改造使用, + 可用于将 examples 的文件批量修改为 demo 引入形式, + 其他项目根据具体情况使用。 +*/ + +const fs = require('fs'); +const glob = require('glob'); + +const paths = glob.sync('./docs/examples/*.tsx'); + +paths.forEach(path => { + const name = path.split('/').pop().split('.')[0]; + fs.writeFile( + `./docs/demo/${name}.md`, + `## ${name} + + +`, + 'utf8', + function(error) { + if(error){ + console.log(error); + return false; + } + console.log(`${name} 更新成功~`); + } + ) +}); diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 00000000..f6d96058 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,16 @@ +{ + "compilerOptions": { + "target": "esnext", + "moduleResolution": "node", + "baseUrl": "./", + "jsx": "preserve", + "declaration": true, + "skipLibCheck": true, + "esModuleInterop": true, + "paths": { + "@/*": ["src/*"], + "@@/*": ["src/.umi/*"], + "rc-dialog": ["src/index.ts"] + } + } +} diff --git a/typings.d.ts b/typings.d.ts new file mode 100644 index 00000000..71e0e9f4 --- /dev/null +++ b/typings.d.ts @@ -0,0 +1,2 @@ +declare module '*.css'; +declare module '*.less'; From c9fe1ef005cc5d1e39c986a742301fa4d99fbf00 Mon Sep 17 00:00:00 2001 From: xrkffgg Date: Thu, 3 Dec 2020 18:05:17 +0800 Subject: [PATCH 2/3] add --- README.md | 1 + 1 file changed, 1 insertion(+) create mode 120000 README.md diff --git a/README.md b/README.md new file mode 120000 index 00000000..e8923303 --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +docs/index.md \ No newline at end of file From 63b11f24063ee20c52dbecf5adb8db2f3760ed80 Mon Sep 17 00:00:00 2001 From: xrkffgg Date: Thu, 3 Dec 2020 20:07:18 +0800 Subject: [PATCH 3/3] Update .eslintrc.js --- .eslintrc.js | 1 - 1 file changed, 1 deletion(-) diff --git a/.eslintrc.js b/.eslintrc.js index c49235ed..54d1afd5 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -12,7 +12,6 @@ module.exports = { "@typescript-eslint/no-inferrable-types": 0, "react/require-default-props": 0, "no-confusing-arrow": 0, - 'import/no-extraneous-dependencies': 0, "import/no-named-as-default-member": 0, "jsx-a11y/label-has-for": 0, "jsx-a11y/label-has-associated-control": 0,