File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed
Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -29,6 +29,16 @@ const CAMERA_ICON_SIZE = {
2929 xxl : '24px' ,
3030} ;
3131
32+ const getInitials = ( firstName ? : string , lastName ? : string ) : string => {
33+ if ( firstName && lastName ) return firstName . slice ( 0 , 1 ) + lastName . slice ( 0 , 1 ) ;
34+
35+ if ( firstName && ! lastName ) return firstName . slice ( 0 , 1 ) ;
36+
37+ if ( ! firstName && lastName ) return lastName . slice ( 0 , 1 ) ;
38+
39+ return DEFAULT_INITIALS ;
40+ } ;
41+
3242function Avatar ( {
3343 src,
3444 firstName,
@@ -38,7 +48,7 @@ function Avatar({
3848 pickVariant,
3949 ...rest
4050} : AvatarProps ) {
41- const initials = firstName && lastName ? firstName . slice ( 0 , 1 ) + lastName . slice ( 0 , 1 ) : DEFAULT_INITIALS ;
51+ const initials = getInitials ( firstName , lastName ) ;
4252
4353 return (
4454 < AvatarTag pickVariant = { pickVariant } { ...rest } firstName = { firstName } tagName = "div" >
You can’t perform that action at this time.
0 commit comments