Skip to content

Commit

Permalink
调整默认组件库
Browse files Browse the repository at this point in the history
  • Loading branch information
asurance committed Jul 7, 2024
1 parent 6ca85e5 commit 7499ae5
Show file tree
Hide file tree
Showing 10 changed files with 87 additions and 98 deletions.
4 changes: 1 addition & 3 deletions demos/close-by-ref.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@ import React, {
forwardRef,
useImperativeHandle,
} from 'react';
import { Button, Modal, Space } from '@arco-design/web-react';
import { Button, Modal, Space } from '@douyinfe/semi-ui';
import { OpenableProps, openify } from 'openify';

import '@arco-design/web-react/dist/css/arco.css';

type MyModalProps = OpenableProps<void> & {
title: string;
};
Expand Down
4 changes: 1 addition & 3 deletions demos/context.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import React, { createContext, useContext } from 'react';
import { Button, Modal, Space } from '@arco-design/web-react';
import { Button, Modal, Space } from '@douyinfe/semi-ui';
import { OpenableProps, openify } from 'openify';

import '@arco-design/web-react/dist/css/arco.css';

const myContext = createContext('默认内容');

type MyModalProps = OpenableProps<void> & {
Expand Down
29 changes: 17 additions & 12 deletions demos/mydrawer.tsx
Original file line number Diff line number Diff line change
@@ -1,29 +1,34 @@
import React from 'react';
import { Drawer } from '@arco-design/web-react';
import { Modal } from '@douyinfe/semi-ui';
import { OpenableProps, openify } from 'openify';

import '@arco-design/web-react/dist/css/arco.css';

type MyDrawerProps = OpenableProps<void> & {
type MyAsyncModalProps = OpenableProps<void> & {
title: string;
};

const MyDrawer = ({ visible, onClose, afterClose, title }: MyDrawerProps) => {
const MyAsyncModal = ({
visible,
onClose,
afterClose,
title,
}: MyAsyncModalProps) => {
return (
<Drawer
<Modal
title={title}
visible={visible}
onOk={onClose}
onCancel={onClose}
afterClose={afterClose}
>
抽屉内容
</Drawer>
静态打开
</Modal>
);
};

export const openMyDrawer = openify<void, MyDrawerProps, MyDrawerProps>(
MyDrawer,
);
export const openMyAsyncModal = openify<
void,
MyAsyncModalProps,
MyAsyncModalProps
>(MyAsyncModal);

export default MyDrawer;
export default MyAsyncModal;
4 changes: 1 addition & 3 deletions demos/promisify.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import React, { useRef, useState } from 'react';
import { Button, Input, Modal, Space } from '@arco-design/web-react';
import { Button, Input, Modal, Space } from '@douyinfe/semi-ui';
import { OpenableProps, openify } from 'openify';

import '@arco-design/web-react/dist/css/arco.css';

type Value =
| {
isOk: true;
Expand Down
8 changes: 3 additions & 5 deletions demos/static-call.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import React from 'react';
import { Button, Modal, Space } from '@arco-design/web-react';
import { Button, Modal, Space } from '@douyinfe/semi-ui';
import { OpenableProps, openify } from 'openify';

import '@arco-design/web-react/dist/css/arco.css';

type MyModalProps = OpenableProps<void> & {
title: string;
};
Expand All @@ -29,8 +27,8 @@ export default () => (
<Button onClick={() => openMyModal({ title: '标题' })}>打开弹窗</Button>
<Button
onClick={async () => {
const { openMyDrawer } = await import('./mydrawer');
openMyDrawer({ title: '标题' });
const { openMyAsyncModal } = await import('demos/mydrawer');
openMyAsyncModal({ title: '标题' });
}}
>
动态加载
Expand Down
4 changes: 1 addition & 3 deletions docs/guide/Q&A/close-by-ref.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@ import React, {
forwardRef,
useImperativeHandle,
} from 'react';
import { Button, Modal, Space } from '@arco-design/web-react';
import { Button, Modal, Space } from '@douyinfe/semi-ui';
import { OpenableProps, openify } from 'openify';

import '@arco-design/web-react/dist/css/arco.css';

type MyModalProps = OpenableProps<void> & {
title: string;
};
Expand Down
4 changes: 1 addition & 3 deletions docs/guide/Q&A/context.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@

```tsx
import React, { createContext, useContext } from 'react';
import { Button, Modal, Space } from '@arco-design/web-react';
import { Button, Modal, Space } from '@douyinfe/semi-ui';
import { OpenableProps, openify } from 'openify';

import '@arco-design/web-react/dist/css/arco.css';

const myContext = createContext('默认内容');

type MyModalProps = OpenableProps<void> & {
Expand Down
116 changes: 58 additions & 58 deletions docs/guide/feature/no-dependency.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,64 +2,6 @@

组件库无关则可以轻易的将该工具库应用到你的项目中。

## Arco Design

```tsx
import React from 'react';
import {
Button,
Drawer,
DrawerProps,
Modal,
ModalProps,
Space,
} from '@arco-design/web-react';
import { OpenableProps, openify } from 'openify';

import '@arco-design/web-react/dist/css/arco.css';

type OpenModalProps = OpenableProps<void> &
Omit<ModalProps, 'visible' | 'onOk' | 'onCancel' | 'afterClose'>;

const openModal = openify<void, OpenModalProps, ModalProps>(Modal, {
transformProps({ visible, onClose, afterClose, ...restProps }) {
return {
...restProps,
visible,
onOk: onClose,
onCancel: onClose,
afterClose,
};
},
});

type OpenDrawerProps = OpenableProps<void> &
Omit<DrawerProps, 'visible' | 'onOk' | 'onCancel' | 'afterClose'>;

const openDrawer = openify<void, OpenDrawerProps, DrawerProps>(Drawer, {
transformProps({ visible, onClose, afterClose, ...restProps }) {
return {
...restProps,
visible,
onOk: onClose,
onCancel: onClose,
afterClose,
};
},
});

export default () => (
<Space>
<Button onClick={() => openModal({ title: '自定义弹窗' })}>
自定义弹窗
</Button>
<Button onClick={() => openDrawer({ title: '自定义抽屉' })}>
自定义抽屉
</Button>
</Space>
);
```

## Semi Design

```tsx
Expand Down Expand Up @@ -120,6 +62,64 @@ export default () => (
);
```

## Arco Design

```tsx
import React from 'react';
import {
Button,
Drawer,
DrawerProps,
Modal,
ModalProps,
Space,
} from '@arco-design/web-react';
import { OpenableProps, openify } from 'openify';

import '@arco-design/web-react/dist/css/arco.css';

type OpenModalProps = OpenableProps<void> &
Omit<ModalProps, 'visible' | 'onOk' | 'onCancel' | 'afterClose'>;

const openModal = openify<void, OpenModalProps, ModalProps>(Modal, {
transformProps({ visible, onClose, afterClose, ...restProps }) {
return {
...restProps,
visible,
onOk: onClose,
onCancel: onClose,
afterClose,
};
},
});

type OpenDrawerProps = OpenableProps<void> &
Omit<DrawerProps, 'visible' | 'onOk' | 'onCancel' | 'afterClose'>;

const openDrawer = openify<void, OpenDrawerProps, DrawerProps>(Drawer, {
transformProps({ visible, onClose, afterClose, ...restProps }) {
return {
...restProps,
visible,
onOk: onClose,
onCancel: onClose,
afterClose,
};
},
});

export default () => (
<Space>
<Button onClick={() => openModal({ title: '自定义弹窗' })}>
自定义弹窗
</Button>
<Button onClick={() => openDrawer({ title: '自定义抽屉' })}>
自定义抽屉
</Button>
</Space>
);
```

## Ant Design

```tsx
Expand Down
4 changes: 1 addition & 3 deletions docs/guide/feature/promisify.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@ Promise 化意味着配合 async/await 使用,可以大大简化代码组织

```tsx
import React, { useRef, useState } from 'react';
import { Button, Input, Modal, Space } from '@arco-design/web-react';
import { Button, Input, Modal, Space } from '@douyinfe/semi-ui';
import { OpenableProps, openify } from 'openify';

import '@arco-design/web-react/dist/css/arco.css';

type Value =
| {
isOk: true;
Expand Down
8 changes: 3 additions & 5 deletions docs/guide/feature/static-call.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@

```tsx
import React from 'react';
import { Button, Modal, Space } from '@arco-design/web-react';
import { Button, Modal, Space } from '@douyinfe/semi-ui';
import { OpenableProps, openify } from 'openify';

import '@arco-design/web-react/dist/css/arco.css';

type MyModalProps = OpenableProps<void> & {
title: string;
};
Expand All @@ -34,8 +32,8 @@ export default () => (
<Button onClick={() => openMyModal({ title: '标题' })}>打开弹窗</Button>
<Button
onClick={async () => {
const { openMyDrawer } = await import('demos/mydrawer');
openMyDrawer({ title: '标题' });
const { openMyAsyncModal } = await import('demos/mydrawer');
openMyAsyncModal({ title: '标题' });
}}
>
动态加载
Expand Down

0 comments on commit 7499ae5

Please sign in to comment.