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

Commit 6d99f45

Browse files
author
Cobb Jung
committed
Update img tag alt attributes, SEO in mind
Make dom util, create img accept alt parameter. Update alt texts with SEO in mind. Refer to https://blog.hubspot.com/marketing/image-alt-text
1 parent 12d3bee commit 6d99f45

File tree

5 files changed

+24
-13
lines changed

5 files changed

+24
-13
lines changed

lib/utils/domUtil.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,12 +111,12 @@ export function createButton({ id, className, innerText } = {}) {
111111
return _createElement({ tagName: 'button', id: id, className: className, innerText: innerText });
112112
}
113113

114-
export function createImg({ id, className, src, onerror } = {}) {
114+
export function createImg({ id, className, src, alt, onerror } = {}) {
115115
const element = _createElement({
116116
tagName: 'img',
117117
id: id,
118118
className: className,
119-
attrs: { src: src }
119+
attrs: { src, alt }
120120
});
121121

122122
element.onerror = onerror;

lib/views/CallLogItem.js

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,22 @@ export class CallLogItem {
1212
if(callLogInfo) {
1313
const wrapper = createListItem({ id: callLogInfo.callId, className: className });
1414
let callType = null;
15+
let callTypeAlt = '';
1516
if(callLogInfo.isVideoCall){
1617
if(callLogInfo.userRole === 'dc_caller'){
1718
callType = outgoingVideo;
19+
callTypeAlt = 'Outgoing call history';
1820
} else {
1921
callType = incomingVideo;
22+
callTypeAlt = 'Incoming call history';
2023
}
2124
} else {
2225
if(callLogInfo.userRole === 'dc_caller'){
2326
callType = outgoingVoice;
27+
callTypeAlt = 'Outgoing call history';
2428
} else {
2529
callType = incomingVoice;
30+
callTypeAlt = 'Incoming call history';
2631
}
2732
}
2833

@@ -36,14 +41,19 @@ export class CallLogItem {
3641
displayName = callLogInfo.caller.userId;
3742
}
3843

39-
const icoCallType = createImg({ className: `${classes['callLogItemType']}`, src: callType });
44+
const icoCallType = createImg({ className: `${classes['callLogItemType']}`, src: callType, alt: callTypeAlt });
4045
const callTypeDiv = createDiv({ className: `${classes['callLogTypeDiv']}` });
4146
callTypeDiv.appendChild(icoCallType);
4247

43-
const profileImg = createImg({ className: `${classes['callLogProfileImg']}`, src: profileImage, onerror: (error) => {
44-
error.currentTarget.src = avatarIcon;
45-
}});
46-
48+
const profileImg = createImg({
49+
className: `${classes['callLogProfileImg']}`,
50+
src: profileImage,
51+
alt: 'Opponent profile photo of call history',
52+
onerror: (error) => {
53+
error.currentTarget.src = avatarIcon;
54+
}
55+
});
56+
4757
const profileDiv = createDiv({ className: `${classes['callLogProfileDiv']}` });
4858
profileDiv.appendChild(profileImg);
4959

@@ -85,12 +95,12 @@ export class CallLogItem {
8595
const btnCallVoice = createDiv({ className: `${classes['callLogVoiceActionBtn']}`});
8696
callActionBtnWrap.appendChild(btnCallVoice);
8797
callActionBtnWrap.appendChild(btnCallVideo);
88-
89-
98+
99+
90100
const callLogActionDiv = createDiv({ className: `${classes['callLogActionDiv']}` });
91101
callLogActionDiv.appendChild(callLogStartTime);
92102
callLogActionDiv.appendChild(callActionBtnWrap);
93-
103+
94104

95105
wrapper.appendChild(callTypeDiv);
96106
wrapper.appendChild(profileDiv);
@@ -135,4 +145,4 @@ export class CallLogItem {
135145
eventhandler(event, {peerId: this.destPeerID, isVideoCall: false, callOption: null});
136146
};
137147
}
138-
}
148+
}

lib/views/CallView.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export default class CallView extends BaseElement {
2424

2525
this.peerProfile = createImg({
2626
src: remoteUser.profileUrl,
27+
alt: 'Sendbird voice & video call opponent profile photo',
2728
className: classes['remoteProfile'],
2829
onerror: (e) => e.target.style.visibility = 'hidden'
2930
});

views/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<body>
1212
<div id="container" class="wrapper center bg-white">
1313
<div id="welcome_view" class="column center">
14-
<img src="<%=require('../img/ic-logo-horizontal-purple-300.svg')%>" alt="logo" class="ic-logo-horizontal-purple-300">
14+
<img src="<%=require('../img/ic-logo-horizontal-purple-300.svg')%>" alt="Sendbird horizontal logo svg icon" class="ic-logo-horizontal-purple-300">
1515
<div class="title voice-sample-page">
1616
Calls Sample
1717
</div>

views/widget.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<body>
1111
<div id="container" class="wrapper center">
1212
<div id="welcome_view" class="column center">
13-
<img src="<%=require('../img/ic-logo-horizontal-purple-300.svg')%>" alt="logo" class="ic-logo-horizontal-purple-300" />
13+
<img src="<%=require('../img/ic-logo-horizontal-purple-300.svg')%>" alt="Sendbird horizontal svg icon" class="ic-logo-horizontal-purple-300" />
1414
<div class="voice-sample-page title">
1515
Voice Sample Login
1616
</div>

0 commit comments

Comments
 (0)