From 2ca3661e87533794aecafd8da8a00d6204565d0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=B8=85?= Date: Fri, 10 Aug 2018 13:32:33 +0800 Subject: [PATCH] placement add top and bottom --- components/drawer/__tests__/Drawer.test.js | 14 ++++ .../drawer/__tests__/MultiDrawer.test.js | 2 +- .../__snapshots__/Drawer.test.js.snap | 40 ++++++++++ .../__snapshots__/DrawerEvent.test.js.snap | 2 +- components/drawer/demo/basic-left.md | 57 -------------- components/drawer/demo/placement.md | 75 +++++++++++++++++++ components/drawer/index.en-US.md | 3 +- components/drawer/index.tsx | 15 +++- components/drawer/index.zh-CN.md | 3 +- 9 files changed, 147 insertions(+), 64 deletions(-) delete mode 100644 components/drawer/demo/basic-left.md create mode 100644 components/drawer/demo/placement.md 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`] = `
- -

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 + + + +

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) | - |