Skip to content

Commit 1645b94

Browse files
committed
feat(rn): tip 支持点击rn点击tip区域外关闭
1 parent abefc23 commit 1645b94

File tree

8 files changed

+61
-19
lines changed

8 files changed

+61
-19
lines changed

packages/mpx-cube-ui/lib/components/switch/index.mpx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
<view
33
wx:class="{{ switchClass }}"
44
bindtap="toggleSwitch"
5-
animation="{{ switchAnimationData }}"
5+
animation@_ios|_android="{{ switchAnimationData }}"
66
wx:style="{{ swithBGClass }}"
77
>
88
<view
99
class="cube-switch-handle"
1010
wx:class="{{ {'cube-switch-handle-on': isOn }}}"
11-
animation="{{ switchHandleAnimationData }}"
11+
animation@_ios|_android="{{ switchHandleAnimationData }}"
1212
/>
1313
</view>
1414
</template>

packages/mpx-cube-ui/lib/components/tip/css.rn.styl

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,12 @@
77
z-index $var(tip-z-index)
88
display flex
99
max-height $var(tip-max-height)
10-
border-radius $var(tip-border-radius)
11-
background-color $var(tip-bgc)
1210
font-size $var(font-size-xs)
1311
color $var(tip-color)
1412
transform scale(0)
1513
.cube-tip-angle-wapper
1614
position absolute
15+
z-index: 2
1716
.cube-tip-angle
1817
border-top-width: 0
1918
border-right-width: 6px
@@ -55,18 +54,19 @@
5554
transform rotate(90deg)
5655
.cube-tip-line-wrapper
5756
position absolute
57+
z-index: 3
5858
right $var(tip-close-right)
5959
top $var(tip-close-top)
6060
width $var(tip-close-width)
6161
height $var(tip-close-height)
62-
transform scale(1.1)
62+
transform scale(1.6)
6363
.cube-tip-line
6464
position absolute
6565
top: 50%
6666
left: 50%
6767
width $var(tip-close-width)
6868
height $var(tip-close-height)
69-
transform: translate(-50%, -50%), rotate(45deg)
69+
transform: translate(-50%, -50%), rotate(45deg), scale(0.625)
7070
background-color: #fff
7171
.cube-tip-line-horizontal
7272
width $var(font-size-lg)
@@ -75,9 +75,20 @@
7575
width: 2px
7676
height $var(font-size-lg)
7777

78-
78+
.cube-tip-popup
79+
position: absolute
80+
z-index: 1
81+
width: 2000vw
82+
height: 2000vh
83+
left: -1000vw
84+
top: -1000vh
85+
opacity: 0
86+
pointer-events: box-only
7987
.cube-tip-content
88+
z-index: 2
8089
padding-all($var(tip-padding-top), $var(tip-padding-right), $var(tip-padding-bottom), $var(tip-padding-left))
90+
background-color $var(tip-bgc)
91+
border-radius $var(tip-border-radius)
8192
min-height $var(tip-content-min-height)
8293
line-height $var(tip-content-line-height)
8394
overflow hidden

packages/mpx-cube-ui/lib/components/tip/index.mpx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@
22
<view
33
wx:class="{{ rootClass }}"
44
wx:style="{{ customStyle }}"
5-
bind:tap="onClick"
65
animation@_ios|_android="{{ tipAnimationData }}"
76
>
8-
<view class="cube-tip-angle-wapper" wx:class="{{ angleWrapperClass }}" wx:style="{{ angStyle }}">
9-
<view class="cube-tip-angle" wx:class="{{ angleClass }}"></view>
7+
<view class="cube-tip-angle-wapper" wx:class@_ios|_android="{{ angleWrapperClass }}" wx:style="{{ angStyle }}">
8+
<view class="cube-tip-angle" wx:class@_ios|_android="{{ angleClass }}"></view>
109
</view>
1110
<view
1211
@_ios|_android
@@ -27,7 +26,14 @@
2726
type="close"
2827
catchtap="onClose"
2928
/>
30-
<view class="cube-tip-content" wx:class="{{ { 'cube-tip-content-without-close': !showClose } }}">
29+
<view
30+
@_ios|_android
31+
class="cube-tip-popup"
32+
wx:show="{{ closeOnClickOutside && isVisible }}"
33+
bind:tap="onClose"
34+
>
35+
</view>
36+
<view class="cube-tip-content" bind:tap="onClick" wx:class="{{ { 'cube-tip-content-without-close': !showClose } }}">
3137
<!-- 默认插槽 -->
3238
<slot />
3339
</view>

