This repository has been archived by the owner on May 24, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 166
[terra-avatar] Changed fallback to initials from user icon for avatar #2621
Merged
Merged
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
9b6a5d4
Changed fallback to initials for avatar
supreethmr 9382491
Merge branch 'master' into Added_Initial_fallback
supreethmr 3e9cb4c
Merge branch 'master' into Added_Initial_fallback
supreethmr 565f141
changes of Code review comment
supreethmr 706b591
Made Initials as Required Prop
supreethmr 84c6038
Merge branch 'master' into Added_Initial_fallback
supreethmr 32352b5
Merge branch 'master' into Added_Initial_fallback
supreethmr 9a25680
added role to initials so that screen reader reads the both intials a…
supreethmr 197e280
Merge branch 'master' into Added_Initial_fallback
supreethmr 919d7f4
Merge branch 'master' into Added_Initial_fallback
supreethmr 4698f86
screenshot update
supreethmr 64b7c72
Update packages/terra-avatar/docs/avatar.md
supreethmr e7b8744
removed obselete snapshots
supreethmr ce1f8fe
Removing Tests which were not required with new changes
supreethmr d8098a5
Merge branch 'master' into Added_Initial_fallback
ryanthemanuel 87fde47
Merge branch 'master' into Added_Initial_fallback
supreethmr 9c50d3a
Update CONTRIBUTORS.md
jeremyfuksa 05df907
Merge remote-tracking branch 'origin/master' into Added_Initial_fallback
rm012685 21fdee0
Merge branch 'master' into Added_Initial_fallback
ryanthemanuel be42bf4
Merge branch 'master' into Added_Initial_fallback
ryanthemanuel 900a3fd
Fix tests
rm012685 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
...erra-avatar/src/terra-dev-site/test/avatar/avatar/InvalidImageAvatarWithInitials.test.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import React from 'react'; | ||
import Avatar from '../../../../index'; | ||
|
||
export default () => <Avatar image="invalid-image-url" initials="JD" alt="User" id="invalid-image-avatar" />; |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -86,8 +86,8 @@ class Avatar extends React.Component { | |
let avatarContent; | ||
|
||
if (image) { | ||
avatarContent = generateImage(image, alt, isAriaHidden, AVATAR_VARIANTS.USER, this.handleFallback); | ||
} else if (initials && (initials.length === 1 || initials.length === 2)) { | ||
avatarContent = generateImage(image, alt, isAriaHidden, AVATAR_VARIANTS.USER, this.handleFallback, initials); | ||
} else if (initials && initials.length <= 2) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just curious, could these redundant checks be probably avoided if the default value of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Redundant checks have been removed and validating this only at generateImagePlaceholder function : here |
||
const avatarTextClassNames = cx('initials'); | ||
avatarContent = <span className={avatarTextClassNames} alt={alt} aria-label={alt} aria-hidden={isAriaHidden}>{initials.toUpperCase()}</span>; | ||
yuderekyu marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} else { | ||
yuderekyu marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+1.41 KB
.../chrome_huge/avatar-common-spec/Invalid_Image_Avatar_With_Initials[default].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe saying 'Changed the load behavior such that if the image fails to load and initials are provided, the avatar falls back to the initials display.' is more clear to a consumer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated here