Skip to content

Commit 801de29

Browse files
authored
feat(Drawer): add overlayProps attr (#3978)
* feat(Drawer): add overlayProps attr * chore: unified code standard
1 parent c69eb75 commit 801de29

File tree

6 files changed

+44
-12
lines changed

6 files changed

+44
-12
lines changed

packages/components/drawer/README.en-US.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,23 @@ style | Object | - | CSS(Cascading Style Sheets) | N
1010
custom-style | Object | - | CSS(Cascading Style Sheets),used to set style on virtual component | N
1111
close-on-overlay-click | Boolean | true | \- | N
1212
destroy-on-close | Boolean | false | \- | N
13-
footer | Slot | - | `0.29.0`[see more ts definition](https://github.com/Tencent/tdesign-miniprogram/blob/develop/packages/components/common/common.ts) | N
13+
1414
items | Array | - | Typescript:`DrawerItem[]` `interface DrawerItem { title: string; icon: string; }`[see more ts definition](https://github.com/Tencent/tdesign-miniprogram/blob/develop/packages/components/drawer/type.ts) | N
15+
overlay-props | Object | {} | Typescript:`OverlayProps`[Overlay API Documents](./overlay?tab=api)[see more ts definition](https://github.com/Tencent/tdesign-miniprogram/blob/develop/packages/components/drawer/type.ts) | N
1516
placement | String | right | options: left/right | N
1617
show-overlay | Boolean | true | \- | N
17-
title | String / Slot | - | `0.29.0`[see more ts definition](https://github.com/Tencent/tdesign-miniprogram/blob/develop/packages/components/common/common.ts) | N
18+
title | String | - | `0.29.0` | N
1819
using-custom-navbar | Boolean | false | \- | N
1920
visible | Boolean | false | \- | N
2021
z-index | Number | 11500 | \- | N
2122

23+
### Drawer Slots
24+
25+
name | Description
26+
-- | --
27+
footer | `0.29.0`
28+
title | `0.29.0`
29+
2230
### Drawer Events
2331

2432
name | params | description

packages/components/drawer/README.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,23 @@ style | Object | - | 样式 | N
5353
custom-style | Object | - | 样式,一般用于开启虚拟化组件节点场景 | N
5454
close-on-overlay-click | Boolean | true | 点击蒙层时是否触发抽屉关闭事件 | N
5555
destroy-on-close | Boolean | false | 抽屉关闭时是否销毁节点 | N
56-
footer | Slot | - | `0.29.0`。抽屉的底部。[通用类型定义](https://github.com/Tencent/tdesign-miniprogram/blob/develop/packages/components/common/common.ts) | N
56+
5757
items | Array | - | 抽屉里的列表项。TS 类型:`DrawerItem[]` `interface DrawerItem { title: string; icon: string; }`[详细类型定义](https://github.com/Tencent/tdesign-miniprogram/blob/develop/packages/components/drawer/type.ts) | N
58+
overlay-props | Object | {} | 遮罩层的属性,透传至 overlay。TS 类型:`OverlayProps`[Overlay API Documents](./overlay?tab=api)[详细类型定义](https://github.com/Tencent/tdesign-miniprogram/blob/develop/packages/components/drawer/type.ts) | N
5859
placement | String | right | 抽屉方向。可选项:left/right | N
5960
show-overlay | Boolean | true | 是否显示遮罩层 | N
60-
title | String / Slot | - | `0.29.0`。抽屉的标题[通用类型定义](https://github.com/Tencent/tdesign-miniprogram/blob/develop/packages/components/common/common.ts) | N
61+
title | String | - | `0.29.0`。抽屉的标题 | N
6162
using-custom-navbar | Boolean | false | 是否使用了自定义导航栏 | N
6263
visible | Boolean | false | 组件是否可见 | N
6364
z-index | Number | 11500 | 抽屉层级,样式默认为 11500 | N
6465

66+
### Drawer Slots
67+
68+
名称 | 描述
69+
-- | --
70+
footer | `0.29.0`。抽屉的底部
71+
title | `0.29.0`。抽屉的标题
72+
6573
### Drawer Events
6674

6775
名称 | 参数 | 描述

packages/components/drawer/drawer.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export default class Drawer extends SuperComponent {
2424

2525
methods = {
2626
// closeOnOverlayClick为true时才能触发popup的visible-change事件
27-
visibleChange({ detail }) {
27+
onVisibleChange({ detail }) {
2828
const { visible } = detail;
2929
const { showOverlay } = this.data;
3030

@@ -41,7 +41,7 @@ export default class Drawer extends SuperComponent {
4141
}
4242
},
4343

44-
itemClick(detail) {
44+
onItemClick(detail) {
4545
const { index, item } = detail.currentTarget.dataset;
4646

4747
this.triggerEvent('item-click', { index, item });

packages/components/drawer/drawer.wxml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@
44
wx:if="{{!destroyOnClose || visible}}"
55
style="{{_._style([style, customStyle])}}"
66
class="class"
7-
bind:visible-change="visibleChange"
87
visible="{{visible}}"
9-
zIndex="{{zIndex}}"
10-
usingCustomNavbar="{{usingCustomNavbar}}"
8+
z-index="{{zIndex}}"
9+
using-custom-navbar="{{usingCustomNavbar}}"
1110
placement="{{placement == 'right' ? 'right' : 'left'}}"
12-
showOverlay="{{showOverlay}}"
13-
closeOnOverlayClick="{{closeOnOverlayClick}}"
11+
show-overlay="{{showOverlay}}"
12+
overlay-props="{{overlayProps}}"
13+
close-on-click-overlay="{{closeOnOverlayClick}}"
14+
bind:visible-change="onVisibleChange"
1415
>
1516
<view class="{{classPrefix}}">
1617
<slot name="title" />
@@ -26,9 +27,9 @@
2627
wx:key="index"
2728
data-item="{{item}}"
2829
data-index="{{index}}"
29-
bindtap="itemClick"
3030
aria-role="{{ ariaRole || 'button' }}"
3131
aria-label="{{item.title}}"
32+
bindtap="onItemClick"
3233
>
3334
<view aria-hidden="{{true}}" wx:if="{{item.icon}}" class="{{classPrefix}}__sidebar-item-icon">
3435
<t-icon name="{{item.icon}}" />

packages/components/drawer/props.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ const props: TdDrawerProps = {
2020
items: {
2121
type: Array,
2222
},
23+
/** 遮罩层的属性,透传至 overlay */
24+
overlayProps: {
25+
type: Object,
26+
value: {},
27+
},
2328
/** 抽屉方向 */
2429
placement: {
2530
type: String,

packages/components/drawer/type.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
* 该文件为脚本自动生成文件,请勿随意修改。如需修改请联系 PMC
55
* */
66

7+
import { OverlayProps } from '../overlay/index';
8+
79
export interface TdDrawerProps {
810
/**
911
* 点击蒙层时是否触发抽屉关闭事件
@@ -28,6 +30,14 @@ export interface TdDrawerProps {
2830
type: ArrayConstructor;
2931
value?: DrawerItem[];
3032
};
33+
/**
34+
* 遮罩层的属性,透传至 overlay
35+
* @default {}
36+
*/
37+
overlayProps?: {
38+
type: ObjectConstructor;
39+
value?: OverlayProps;
40+
};
3141
/**
3242
* 抽屉方向
3343
* @default right

0 commit comments

Comments
 (0)