diff --git a/components/drawer/__tests__/Drawer.test.js b/components/drawer/__tests__/Drawer.test.js index f366715c9c..cb65152e4b 100644 --- a/components/drawer/__tests__/Drawer.test.js +++ b/components/drawer/__tests__/Drawer.test.js @@ -16,6 +16,20 @@ describe('Drawer', () => { expect(wrapper).toMatchSnapshot(); }); + it('render top drawer', () => { + const wrapper = render( + + Here is content of Drawer + + ); + expect(wrapper).toMatchSnapshot(); + }); + it('have a title', () => { const wrapper = render( { expect(wrapper.find('#two_drawer_text').exists()).toBe(true); }); - it('render right MultiDrawer', () => { + it('render left MultiDrawer', () => { const wrapper = mount(); wrapper.find('button#open_drawer').simulate('click'); wrapper.find('button#open_two_drawer').simulate('click'); diff --git a/components/drawer/__tests__/__snapshots__/Drawer.test.js.snap b/components/drawer/__tests__/__snapshots__/Drawer.test.js.snap index c581ee9a4b..70c72479fd 100644 --- a/components/drawer/__tests__/__snapshots__/Drawer.test.js.snap +++ b/components/drawer/__tests__/__snapshots__/Drawer.test.js.snap @@ -205,3 +205,43 @@ exports[`Drawer render correctly 1`] = ` `; + +exports[`Drawer render top drawer 1`] = ` + + + + + + + + + + + Here is content of Drawer + + + + + + +`; diff --git a/components/drawer/__tests__/__snapshots__/DrawerEvent.test.js.snap b/components/drawer/__tests__/__snapshots__/DrawerEvent.test.js.snap index fdf8f3e5d7..875ab4c752 100644 --- a/components/drawer/__tests__/__snapshots__/DrawerEvent.test.js.snap +++ b/components/drawer/__tests__/__snapshots__/DrawerEvent.test.js.snap @@ -3,7 +3,7 @@ exports[`Drawer render correctly 1`] = ` diff --git a/components/drawer/demo/basic-left.md b/components/drawer/demo/basic-left.md deleted file mode 100644 index 1caf745dea..0000000000 --- a/components/drawer/demo/basic-left.md +++ /dev/null @@ -1,57 +0,0 @@ ---- -order: 1 -title: - zh-CN: 左侧滑出 - en-US: Left Slider ---- - -## zh-CN - -基础抽屉,点击触发按钮抽屉从左滑出,点击遮罩区关闭 - -## en-US - -Basic drawer. - -```jsx -import { Drawer, Button } from 'antd'; - -class App extends React.Component { - state = { visible: false }; - - showDrawer = () => { - this.setState({ - visible: true, - }); - }; - - onClose = () => { - this.setState({ - visible: false, - }); - }; - - render() { - return ( - - - Open - - - Some contents... - Some contents... - Some contents... - - - ); - } -} - -ReactDOM.render(, mountNode); -``` diff --git a/components/drawer/demo/placement.md b/components/drawer/demo/placement.md new file mode 100644 index 0000000000..a1a5907a0b --- /dev/null +++ b/components/drawer/demo/placement.md @@ -0,0 +1,75 @@ +--- +order: 1 +title: + zh-CN: 自定义位置 + en-US: Custom Placement +--- + +## zh-CN + +自定义位置,点击触发按钮抽屉从相应的位置滑出,点击遮罩区关闭 + +## en-US + +Basic drawer. + +```jsx +import { Drawer, Button, Radio } from 'antd'; + +const RadioGroup = Radio.Group; + +class App extends React.Component { + state = { visible: false, placement: 'left' }; + + showDrawer = () => { + this.setState({ + visible: true, + }); + }; + + onClose = () => { + this.setState({ + visible: false, + }); + }; + + onChange = (e) => { + this.setState({ + placement: e.target.value, + }); + } + + render() { + return ( + + + top + right + bottom + left + + + Open + + + Some contents... + Some contents... + Some contents... + + + ); + } +} + +ReactDOM.render(, mountNode); +``` diff --git a/components/drawer/index.en-US.md b/components/drawer/index.en-US.md index 2b7bfc60b5..eb9b33bac4 100644 --- a/components/drawer/index.en-US.md +++ b/components/drawer/index.en-US.md @@ -27,9 +27,10 @@ A Drawer is a panel that is typically overlaid on top of a page and slides in fr | title | The title for Drawer. | string\|ReactNode | - | | visible | Whether the Drawer dialog is visible or not. | boolean | false | | width | Width of the Drawer dialog. | string\|number | 256 | +| height | placement is `top` or `bottom`, height of the Drawer dialog. | string\|number | - | | className | The class name of the container of the Drawer dialog. | string | - | | zIndex | The `z-index` of the Drawer. | Number | 1000 | -| placement | The placement of the Drawer. | 'left' \| 'right' | 'right' +| placement | The placement of the Drawer. | 'top' \| 'right' \| 'bottom' \| 'left' | 'right' | | onClose | Specify a callback that will be called when a user clicks mask, close button or Cancel button. | function(e) | - |
Some contents...