Skip to content

Commit

Permalink
feat: 克隆 antd 静态方法 (#15)
Browse files Browse the repository at this point in the history
* test: 添加测试用例

* feat: 完全 clone 静态方法

* chore: 改进构建工具

* chore: update file

* chore: update docs

* chore: 软连接调试

* chore: update deps

* chore: 修复测试 demo 失败
  • Loading branch information
Wxh16144 committed Jan 10, 2024
1 parent 0bc87f4 commit 2f8cdac
Show file tree
Hide file tree
Showing 10 changed files with 1,841 additions and 711 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,6 @@ screenshot
example/.temp/*
.eslintcache
techUI*

# Symbolic link
examples/with-antd4/src/App.tsx
37 changes: 37 additions & 0 deletions docs/guide/static-method.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
title: 静态方法
group:
title: Legacy
order: 5
---

## 静态方法

自 antd 发布 5.0 版本后, Modal 的静态方法已经不推荐使用,[为什么?](https://ant.design/docs/blog/why-not-static-cn), 但二次封装不应该阉割先前的功能, 所以需要将 Modal 的静态方法保留了下来, 不推荐使用。

```tsx
import { Button, Space } from 'antd';
import Modal from 'easy-antd-modal';

export default () => (
<Button
danger
onClick={() => {
Modal.success({
title: 'success',
content: (
<Space>
不推荐使用!!!
<Button type="link" href="https://ant.design/docs/blog/why-not-static-cn">
为什么?
</Button>
</Space>
),
onOk: () => console.log('success'),
});
}}
>
Static Methods (Not Recommended)
</Button>
);
```
26 changes: 0 additions & 26 deletions examples/with-antd4/src/App.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion examples/with-antd5/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"preview": "vite preview"
},
"dependencies": {
"antd": "^5",
"antd": "^5.12.8",
"easy-antd-modal": "workspace:*",
"react": "^18.2.0",
"react-dom": "^18.2.0"
Expand Down
25 changes: 24 additions & 1 deletion examples/with-antd5/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Button, Typography, version } from 'antd';
import { Button, Space, Typography, version } from 'antd';
import { DragModal, Drawer, Modal } from 'easy-antd-modal';

export default () => (
Expand All @@ -22,5 +22,28 @@ export default () => (
<DragModal title="easy-antd-modal" trigger={<Button type="primary">DragModal</Button>}>
I ❤️ antd
</DragModal>

<br />
<br />

<Button
danger
onClick={() => {
Modal.success({
title: 'success',
content: (
<Space>
不推荐使用!!!
<Button type="link" href="https://ant.design/docs/blog/why-not-static-cn">
为什么?
</Button>
</Space>
),
onOk: () => console.log('success'),
});
}}
>
Static Methods
</Button>
</>
);
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
"dev": "dumi dev",
"docs:build": "dumi build",
"doctor": "father doctor",
"postinstall": "[ -f examples/with-antd4/src/App.tsx ] || ln -s ../../with-antd5/src/App.tsx examples/with-antd4/src/App.tsx",
"lint": "eslint \"{src,test}/**/*.{js,jsx,ts,tsx}\"",
"prepare": "husky install && npm run setup",
"prepublishOnly": "npm run doctor && npm run build",
Expand Down Expand Up @@ -135,7 +136,7 @@
"react": ">=17.0.0",
"react-dom": ">=17.0.0"
},
"packageManager": "pnpm@8.0.0",
"packageManager": "pnpm@8.6.2",
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org"
Expand Down

0 comments on commit 2f8cdac

Please sign in to comment.