From 2cd863929a599b8b07710eebd9bd5d4b7bb2e92e Mon Sep 17 00:00:00 2001 From: jljsj33 Date: Fri, 20 Jul 2018 16:02:42 +0800 Subject: [PATCH] update drawer test --- .../__tests__/__snapshots__/Drawer.test.js.snap | 16 ++++++++++++---- .../__snapshots__/DrawerEvent.test.js.snap | 4 +++- components/drawer/index.tsx | 12 +++++++----- components/drawer/style/drawer.less | 4 ++-- package.json | 2 +- 5 files changed, 25 insertions(+), 13 deletions(-) diff --git a/components/drawer/__tests__/__snapshots__/Drawer.test.js.snap b/components/drawer/__tests__/__snapshots__/Drawer.test.js.snap index 13845a3fc4..6819b1bbc7 100644 --- a/components/drawer/__tests__/__snapshots__/Drawer.test.js.snap +++ b/components/drawer/__tests__/__snapshots__/Drawer.test.js.snap @@ -1,7 +1,9 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`Drawer closable is false 1`] = ` -
+
@@ -31,7 +33,9 @@ exports[`Drawer closable is false 1`] = ` `; exports[`Drawer destroyOnClose is true 1`] = ` -
+
@@ -69,7 +73,9 @@ exports[`Drawer destroyOnClose is true 1`] = ` `; exports[`Drawer have a title 1`] = ` -
+
@@ -116,7 +122,9 @@ exports[`Drawer have a title 1`] = ` `; exports[`Drawer render correctly 1`] = ` -
+
diff --git a/components/drawer/__tests__/__snapshots__/DrawerEvent.test.js.snap b/components/drawer/__tests__/__snapshots__/DrawerEvent.test.js.snap index fdca544f5e..c9bfc7cf8f 100644 --- a/components/drawer/__tests__/__snapshots__/DrawerEvent.test.js.snap +++ b/components/drawer/__tests__/__snapshots__/DrawerEvent.test.js.snap @@ -10,7 +10,9 @@ exports[`Drawer render correctly 1`] = ` open -
+
diff --git a/components/drawer/index.tsx b/components/drawer/index.tsx index aa39748bf8..fea4ed020a 100644 --- a/components/drawer/index.tsx +++ b/components/drawer/index.tsx @@ -107,8 +107,7 @@ export default class Drawer extends React.Component { }); } onDestoryTransitionEnd = () => { - const { destroyOnClose, visible } = this.props; - const isDestroyOnClose = destroyOnClose && !visible; + const isDestroyOnClose = this.getDestoryOnClose(); if (!isDestroyOnClose) { return; } @@ -117,20 +116,23 @@ export default class Drawer extends React.Component { this.forceUpdate(); } } + + getDestoryOnClose = () => (this.props.destroyOnClose && !this.props.visible); + renderBody = () => { if (this.destoryClose && !this.props.visible) { return null; } this.destoryClose = false; - const { destroyOnClose, visible, placement } = this.props; + const { placement } = this.props; const containerStyle: React.CSSProperties = placement === 'left' || placement === 'right' ? { overflow: 'auto', height: '100%', } : {}; - const isDestroyOnClose = destroyOnClose && !visible; + const isDestroyOnClose = this.getDestoryOnClose(); if (isDestroyOnClose) { - // 增加透明渐变,跟关闭的动画时间相同,在关闭后删除子元素; + // Increase the opacity transition, delete children after closing. containerStyle.opacity = 0; containerStyle.transition = 'opacity .3s'; } diff --git a/components/drawer/style/drawer.less b/components/drawer/style/drawer.less index 46e7a3b045..aac8ada9fc 100644 --- a/components/drawer/style/drawer.less +++ b/components/drawer/style/drawer.less @@ -28,7 +28,7 @@ &-left { &.@{dawer-prefix-cls}-open { .@{dawer-prefix-cls}-content-wrapper { - box-shadow: 2px 0 8px rgba(0, 0, 0, 0.15); + box-shadow: @shadow-1-right; } } } @@ -40,7 +40,7 @@ } &.@{dawer-prefix-cls}-open { .@{dawer-prefix-cls}-content-wrapper { - box-shadow: -2px 0 8px rgba(0, 0, 0, 0.15); + box-shadow: @shadow-1-left; } } } diff --git a/package.json b/package.json index e9d572f8af..0700945c00 100644 --- a/package.json +++ b/package.json @@ -59,7 +59,7 @@ "rc-checkbox": "~2.1.5", "rc-collapse": "~1.9.0", "rc-dialog": "~7.1.0", - "rc-drawer": "~1.6.1", + "rc-drawer": "~1.6.2", "rc-dropdown": "~2.2.0", "rc-editor-mention": "^1.0.2", "rc-form": "^2.1.0",