77
88import React from 'react' ;
99import PropTypes from 'prop-types' ;
10- import { StyledAvatar , StyledBadge } from './styled' ;
10+ import { StyledAvatar } from './styled' ;
1111
1212const SIZE = {
1313 EXTRASMALL : 'extrasmall' ,
@@ -27,40 +27,28 @@ const STATUS = {
2727const Avatar = ( { isSystem, size, status, children, badge, ...other } ) => {
2828 let computedStatus = status ;
2929
30- if ( status === STATUS . AVAILABLE && badge !== undefined ) {
30+ if ( status === STATUS . AVAILABLE && badge ) {
3131 computedStatus = STATUS . ACTIVE ;
3232 }
3333
34- const FormattedBadge = ( ) => {
35- if ( status === undefined || status === STATUS . AWAY ) {
36- return null ;
37- }
38-
39- if ( computedStatus === STATUS . AVAILABLE ) {
40- return < StyledBadge /> ;
41- }
42-
43- return < StyledBadge > { badge } </ StyledBadge > ;
44- } ;
45-
4634 return (
4735 < StyledAvatar
4836 isSystem = { isSystem }
4937 size = { size }
5038 status = { computedStatus }
39+ data-badge = { badge }
5140 aria-live = "polite"
5241 { ...other }
5342 >
5443 { children }
55- < FormattedBadge />
5644 </ StyledAvatar >
5745 ) ;
5846} ;
5947
6048Avatar . propTypes = {
6149 /** Applies system styling */
6250 isSystem : PropTypes . bool ,
63- badge : PropTypes . node ,
51+ badge : PropTypes . oneOf ( [ PropTypes . string , PropTypes . number ] ) ,
6452 size : PropTypes . oneOf ( [ SIZE . EXTRASMALL , SIZE . SMALL , SIZE . LARGE ] ) ,
6553 status : PropTypes . oneOf ( [ STATUS . AVAILABLE , STATUS . AWAY ] ) ,
6654 children : PropTypes . node
0 commit comments