Skip to content

Commit

Permalink
feat: support aria property for all component (#1127)
Browse files Browse the repository at this point in the history
* feat: support aria property for all component

* test(icon): update snapshot

* test(icon): update snapshot
  • Loading branch information
LeeJim authored Nov 28, 2022
1 parent a31529c commit a9be36b
Show file tree
Hide file tree
Showing 10 changed files with 76 additions and 4 deletions.
3 changes: 3 additions & 0 deletions src/calendar/__test__/__snapshots__/index.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ exports[`calendar :base 1`] = `
bind:tap="handleClose"
>
<wx-view
ariaHidden="{{false}}"
ariaLabel=""
ariaRole=""
class="t-icon t-class"
style="font-size: 24px"
bind:tap="onTap"
Expand Down
3 changes: 3 additions & 0 deletions src/cell/__test__/__snapshots__/index.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ exports[`cell :base 1`] = `
class="t-cell__right-icon t-class-right-icon"
>
<wx-view
ariaHidden="{{false}}"
ariaLabel=""
ariaRole=""
class="t-icon t-class"
style=""
bind:tap="onTap"
Expand Down
24 changes: 24 additions & 0 deletions src/collapse/__test__/__snapshots__/index.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ exports[`collapse :base 1`] = `
class="t-cell__right-icon t-class-right-icon"
>
<wx-view
ariaHidden="{{false}}"
ariaLabel=""
ariaRole=""
class="t-icon t-class"
style=""
bind:tap="onTap"
Expand Down Expand Up @@ -134,6 +137,9 @@ exports[`collapse :base 1`] = `
class="t-cell__right-icon t-class-right-icon"
>
<wx-view
ariaHidden="{{false}}"
ariaLabel=""
ariaRole=""
class="t-icon t-class"
style=""
bind:tap="onTap"
Expand Down Expand Up @@ -217,6 +223,9 @@ exports[`collapse :base 1`] = `
class="t-cell__right-icon t-class-right-icon"
>
<wx-view
ariaHidden="{{false}}"
ariaLabel=""
ariaRole=""
class="t-icon t-class"
style=""
bind:tap="onTap"
Expand Down Expand Up @@ -291,6 +300,9 @@ exports[`collapse :base 1`] = `
class="t-cell__right-icon t-class-right-icon"
>
<wx-view
ariaHidden="{{false}}"
ariaLabel=""
ariaRole=""
class="t-icon t-class"
style=""
bind:tap="onTap"
Expand Down Expand Up @@ -378,6 +390,9 @@ exports[`collapse :defaultExpandAll 1`] = `
class="t-cell__right-icon t-class-right-icon"
>
<wx-view
ariaHidden="{{false}}"
ariaLabel=""
ariaRole=""
class="t-icon t-class"
style=""
bind:tap="onTap"
Expand Down Expand Up @@ -452,6 +467,9 @@ exports[`collapse :defaultExpandAll 1`] = `
class="t-cell__right-icon t-class-right-icon"
>
<wx-view
ariaHidden="{{false}}"
ariaLabel=""
ariaRole=""
class="t-icon t-class"
style=""
bind:tap="onTap"
Expand Down Expand Up @@ -541,6 +559,9 @@ exports[`collapse :disabled 1`] = `
class="t-cell__right-icon t-class-right-icon"
>
<wx-view
ariaHidden="{{false}}"
ariaLabel=""
ariaRole=""
class="t-icon t-class"
style=""
bind:tap="onTap"
Expand Down Expand Up @@ -617,6 +638,9 @@ exports[`collapse :disabled 1`] = `
class="t-cell__right-icon t-class-right-icon"
>
<wx-view
ariaHidden="{{false}}"
ariaLabel=""
ariaRole=""
class="t-icon t-class"
style=""
bind:tap="onTap"
Expand Down
14 changes: 11 additions & 3 deletions src/common/src/instantiationDecorator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ const ComponentNativeProps = [
* @param options {}
*/
export const toComponent = function toComponent(options: Record<string, any>) {
// 处理 properties 属性
if (options.properties) {
Object.keys(options.properties).forEach((k) => {
let opt = options.properties[k];
Expand All @@ -38,12 +37,21 @@ export const toComponent = function toComponent(options: Record<string, any>) {
}
options.properties[k] = opt;
});
// aria
const ariaProps = [
{ key: 'ariaHidden', type: Boolean },
{ key: 'ariaRole', type: String },
{ key: 'ariaLabel', type: String },
];
ariaProps.forEach(({ key, type }) => {
options.properties[key] = {
type,
};
});
}

// 处理自定义的方法和生命周期函数
if (!options.methods) options.methods = {};

// 使用 lifetimes 处理生命周期函数
if (!options.lifetimes) options.lifetimes = {};

const inits: { [key: string]: PropertyDescriptor } = {};
Expand Down
9 changes: 8 additions & 1 deletion src/icon/icon.wxml
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
<view class="{{ prefix ? prefix : classPrefix}} {{componentPrefix}}-class" style="{{ iconStyle }}" bind:tap="onTap">
<view
class="{{ prefix ? prefix : classPrefix}} {{componentPrefix}}-class"
style="{{ iconStyle }}"
bind:tap="onTap"
aria-hidden="{{ariaHidden}}"
aria-label="{{ariaLabel}}"
aria-role="{{ariaRole}}"
>
<view wx:if="{{ isImage }}" class="{{classPrefix}}--image">
<image src="{{ name }}" mode="aspectFit" class="{{classPrefix}}__image" />
</view>
Expand Down
3 changes: 3 additions & 0 deletions src/image/__test__/__snapshots__/index.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ exports[`image :base 1`] = `
>
<t-icon>
<wx-view
ariaHidden="{{false}}"
ariaLabel=""
ariaRole=""
class="t-icon t-class"
style=""
bind:tap="onTap"
Expand Down
6 changes: 6 additions & 0 deletions src/input/__test__/__snapshots__/index.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ exports[`input props : clearable && label && suffix 1`] = `
class="t-class-clearable"
>
<wx-view
ariaHidden="{{false}}"
ariaLabel=""
ariaRole=""
class="t-icon t-class"
style="font-size: 48rpx"
bind:tap="onTap"
Expand Down Expand Up @@ -90,6 +93,9 @@ exports[`input props : clearable && label && suffix 1`] = `
class="t-class-suffix-icon"
>
<wx-view
ariaHidden="{{false}}"
ariaLabel=""
ariaRole=""
class="t-icon t-class"
style="font-size: 48rpx"
bind:tap="onTap"
Expand Down
3 changes: 3 additions & 0 deletions src/notice-bar/__test__/__snapshots__/index.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ exports[`notice-bar props : marquee 1`] = `
>
<t-icon>
<wx-view
ariaHidden="{{false}}"
ariaLabel=""
ariaRole=""
class="t-icon t-class"
style=""
bind:tap="onTap"
Expand Down
3 changes: 3 additions & 0 deletions src/search/__test__/__snapshots__/index.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ exports[`search Props :base 1`] = `
class="t-icon t-class-left"
>
<wx-view
ariaHidden="{{false}}"
ariaLabel=""
ariaRole=""
class="t-icon t-class"
style="font-size: 24px"
bind:tap="onTap"
Expand Down
12 changes: 12 additions & 0 deletions src/stepper/__test__/__snapshots__/index.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ exports[`stepper event : input 1`] = `
class="t-stepper__minus-icon"
>
<wx-view
ariaHidden="{{false}}"
ariaLabel=""
ariaRole=""
class="t-icon t-class"
style="color: #444; font-size: 40rpx"
bind:tap="onTap"
Expand Down Expand Up @@ -41,6 +44,9 @@ exports[`stepper event : input 1`] = `
class="t-stepper__plus-icon"
>
<wx-view
ariaHidden="{{false}}"
ariaLabel=""
ariaRole=""
class="t-icon t-class"
style="color: #444; font-size: 40rpx"
bind:tap="onTap"
Expand All @@ -67,6 +73,9 @@ exports[`stepper event : input 2`] = `
class="t-stepper__minus-icon"
>
<wx-view
ariaHidden="{{false}}"
ariaLabel=""
ariaRole=""
class="t-icon t-class"
style="color: #444; font-size: 40rpx"
bind:tap="onTap"
Expand Down Expand Up @@ -95,6 +104,9 @@ exports[`stepper event : input 2`] = `
class="t-stepper__plus-icon"
>
<wx-view
ariaHidden="{{false}}"
ariaLabel=""
ariaRole=""
class="t-icon t-class"
style="color: #444; font-size: 40rpx"
bind:tap="onTap"
Expand Down

0 comments on commit a9be36b

Please sign in to comment.