Skip to content
This repository was archived by the owner on Feb 6, 2024. It is now read-only.

Commit 1fa9230

Browse files
Merge pull request #339 from deckgo/accessibility
feat: improve avatars accessbility
2 parents 00efd54 + c4d0f5f commit 1fa9230

File tree

7 files changed

+11
-8
lines changed

7 files changed

+11
-8
lines changed

studio/src/app/components/core/app-avatar/app-avatar.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,16 @@ import {Component, Prop, h} from '@stencil/core';
99
export class AppAvatar {
1010

1111
@Prop() src: string;
12+
@Prop() ariaLabel: string;
1213

1314
render() {
1415
if (this.src) {
1516
return <ion-avatar>
16-
<img src={this.src}/>
17+
<img src={this.src} alt={this.ariaLabel}/>
1718
</ion-avatar>
1819
} else {
1920
return <ion-avatar>
20-
<ion-icon name="person" md="md-person" ios="md-person"></ion-icon>
21+
<ion-icon name="person" md="md-person" ios="md-person" aria-label={this.ariaLabel}></ion-icon>
2122
</ion-avatar>
2223
}
2324
}

studio/src/app/components/core/app-navigation-actions/app-navigation-actions.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ export class AppNavigationActions {
107107

108108
private renderLoggedIn() {
109109
if (Utils.isLoggedIn(this.authUser) && this.photoUrlLoaded) {
110-
return <a class="ion-padding-end" onClick={(e: UIEvent) => this.openMenu(e)}>
110+
return <a class="ion-padding-end" onClick={(e: UIEvent) => this.openMenu(e)} aria-label="Open menu">
111111
<app-avatar src={this.photoUrl}></app-avatar>
112112
</a>;
113113
} else {

studio/src/app/components/core/app-user-info/app-user-info.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ export class AppUserInfo {
7979
if (this.authUser) {
8080
return <ion-grid>
8181
<ion-row class="ion-align-items-center">
82-
<ion-col size={'' + this.avatarColSize}><app-avatar src={this.photoUrl}></app-avatar></ion-col>
82+
<ion-col size={'' + this.avatarColSize}><app-avatar src={this.photoUrl} aria-hidden="true"></app-avatar></ion-col>
8383
<ion-col size={'' + (12 - this.avatarColSize)} class="user-info">
8484
<ion-label>{this.name}</ion-label>
8585
<ion-label>{!this.authUser.anonymous && this.apiUser && this.apiUser.username ? '@' + this.apiUser.username : undefined}</ion-label>

studio/src/app/components/feed/card/app-feed-card/app-feed-card.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ export class AppFeedCard {
157157

158158
private renderAuthorAvatar() {
159159
if (this.authorPhotoUrl) {
160-
return <app-avatar src={this.authorPhotoUrl}></app-avatar>
160+
return <app-avatar src={this.authorPhotoUrl} aria-label={this.author}></app-avatar>
161161
} else {
162162
return undefined;
163163
}

studio/src/app/pages/core/about/app-team/app-team.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export class AppTeam {
1616

1717
<div class="team">
1818
<div>
19-
<app-avatar src="https://pbs.twimg.com/profile_images/941274539979366400/bTKGkd-O_400x400.jpg"></app-avatar>
19+
<app-avatar src="https://pbs.twimg.com/profile_images/941274539979366400/bTKGkd-O_400x400.jpg" aria-label="David Dal Busco"></app-avatar>
2020

2121
<h2>David Dal Busco</h2>
2222

@@ -46,7 +46,7 @@ export class AppTeam {
4646
</div>
4747

4848
<div>
49-
<app-avatar src="https://pbs.twimg.com/profile_images/588789970690658305/Ru9JiWks_400x400.png"></app-avatar>
49+
<app-avatar src="https://pbs.twimg.com/profile_images/588789970690658305/Ru9JiWks_400x400.png" arial-label="Nicolas Mattia"></app-avatar>
5050

5151
<h2>Nicolas Mattia</h2>
5252

studio/src/app/pages/core/app-settings/app-settings.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ export class AppHome {
483483
<ion-label>Profile picture</ion-label>
484484
</ion-item>
485485
<div class="avatar">
486-
<app-avatar src={this.user && this.user.data ? this.user.data.photo_url : undefined}></app-avatar>
486+
<app-avatar src={this.user && this.user.data ? this.user.data.photo_url : undefined} aria-label="Profile picture"></app-avatar>
487487
<input id="inputProfilePicture" type="file" accept="image/x-png,image/jpeg,image/gif" onChange={() => this.selectProfilePicture()} disabled={this.saving}/>
488488
</div>
489489
<p><small>Tips: if you would update your profile picture, ideally use a <strong>square</strong> image for that purpose</small></p>

studio/src/components.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export namespace Components {
2323
interface AppAbout {}
2424
interface AppAddSlideAction {}
2525
interface AppAvatar {
26+
'ariaLabel': string;
2627
'src': string;
2728
}
2829
interface AppCode {
@@ -577,6 +578,7 @@ declare namespace LocalJSX {
577578
'onActionOpenSlideAdd'?: (event: CustomEvent<UIEvent>) => void;
578579
}
579580
interface AppAvatar extends JSXBase.HTMLAttributes<HTMLAppAvatarElement> {
581+
'ariaLabel'?: string;
580582
'src'?: string;
581583
}
582584
interface AppCode extends JSXBase.HTMLAttributes<HTMLAppCodeElement> {

0 commit comments

Comments
 (0)