mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-29 03:48:26 +08:00
e7aa014c31
* docs: init * chore: all types * docs: faq * chore: fix lint
58 lines
1.4 KiB
TypeScript
58 lines
1.4 KiB
TypeScript
import React, { useState } from 'react';
|
|
import { Button, Drawer, Radio, Space } from 'antd';
|
|
import type { DrawerProps, RadioChangeEvent } from 'antd';
|
|
|
|
const App: React.FC = () => {
|
|
const [open, setOpen] = useState(false);
|
|
const [placement, setPlacement] = useState<DrawerProps['placement']>('right');
|
|
|
|
const showDrawer = () => {
|
|
setOpen(true);
|
|
};
|
|
|
|
const onChange = (e: RadioChangeEvent) => {
|
|
setPlacement(e.target.value);
|
|
};
|
|
|
|
const onClose = () => {
|
|
setOpen(false);
|
|
};
|
|
|
|
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="Drawer with extra actions"
|
|
placement={placement}
|
|
width={500}
|
|
onClose={onClose}
|
|
open={open}
|
|
extra={
|
|
<Space>
|
|
<Button onClick={onClose}>Cancel</Button>
|
|
<Button type="primary" onClick={onClose}>
|
|
OK
|
|
</Button>
|
|
</Space>
|
|
}
|
|
>
|
|
<p>Some contents...</p>
|
|
<p>Some contents...</p>
|
|
<p>Some contents...</p>
|
|
</Drawer>
|
|
</>
|
|
);
|
|
};
|
|
|
|
export default App;
|