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

Fix/upload/slot #1507

Merged
merged 3 commits into from
Jan 14, 2023
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
2 changes: 1 addition & 1 deletion src/upload/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ isComponent: true

名称 | 类型 | 默认值 | 说明 | 必传
-- | -- | -- | -- | --
add-content | String / Slot | - | 添加按钮内容。值为空,使用默认图标渲染;值为 slot 则表示使用插槽渲染;其他值无效。 | N
add-content | String / Slot | - | 添加按钮内容 | N
allow-upload-duplicate-file | Boolean | false | 【开发中】是否允许重复上传相同文件名的文件 | N
config | Object | - | 图片上传配置,视频上传配置,文件上传配置等,包含图片尺寸、图片来源、视频来源、视频拍摄最长时间等。更多细节查看小程序官网。[图片上传](https://developers.weixin.qq.com/miniprogram/dev/api/media/image/wx.chooseImage.html)。[视频上传](https://developers.weixin.qq.com/miniprogram/dev/api/media/video/wx.chooseVideo.html)。TS 类型:`UploadMpConfig` `type UploadMpConfig = ImageConfig \| VideoConfig` `interface ImageConfig { count?: number; sizeType?: Array<SizeTypeValues>; sourceType?: Array<SourceTypeValues> }` `type SizeTypeValues = 'original' \| 'compressed'` `type SourceTypeValues = 'album' \| 'camera'` `interface VideoConfig { sourceType?: Array<SourceTypeValues>; compressed?: boolean; maxDuration?: number; camera?: 'back' \| 'front' }`。[详细类型定义](https://github.com/Tencent/tdesign-miniprogram/tree/develop/src/upload/type.ts) | N
custom-style `v0.25.0` | String | - | 自定义组件样式 | N
Expand Down
4 changes: 2 additions & 2 deletions src/upload/__test__/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ describe('upload', () => {
id="t-upload"
addContent="slot"
>
<text slot="add-content"> {{text}} </text>
<text slot="add-content" class="custom-add"> {{text}} </text>
</t-upload>
`,
data: {
Expand All @@ -342,7 +342,7 @@ describe('upload', () => {
const comp = simulate.render(id);
comp.attach(document.createElement('parent-wrapper'));

const $addIcon = comp.querySelector('#t-upload >>> .t-upload__add-icon');
const $addIcon = comp.querySelector('#t-upload >>> .custom-add');
expect($addIcon.dom.textContent).toContain(comp.data.text);
});
});
Expand Down
6 changes: 5 additions & 1 deletion src/upload/upload.less
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,17 @@
&__add-icon {
width: 100%;
height: 100%;
display: flex;
display: none;
align-items: center;
justify-content: center;
font-size: @upload-add-icon-font-size;
background-color: @upload-add-bg-color;
color: @upload-add-color;
border-radius: @upload-radius;

&:only-child {
display: flex;
}
}

&__thumbnail {
Expand Down
10 changes: 5 additions & 5 deletions src/upload/upload.wxml
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@
</view>
<!-- 删除 -->
<view class="{{classPrefix}}__close-btn hotspot-expanded" bindtap="onDelete" data-index="{{index}}">
<slot wx:if="{{deleteBtn === 'slot'}}" name="delete-btn" />
<t-icon wx:else name="close" size="16" color="#fff" />
<t-icon name="close" size="16" color="#fff" />
</view>
</view>
</t-grid-item>
Expand All @@ -63,9 +62,10 @@
bindclick="onAddTap"
>
<view class="{{classPrefix}}__wrapper" style="{{gridItemStyle}}">
<view class="{{classPrefix}}__add-icon">
<slot wx:if="{{addContent === 'slot'}}" name="add-content" />
<t-icon wx:else name="add" />
<slot name="add-content" />
<block wx:if="{{addContent}}">{{addContent}}</block>
<view wx:else class="{{classPrefix}}__add-icon">
<t-icon name="add" />
</view>
</view>
</t-grid-item>
Expand Down