fix: drawer wrapStyle position is incorrect and add drawerStyle #1699

pull/1731/head
tangjinzhou 2020-01-15 14:32:24 +08:00
parent 0dbea62fdf
commit 42787664ab
4 changed files with 56 additions and 46 deletions

View File

@ -1,26 +1,27 @@
## API
| Property | Description | Type | Default |
| --- | --- | --- | --- |
| closable | Whether a close (x) button is visible on top right of the Drawer dialog or not. | boolean | true |
| destroyOnClose | Whether to unmount child components on closing drawer or not. | boolean | false |
| getContainer | Return the mounted node for Drawer. | HTMLElement \| `() => HTMLElement` \| Selectors | 'body' |
| mask | Whether to show mask or not. | Boolean | true |
| maskClosable | Clicking on the mask (area outside the Drawer) to close the Drawer or not. | boolean | true |
| maskStyle | Style for Drawer's mask element. | object | {} |
| title | The title for Drawer. | string\|slot | - |
| visible | Whether the Drawer dialog is visible or not. | boolean | false |
| wrapClassName | The class name of the container of the Drawer dialog. | string | - |
| wrapStyle | The style of the container of the Drawer dialog. | object | - |
| bodyStyle | Style of floating layer, typically used for adjusting its position. | object | - |
| width | Width of the Drawer dialog. | string\|number | 256 |
| height | placement is `top` or `bottom`, height of the Drawer dialog. | string\|number | - |
| zIndex | The `z-index` of the Drawer. | Number | 1000 |
| placement | The placement of the Drawer. | 'top' \| 'right' \| 'bottom' \| 'left' | 'right' |
| handle | After setting, the drawer is directly mounted on the DOM, and you can control the drawer to open or close through this `handle`. | VNode \| slot | - |
| Property | Description | Type | Default | Version |
| --- | --- | --- | --- | --- |
| closable | Whether a close (x) button is visible on top right of the Drawer dialog or not. | boolean | true | |
| destroyOnClose | Whether to unmount child components on closing drawer or not. | boolean | false | |
| getContainer | Return the mounted node for Drawer. | HTMLElement \| `() => HTMLElement` \| Selectors | 'body' | |
| mask | Whether to show mask or not. | Boolean | true | |
| maskClosable | Clicking on the mask (area outside the Drawer) to close the Drawer or not. | boolean | true | |
| maskStyle | Style for Drawer's mask element. | object | {} | |
| title | The title for Drawer. | string\|slot | - | |
| visible | Whether the Drawer dialog is visible or not. | boolean | false | |
| wrapClassName | The class name of the container of the Drawer dialog. | string | - | |
| wrapStyle | Style of wrapper element which **contains mask** compare to `drawerStyle` | object | - | |
| drawerStyle | Style of the popup layer element | object | - | 1.4.11 |
| bodyStyle | Style of the drawer content part | object | - | |
| width | Width of the Drawer dialog. | string\|number | 256 | |
| height | placement is `top` or `bottom`, height of the Drawer dialog. | string\|number | - | |
| zIndex | The `z-index` of the Drawer. | Number | 1000 | |
| placement | The placement of the Drawer. | 'top' \| 'right' \| 'bottom' \| 'left' | 'right' | |
| handle | After setting, the drawer is directly mounted on the DOM, and you can control the drawer to open or close through this `handle`. | VNode \| slot | - | |
## Methods
| Name | Description | Type | Default |
| --- | --- | --- | --- |
| close | Specify a callback that will be called when a user clicks mask, close button or Cancel button. | function(e) | - |
| Name | Description | Type | Default | Version |
| --- | --- | --- | --- | --- |
| close | Specify a callback that will be called when a user clicks mask, close button or Cancel button. | function(e) | - | |

View File

