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(avatar): 无障碍朗读支持. (#1028) #1137

Merged
merged 6 commits into from
Dec 2, 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
5 changes: 5 additions & 0 deletions src/avatar/__test__/__snapshots__/demo.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ exports[`Avatar Avatar action demo works fine 1`] = `
image="https://cdn-we-retail.ym.tencent.com/retail-ui/components-exp/avatar/avatar-v2/1.png"
/>
<t-avatar
ariaLabel="添加"
ariaRole="button"
bordered="{{true}}"
icon="user-add"
slot="collapseAvatar"
Expand Down Expand Up @@ -77,6 +79,8 @@ exports[`Avatar Avatar action demo works fine 1`] = `
image="https://cdn-we-retail.ym.tencent.com/retail-ui/components-exp/avatar/avatar-v2/1.png"
/>
<t-avatar
ariaLabel="添加"
ariaRole="button"
bordered="{{true}}"
icon="user-add"
slot="collapseAvatar"
Expand Down Expand Up @@ -144,6 +148,7 @@ exports[`Avatar Avatar character-avatar demo works fine 1`] = `
class="avatar-example"
>
<t-avatar
ariaLabel="字符头像"
tClassContent="external-class-content"
>
A
Expand Down
4 changes: 2 additions & 2 deletions src/avatar/_example/action/index.wxml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
<view class="avatar-example">
<t-avatar-group max="5" cascading="left-up" size="medium">
<t-avatar wx:for="{{pics}}" wx:for-item="pic" wx:key="index" image="{{pic}}" bordered />
<t-avatar slot="collapseAvatar" icon="user-add" bindtap="onAddTap" bordered />
<t-avatar slot="collapseAvatar" icon="user-add" bindtap="onAddTap" bordered aria-role="button" aria-label="添加" />
</t-avatar-group>
</view>
<view class="avatar-example">
<t-avatar-group max="5" size="medium">
<t-avatar wx:for="{{pics}}" wx:for-item="pic" wx:key="index" image="{{pic}}" bordered />
<t-avatar slot="collapseAvatar" icon="user-add" bindtap="onAddTap" bordered />
<t-avatar slot="collapseAvatar" icon="user-add" bindtap="onAddTap" bordered aria-role="button" aria-label="添加"/>
</t-avatar-group>
</view>
</view>
2 changes: 1 addition & 1 deletion src/avatar/_example/character-avatar/index.wxml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<view class="demo-avatar">
<view class="avatar-example">
<t-avatar t-class-content="external-class-content">A</t-avatar>
<t-avatar t-class-content="external-class-content" aria-label="字符头像">A</t-avatar>
</view>
<view class="avatar-example">
<t-avatar shape="round" t-class-content="external-class-content">A</t-avatar>
Expand Down
1 change: 1 addition & 0 deletions src/avatar/avatar-group.wxml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
t-class-content="{{prefix}}-class-content"
bordered="{{true}}"
size="{{size}}"
aria-role="none"
>{{collapseAvatar || '+N'}}</t-avatar
>
</view>
Expand Down
3 changes: 3 additions & 0 deletions src/avatar/avatar.wxml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
<view
class="{{this.getAvatarOuterClass(classPrefix, size, shape, bordered)}} {{prefix}}-class-image "
style="{{this.getAvatarSizePx(size)}}"
aria-label="{{ ariaLabel || alt ||'头像'}}"
aria-role="{{ ariaRole || 'img'}}"
aria-hidden="{{ ariaHidden }}"
>
<t-image
wx:if="{{image}}"
Expand Down