packages/mpx-cube-ui/lib/components/tip/tip.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ createComponent({
3838
showClose: {
3939
type: Boolean,
4040
value: true
41+
},
42+
closeOnClickOutside: {
43+
type: Boolean,
44+
value: false
4145
}
4246
},
4347
data: {

packages/mpx-cube-ui/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@mpxjs/mpx-cube-ui",
3-
"version": "1.3.12-beta.3",
3+
"version": "1.3.12-beta.7",
44
"description": "mpx components library",
55
"author": "xiaolei <[email protected]>",
66
"publishConfig": {

packages/mpx-cube-ui/src/components/tip/css.rn.styl

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,12 @@
77
z-index $var(tip-z-index)
88
display flex
99
max-height $var(tip-max-height)
10-
border-radius $var(tip-border-radius)
11-
background-color $var(tip-bgc)
1210
font-size $var(font-size-xs)
1311
color $var(tip-color)
1412
transform scale(0)
1513
.cube-tip-angle-wapper
1614
position absolute
15+
z-index: 2
1716
.cube-tip-angle
1817
border-top-width: 0
1918
border-right-width: 6px
@@ -55,18 +54,19 @@
5554
transform rotate(90deg)
5655
.cube-tip-line-wrapper
5756
position absolute
57+
z-index: 3
5858
right $var(tip-close-right)
5959
top $var(tip-close-top)
6060
width $var(tip-close-width)
6161
height $var(tip-close-height)
62-
transform scale(1.1)
62+
transform scale(1.6)
6363
.cube-tip-line
6464
position absolute
6565
top: 50%
6666
left: 50%
6767
width $var(tip-close-width)
6868
height $var(tip-close-height)
69-
transform: translate(-50%, -50%), rotate(45deg)
69+
transform: translate(-50%, -50%), rotate(45deg), scale(0.625)
7070
background-color: #fff
7171
.cube-tip-line-horizontal
7272
width $var(font-size-lg)
@@ -75,9 +75,20 @@
7575
width: 2px
7676
height $var(font-size-lg)
7777

78-
78+
.cube-tip-popup
79+
position: absolute
80+
z-index: 1
81+
width: 2000vw
82+
height: 2000vh
83+
left: -1000vw
84+
top: -1000vh
85+
opacity: 0
86+
pointer-events: box-only
7987
.cube-tip-content
88+
z-index: 2
8089
padding-all($var(tip-padding-top), $var(tip-padding-right), $var(tip-padding-bottom), $var(tip-padding-left))
90+
background-color $var(tip-bgc)
91+
border-radius $var(tip-border-radius)
8192
min-height $var(tip-content-min-height)
8293
line-height $var(tip-content-line-height)
8394
overflow hidden

packages/mpx-cube-ui/src/components/tip/index.mpx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
<view
33
wx:class="{{ rootClass }}"
44
wx:style="{{ customStyle }}"
5-
bind:tap="onClick"
65
animation@_ios|_android="{{ tipAnimationData }}"
76
>
87
<view class="cube-tip-angle-wapper" wx:class@_ios|_android="{{ angleWrapperClass }}" wx:style="{{ angStyle }}">
@@ -27,7 +26,14 @@
2726
type="close"
2827
catchtap="onClose"
2928
/>
30-
<view class="cube-tip-content" wx:class@_ios|_android="{{ { 'cube-tip-content-without-close': !showClose } }}">
29+
<view
30+
@_ios|_android
31+
class="cube-tip-popup"
32+
wx:show="{{ closeOnClickOutside && isVisible }}"
33+
bind:tap="onClose"
34+
>
35+
</view>
36+
<view class="cube-tip-content" bind:tap="onClick" wx:class="{{ { 'cube-tip-content-without-close': !showClose } }}">
3137
<!-- 默认插槽 -->
3238
<slot />
3339
</view>

packages/mpx-cube-ui/src/components/tip/tip.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ createComponent({
4040
showClose: {
4141
type: Boolean,
4242
value: true
43+
},
44+
closeOnClickOutside: {
45+
type: Boolean,
46+
value: false
4347
}
4448
},
4549
data: {

0 commit comments

Comments
 (0)