Skip to content

Commit

Permalink
Add more detailt alt tags for avatar images (LucasBassetti#273)
Browse files Browse the repository at this point in the history
  • Loading branch information
lazerwalker authored Jun 24, 2020
1 parent 9e53baf commit 9a02150
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 23 deletions.
2 changes: 1 addition & 1 deletion dist/react-simple-chatbot.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/react-simple-chatbot.js.map

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion lib/ChatBot.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class ChatBot extends Component {
const {
botDelay,
botAvatar,
botName,
cache,
cacheName,
customDelay,
Expand All @@ -71,7 +72,7 @@ class ChatBot extends Component {
} = this.props;
const chatSteps = {};

const defaultBotSettings = { delay: botDelay, avatar: botAvatar };
const defaultBotSettings = { delay: botDelay, avatar: botAvatar, botName };
const defaultUserSettings = {
delay: userDelay,
avatar: userAvatar,
Expand Down Expand Up @@ -724,6 +725,7 @@ class ChatBot extends Component {
ChatBot.propTypes = {
avatarStyle: PropTypes.objectOf(PropTypes.any),
botAvatar: PropTypes.string,
botName: PropTypes.string,
botDelay: PropTypes.number,
bubbleOptionStyle: PropTypes.objectOf(PropTypes.any),
bubbleStyle: PropTypes.objectOf(PropTypes.any),
Expand Down Expand Up @@ -776,6 +778,7 @@ ChatBot.propTypes = {
ChatBot.defaultProps = {
avatarStyle: {},
botDelay: 1000,
botName: 'The bot',
bubbleOptionStyle: {},
bubbleStyle: {},
cache: false,
Expand Down
6 changes: 4 additions & 2 deletions lib/steps_components/text/TextStep.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,12 @@ class TextStep extends Component {
hideUserAvatar
} = this.props;
const { loading } = this.state;
const { avatar, user } = step;
const { avatar, user, botName } = step;

const showAvatar = user ? !hideUserAvatar : !hideBotAvatar;

const imageAltText = user ? "Your avatar" : `${botName}'s avatar`;

return (
<TextStepContainer className={`rsc-ts ${user ? 'rsc-ts-user' : 'rsc-ts-bot'}`} user={user}>
<ImageContainer className="rsc-ts-image-container" user={user}>
Expand All @@ -75,7 +77,7 @@ class TextStep extends Component {
showAvatar={showAvatar}
user={user}
src={avatar}
alt="avatar"
alt={imageAltText}
/>
)}
</ImageContainer>
Expand Down
18 changes: 0 additions & 18 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 9a02150

Please sign in to comment.