2024-05-09 11:56:53 +08:00
|
|
|
import React from 'react';
|
2024-04-29 09:57:45 +08:00
|
|
|
import { Button, Drawer } from 'antd';
|
|
|
|
|
|
|
|
const App: React.FC = () => {
|
2024-05-15 15:15:02 +08:00
|
|
|
const [open, setOpen] = React.useState<boolean>(false);
|
|
|
|
const [loading, setLoading] = React.useState<boolean>(true);
|
2024-04-29 09:57:45 +08:00
|
|
|
|
2024-05-15 15:15:02 +08:00
|
|
|
const showLoading = () => {
|
2024-05-09 11:56:53 +08:00
|
|
|
setOpen(true);
|
2024-04-29 09:57:45 +08:00
|
|
|
setLoading(true);
|
2024-05-15 15:15:02 +08:00
|
|
|
|
|
|
|
// Simple loading mock. You should add cleanup logic in real world.
|
|
|
|
setTimeout(() => {
|
2024-05-09 11:56:53 +08:00
|
|
|
setLoading(false);
|
|
|
|
}, 2000);
|
|
|
|
};
|
2024-04-29 09:57:45 +08:00
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
2024-05-15 15:15:02 +08:00
|
|
|
<Button type="primary" onClick={showLoading}>
|
|
|
|
Open Drawer
|
2024-04-29 09:57:45 +08:00
|
|
|
</Button>
|
|
|
|
<Drawer
|
2024-05-15 15:15:02 +08:00
|
|
|
closable
|
2024-05-09 11:56:53 +08:00
|
|
|
destroyOnClose
|
2024-05-15 15:15:02 +08:00
|
|
|
title={<p>Loading Drawer</p>}
|
2024-04-29 09:57:45 +08:00
|
|
|
placement="right"
|
|
|
|
open={open}
|
|
|
|
loading={loading}
|
2024-05-09 11:56:53 +08:00
|
|
|
onClose={() => setOpen(false)}
|
2024-04-29 09:57:45 +08:00
|
|
|
>
|
2024-05-15 15:15:02 +08:00
|
|
|
<Button type="primary" style={{ marginBottom: 16 }} onClick={showLoading}>
|
|
|
|
Reload
|
2024-05-09 11:56:53 +08:00
|
|
|
</Button>
|
2024-04-29 09:57:45 +08:00
|
|
|
<p>Some contents...</p>
|
|
|
|
<p>Some contents...</p>
|
|
|
|
<p>Some contents...</p>
|
|
|
|
</Drawer>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default App;
|