import type { EuiAvatarProps } from '@elastic/eui' ; import { EuiAvatar , isValidHex } from '@elastic/eui' ; import type { FC } from 'react' ; import React from 'react' ; import { MAX_SPACE_INITIALS } from '../../common' ; import { getSpaceColor , getSpaceImageUrl , getSpaceInitials } from './space_attributes' ; import type { SpaceAvatarProps } from './types' ; export const SpaceAvatarInternal = ( props ) => { const { space , size , announceSpaceName , ... rest } = props ; const spaceName = space . name ? space . name . trim ( ) : '' ; const spaceColor = getSpaceColor ( space ) ; const spaceInitials = getSpaceInitials ( space ) ; const spaceImageUrl = getSpaceImageUrl ( space ) ; const avatarConfig = spaceImageUrl ? { imageUrl : spaceImageUrl } : { initials : spaceInitials , initialsLength : MAX_SPACE_INITIALS } ; return ( < EuiAvatar type = "space" data - test - subj = { `space-avatar-${ space . id }` } name = { spaceName } { ... ( ! announceSpaceName && { 'aria-label' : '' , 'aria-hidden' : true , } ) } size = { size || 'm' } color = { isValidHex ( spaceColor ) ? spaceColor : '' } { ... avatarConfig } { ... rest } />); } ; SpaceAvatarInternal . defaultProps = { announceSpaceName : true , } ;