Skip to content

Commit 9a02150

Browse files
authored
Add more detailt alt tags for avatar images (LucasBassetti#273)
1 parent 9e53baf commit 9a02150

File tree

5 files changed

+10
-23
lines changed

5 files changed

+10
-23
lines changed

dist/react-simple-chatbot.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/react-simple-chatbot.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/ChatBot.jsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ class ChatBot extends Component {
6262
const {
6363
botDelay,
6464
botAvatar,
65+
botName,
6566
cache,
6667
cacheName,
6768
customDelay,
@@ -71,7 +72,7 @@ class ChatBot extends Component {
7172
} = this.props;
7273
const chatSteps = {};
7374

74-
const defaultBotSettings = { delay: botDelay, avatar: botAvatar };
75+
const defaultBotSettings = { delay: botDelay, avatar: botAvatar, botName };
7576
const defaultUserSettings = {
7677
delay: userDelay,
7778
avatar: userAvatar,
@@ -724,6 +725,7 @@ class ChatBot extends Component {
724725
ChatBot.propTypes = {
725726
avatarStyle: PropTypes.objectOf(PropTypes.any),
726727
botAvatar: PropTypes.string,
728+
botName: PropTypes.string,
727729
botDelay: PropTypes.number,
728730
bubbleOptionStyle: PropTypes.objectOf(PropTypes.any),
729731
bubbleStyle: PropTypes.objectOf(PropTypes.any),
@@ -776,6 +778,7 @@ ChatBot.propTypes = {
776778
ChatBot.defaultProps = {
777779
avatarStyle: {},
778780
botDelay: 1000,
781+
botName: 'The bot',
779782
bubbleOptionStyle: {},
780783
bubbleStyle: {},
781784
cache: false,

lib/steps_components/text/TextStep.jsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,12 @@ class TextStep extends Component {
6161
hideUserAvatar
6262
} = this.props;
6363
const { loading } = this.state;
64-
const { avatar, user } = step;
64+
const { avatar, user, botName } = step;
6565

6666
const showAvatar = user ? !hideUserAvatar : !hideBotAvatar;
6767

68+
const imageAltText = user ? "Your avatar" : `${botName}'s avatar`;
69+
6870
return (
6971
<TextStepContainer className={`rsc-ts ${user ? 'rsc-ts-user' : 'rsc-ts-bot'}`} user={user}>
7072
<ImageContainer className="rsc-ts-image-container" user={user}>
@@ -75,7 +77,7 @@ class TextStep extends Component {
7577
showAvatar={showAvatar}
7678
user={user}
7779
src={avatar}
78-
alt="avatar"
80+
alt={imageAltText}
7981
/>
8082
)}
8183
</ImageContainer>

package-lock.json

Lines changed: 0 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)