2023-10-19 15:03:20 +08:00
|
|
|
import React, { useState } from 'react';
|
2023-11-17 10:54:19 +08:00
|
|
|
import { Button, message, Modal, notification, Select, Space, Switch } from 'antd';
|
2023-10-19 15:03:20 +08:00
|
|
|
|
|
|
|
const options = [
|
|
|
|
{
|
|
|
|
label: 'Option 1',
|
|
|
|
value: '1',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: 'Option 2',
|
|
|
|
value: '2',
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
2023-11-17 10:54:19 +08:00
|
|
|
const Demo: React.FC = () => {
|
|
|
|
const [messageInstance, messageHolder] = message.useMessage();
|
|
|
|
const [notificationInstance, notificationHolder] = notification.useNotification();
|
|
|
|
|
2023-10-19 15:03:20 +08:00
|
|
|
const [isModalOpen, setIsModalOpen] = useState<boolean>(false);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<Switch
|
2023-11-17 10:54:19 +08:00
|
|
|
style={{ position: 'relative', zIndex: isModalOpen ? 4000 : 0 }}
|
2023-10-19 15:03:20 +08:00
|
|
|
checkedChildren="Open"
|
|
|
|
unCheckedChildren="Close"
|
|
|
|
onChange={(open) => setIsModalOpen(open)}
|
|
|
|
/>
|
|
|
|
<Modal
|
|
|
|
title="Basic Modal"
|
|
|
|
open={isModalOpen}
|
|
|
|
footer={null}
|
|
|
|
destroyOnClose
|
|
|
|
onCancel={() => setIsModalOpen(false)}
|
|
|
|
maskClosable={false}
|
|
|
|
closable={false}
|
|
|
|
styles={{
|
|
|
|
content: {
|
|
|
|
marginBlockStart: 100,
|
|
|
|
},
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<Select open value="1" options={options} />
|
|
|
|
<Modal
|
|
|
|
title="Nested Modal"
|
|
|
|
open={isModalOpen}
|
|
|
|
footer={null}
|
|
|
|
destroyOnClose
|
|
|
|
mask={false}
|
|
|
|
onCancel={() => setIsModalOpen(false)}
|
|
|
|
maskClosable={false}
|
|
|
|
closable={false}
|
|
|
|
styles={{
|
|
|
|
content: {
|
|
|
|
marginBlockStart: 250,
|
|
|
|
},
|
|
|
|
body: {
|
|
|
|
display: 'flex',
|
|
|
|
justifyContent: 'center',
|
|
|
|
},
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<Select open value="1" options={options} />
|
|
|
|
|
|
|
|
<Modal
|
|
|
|
title="Nested Modal"
|
|
|
|
open={isModalOpen}
|
|
|
|
footer={null}
|
|
|
|
destroyOnClose
|
|
|
|
mask={false}
|
|
|
|
maskClosable={false}
|
|
|
|
onCancel={() => setIsModalOpen(false)}
|
|
|
|
closable={false}
|
|
|
|
styles={{
|
|
|
|
content: {
|
|
|
|
marginBlockStart: 400,
|
|
|
|
},
|
|
|
|
body: {
|
|
|
|
display: 'flex',
|
|
|
|
justifyContent: 'flex-end',
|
|
|
|
},
|
|
|
|
}}
|
|
|
|
>
|
2023-11-17 10:54:19 +08:00
|
|
|
<Space wrap>
|
|
|
|
<Button
|
|
|
|
onClick={() => {
|
|
|
|
Modal.confirm({
|
|
|
|
title: 'Are you OK?',
|
|
|
|
content: 'I am OK',
|
|
|
|
});
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
Static Confirm
|
|
|
|
</Button>
|
|
|
|
|
|
|
|
<Button
|
|
|
|
onClick={() => {
|
|
|
|
message.success('Hello World');
|
|
|
|
notification.success({
|
|
|
|
message: 'Hello World',
|
|
|
|
});
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
Static Message, Notification
|
|
|
|
</Button>
|
|
|
|
|
|
|
|
<Button
|
|
|
|
onClick={() => {
|
|
|
|
messageInstance.success('Hello World');
|
|
|
|
notificationInstance.success({
|
|
|
|
message: 'Hello World',
|
|
|
|
});
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
Hook Message, Notification
|
|
|
|
</Button>
|
|
|
|
|
|
|
|
<Select open value="1" options={options} />
|
|
|
|
</Space>
|
2023-10-19 15:03:20 +08:00
|
|
|
</Modal>
|
|
|
|
</Modal>
|
|
|
|
</Modal>
|
2023-11-17 10:54:19 +08:00
|
|
|
|
|
|
|
{messageHolder}
|
|
|
|
{notificationHolder}
|
2023-10-19 15:03:20 +08:00
|
|
|
</>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2023-11-17 10:54:19 +08:00
|
|
|
export default Demo;
|