mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-24 15:46:10 +08:00
51 lines
1.2 KiB
TypeScript
51 lines
1.2 KiB
TypeScript
|
import React, { useState } from 'react';
|
||
|
import type { DrawerProps, RadioChangeEvent } from 'antd';
|
||
|
import { Button, Drawer, Radio, Space } from 'antd';
|
||
|
|
||
|
const App: React.FC = () => {
|
||
|
const [open, setOpen] = useState(false);
|
||
|
const [placement, setPlacement] = useState<DrawerProps['placement']>('left');
|
||
|
|
||
|
const showDrawer = () => {
|
||
|
setOpen(true);
|
||
|
};
|
||
|
|
||
|
const onClose = () => {
|
||
|
setOpen(false);
|
||
|
};
|
||
|
|
||
|
const onChange = (e: RadioChangeEvent) => {
|
||
|
setPlacement(e.target.value);
|
||
|
};
|
||
|
|
||
|
return (
|
||
|
<>
|
||
|
<Space>
|
||
|
<Radio.Group value={placement} onChange={onChange}>
|
||
|
<Radio value="top">top</Radio>
|
||
|
<Radio value="right">right</Radio>
|
||
|
<Radio value="bottom">bottom</Radio>
|
||
|
<Radio value="left">left</Radio>
|
||
|
</Radio.Group>
|
||
|
<Button type="primary" onClick={showDrawer}>
|
||
|
Open
|
||
|
</Button>
|
||
|
</Space>
|
||
|
<Drawer
|
||
|
title="Basic Drawer"
|
||
|
placement={placement}
|
||
|
closable={false}
|
||
|
onClose={onClose}
|
||
|
open={open}
|
||
|
key={placement}
|
||
|
>
|
||
|
<p>Some contents...</p>
|
||
|
<p>Some contents...</p>
|
||
|
<p>Some contents...</p>
|
||
|
</Drawer>
|
||
|
</>
|
||
|
);
|
||
|
};
|
||
|
|
||
|
export default App;
|