From 77247006503e2335fa62f4af87d39bbdc53babda Mon Sep 17 00:00:00 2001 From: neverland Date: Thu, 19 Sep 2019 17:47:16 +0800 Subject: [PATCH] feat(Popup): add close-icon-position prop (#2064) --- example/pages/popup/index.js | 11 +++++++++- example/pages/popup/index.wxml | 38 ++++++++++++++++++++-------------- packages/popup/README.md | 20 +++++++++++++----- packages/popup/index.less | 22 ++++++++++++++++++-- packages/popup/index.ts | 4 ++++ packages/popup/index.wxml | 2 +- 6 files changed, 72 insertions(+), 25 deletions(-) diff --git a/example/pages/popup/index.js b/example/pages/popup/index.js index 56e5a705..d68ea2e5 100644 --- a/example/pages/popup/index.js +++ b/example/pages/popup/index.js @@ -10,7 +10,8 @@ Page({ right: false, round: false, closeIcon: false, - customCloseIcon: false + customCloseIcon: false, + customIconPosition: false } }, @@ -82,5 +83,13 @@ Page({ hideCustomCloseIcon() { this.toggle('customCloseIcon', false); + }, + + showCustomIconPosition() { + this.toggle('customIconPosition', true); + }, + + hideCustomIconPosition() { + this.toggle('customIconPosition', false); } }); diff --git a/example/pages/popup/index.wxml b/example/pages/popup/index.wxml index fc799f9b..5f98c12b 100644 --- a/example/pages/popup/index.wxml +++ b/example/pages/popup/index.wxml @@ -1,5 +1,5 @@ - - 展示弹出层 + + - - - 顶部弹出 - 底部弹出 - - - 左侧弹出 - 右侧弹出 + + + + + - - 关闭图标 + + + + - 自定义图标 - + + - - 圆角弹窗 + + ``` ### 关闭图标 -设置`closeable`属性后,会在弹出层的右上角显示关闭图标,并且可以通过`close-icon`属性自定义图标 +设置`closeable`属性后,会在弹出层的右上角显示关闭图标,并且可以通过`close-icon`属性自定义图标,使用`close-icon-position`属性可以自定义图标位置 ```html @@ -76,7 +76,17 @@ Page({ closeable close-icon="close" position="bottom" - :style="{ height: '20%' }" + custom-style="height: 20%" + bind:close="onClose" +/> + + + ``` @@ -90,7 +100,7 @@ Page({ show="{{ show }}" round position="bottom" - :style="{ height: '20%' }" + custom-style="height: 20%" bind:close="onClose" /> ``` diff --git a/packages/popup/index.less b/packages/popup/index.less index 3d40ad3c..f49e65c0 100644 --- a/packages/popup/index.less +++ b/packages/popup/index.less @@ -89,12 +89,30 @@ &__close-icon { position: absolute; - .theme(top, '@popup-close-icon-margin'); - .theme(right, '@popup-close-icon-margin'); .theme(z-index, '@popup-close-icon-z-index'); .theme(color, '@popup-close-icon-color'); .theme(font-size, '@popup-close-icon-size'); + &--top-left { + .theme(top, '@popup-close-icon-margin'); + .theme(left, '@popup-close-icon-margin'); + } + + &--top-right { + .theme(top, '@popup-close-icon-margin'); + .theme(right, '@popup-close-icon-margin'); + } + + &--bottom-left { + .theme(bottom, '@popup-close-icon-margin'); + .theme(left, '@popup-close-icon-margin'); + } + + &--bottom-right { + .theme(right, '@popup-close-icon-margin'); + .theme(bottom, '@popup-close-icon-margin'); + } + &:active { opacity: 0.6; } diff --git a/packages/popup/index.ts b/packages/popup/index.ts index 45e248f4..2f15882b 100644 --- a/packages/popup/index.ts +++ b/packages/popup/index.ts @@ -35,6 +35,10 @@ VantComponent({ type: String, value: 'cross' }, + closeIconPosition: { + type: String, + value: 'top-right' + }, closeOnClickOverlay: { type: Boolean, value: true diff --git a/packages/popup/index.wxml b/packages/popup/index.wxml index fe9514ad..c257348a 100644 --- a/packages/popup/index.wxml +++ b/packages/popup/index.wxml @@ -18,7 +18,7 @@