Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Grid): support iconProps: #1123

Merged
merged 1 commit into from
Nov 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/grid/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ custom-style | String | - | 自定义组件样式 | N
description | String / Slot | - | 文本以外的更多描述,辅助信息。可以通过 Props 传入文本,也可以自定义标题节点 | N
external-classes | Array | - | 组件类名,分别用于设置组件外层元素、图片、文本、描述等元素类名。`['t-class', 't-class-image', 't-class-text', 't-class-description']` | N
icon | String | - | 图标名称 | N
icon-props | Object | {} | 图标属性,透传至 icon | N
image | String / Slot | - | 图片,可以是图片地址,也可以自定义图片节点 | N
image-props | Object | - | 透传至 Image 组件 | N
jump-type | String | navigate-to | 链接跳转类型。可选项:redirect-to/switch-tab/relaunch/navigate-to | N
Expand Down
5 changes: 5 additions & 0 deletions src/grid/grid-item-props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ const props: TdGridItemProps = {
type: String,
value: '',
},
/** 图标属性,透传至 icon */
iconProps: {
type: Object,
value: {},
},
/** 图片,可以是图片地址,也可以自定义图片节点 */
image: {
type: String,
Expand Down
9 changes: 8 additions & 1 deletion src/grid/grid-item.wxml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,14 @@
/>
</block>
<slot wx:else name="image" />
<t-icon wx:if="{{icon}}" name="{{icon}}" size="48rpx" />
<t-icon
wx:if="{{icon}}"
name="{{iconProps.name || icon}}"
prefix="{{iconProps.prefix}}"
size="{{iconProps.size || '48rpx'}}"
color="{{iconProps.color}}"
customStyle="{{iconProps.customStyle}}"
></t-icon>
</view>
</t-badge>
<view class="{{_.cls(classPrefix + '__words', [layout])}}">
Expand Down
8 changes: 8 additions & 0 deletions src/grid/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,14 @@ export interface TdGridItemProps {
type: StringConstructor;
value?: string;
};
/**
* 图标属性,透传至 icon
* @default {}
*/
iconProps?: {
type: ObjectConstructor;
value?: object;
};
/**
* 图片,可以是图片地址,也可以自定义图片节点
*/
Expand Down