@ -18,6 +18,7 @@ const Drawer = {
maskStyle: PropTypes.object,
wrapStyle: PropTypes.object,
bodyStyle: PropTypes.object,
drawerStyle: PropTypes.object,
title: PropTypes.any,
visible: PropTypes.bool,
width: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).def(256),
@ -107,11 +108,12 @@ const Drawer = {
}
},
getRcDrawerStyle() {
const { zIndex, placement } = this.$props;
const { zIndex, placement, wrapStyle } = this.$props;
const { _push: push } = this.$data;
return {
zIndex,
transform: push ? this.getPushTransform(placement) : undefined,
...wrapStyle,
};
},
renderHeader(prefixCls) {
@ -142,7 +144,7 @@ const Drawer = {
return null;
}
this.destroyClose = false;
const { placement, bodyStyle, wrapStyle } = this.$props;
const { placement, bodyStyle, drawerStyle } = this.$props;
const containerStyle =
placement === 'left' || placement === 'right'
@ -162,7 +164,7 @@ const Drawer = {
return (
<div
class={`${prefixCls}-wrapper-body`}
style={{ ...containerStyle, ...wrapStyle }}
style={{ ...containerStyle, ...drawerStyle }}
onTransitionend={this.onDestroyTransitionEnd}
>
{this.renderHeader(prefixCls)}

View File

@ -1,26 +1,27 @@
## API
| 参数 | 说明 | 类型 | 默认值 |
| --- | --- | --- | --- |
| closable | 是否显示右上角的关闭按钮 | boolean | true |
| destroyOnClose | 关闭时销毁 Drawer 里的子元素 | boolean | false |
| getContainer | 指定 Drawer 挂载的 HTML 节点 | HTMLElement \| `() => HTMLElement` \| Selectors | 'body' |
| maskClosable | 点击蒙层是否允许关闭 | boolean | true |
| mask | 是否展示遮罩 | Boolean | true |
| maskStyle | 遮罩样式 | object | {} |
| title | 标题 | string \| slot | - |
| visible | Drawer 是否可见 | boolean | - |
| wrapClassName | 对话框外层容器的类名 | string | - |
| wrapStyle | 对话框外层容器的`style` | object | - |
| bodyStyle | 可用于设置 Drawer 的样式,调整浮层位置等 | object | - |
| width | 宽度 | string \| number | 256 |
| height | 高度, 在 `placement``top``bottom` 时使用 | string \| number | 256 |
| zIndex | 设置 Drawer 的 `z-index` | Number | 1000 |
| placement | 抽屉的方向 | 'top' \| 'right' \| 'bottom' \| 'left' | 'right' |
| handle | 设置后抽屉直接挂载到 DOM 上,你可以通过该 handle 控制抽屉打开关闭 | VNode \| slot | - |
| 参数 | 说明 | 类型 | 默认值 | 版本 |
| --- | --- | --- | --- | --- |
| closable | 是否显示右上角的关闭按钮 | boolean | true | |
| destroyOnClose | 关闭时销毁 Drawer 里的子元素 | boolean | false | |
| getContainer | 指定 Drawer 挂载的 HTML 节点 | HTMLElement \| `() => HTMLElement` \| Selectors | 'body' | |
| maskClosable | 点击蒙层是否允许关闭 | boolean | true | |
| mask | 是否展示遮罩 | Boolean | true | |
| maskStyle | 遮罩样式 | object | {} | |
| title | 标题 | string \| slot | - | |
| visible | Drawer 是否可见 | boolean | - | |
| wrapClassName | 对话框外层容器的类名 | string | - | |
| wrapStyle | 可用于设置 Drawer 最外层容器的样式,和 `drawerStyle` 的区别是作用节点包括 `mask` | object | - | |
| drawerStyle | 用于设置 Drawer 弹出层的样式 | object | - | 1.4.11 |
| bodyStyle | 可用于设置 Drawer 内容部分的样式 | object | - | |
| width | 宽度 | string \| number | 256 | |
| height | 高度, 在 `placement``top``bottom` 时使用 | string \| number | 256 | |
| zIndex | 设置 Drawer 的 `z-index` | Number | 1000 | |
| placement | 抽屉的方向 | 'top' \| 'right' \| 'bottom' \| 'left' | 'right' | |
| handle | 设置后抽屉直接挂载到 DOM 上,你可以通过该 handle 控制抽屉打开关闭 | VNode \| slot | - | |
## 方法
| 名称 | 描述 | 类型 | 默认值 |
| ----- | ------------------------------------ | ----------- | ------ |
| close | 点击遮罩层或右上角叉或取消按钮的回调 | function(e) | 无 |
| 名称 | 描述 | 类型 | 默认值 | 版本 |
| ----- | ------------------------------------ | ----------- | ------ | ---- |
| close | 点击遮罩层或右上角叉或取消按钮的回调 | function(e) | 无 | |

8
types/drawer.d.ts vendored
View File

@ -67,11 +67,17 @@ export declare class Drawer extends AntdComponent {
wrapClassName: string;
/**
* The style of the container of the Drawer dialog.
* Style of wrapper element which **contains mask** compare to `drawerStyle`
* @type object
*/
wrapStyle: object;
/**
* Style of the popup layer element
* @type object
*/
drawerStyle: object;
/**
* Style of floating layer, typically used for adjusting its position.
* @type object