Add forward ref in avatar component
Signed-off-by: Ajay Bura <ajbura@gmail.com>
This commit is contained in:
parent
8f41139076
commit
faaac72b81
1 changed files with 4 additions and 4 deletions
|
@ -10,16 +10,16 @@ import RawIcon from '../system-icons/RawIcon';
|
||||||
import ImageBrokenSVG from '../../../../public/res/svg/image-broken.svg';
|
import ImageBrokenSVG from '../../../../public/res/svg/image-broken.svg';
|
||||||
import { avatarInitials } from '../../../util/common';
|
import { avatarInitials } from '../../../util/common';
|
||||||
|
|
||||||
function Avatar({
|
const Avatar = React.forwardRef(({
|
||||||
text, bgColor, iconSrc, iconColor, imageSrc, size,
|
text, bgColor, iconSrc, iconColor, imageSrc, size,
|
||||||
}) {
|
}, ref) => {
|
||||||
let textSize = 's1';
|
let textSize = 's1';
|
||||||
if (size === 'large') textSize = 'h1';
|
if (size === 'large') textSize = 'h1';
|
||||||
if (size === 'small') textSize = 'b1';
|
if (size === 'small') textSize = 'b1';
|
||||||
if (size === 'extra-small') textSize = 'b3';
|
if (size === 'extra-small') textSize = 'b3';
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={`avatar-container avatar-container__${size} noselect`}>
|
<div ref={ref} className={`avatar-container avatar-container__${size} noselect`}>
|
||||||
{
|
{
|
||||||
imageSrc !== null
|
imageSrc !== null
|
||||||
? (
|
? (
|
||||||
|
@ -50,7 +50,7 @@ function Avatar({
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
});
|
||||||
|
|
||||||
Avatar.defaultProps = {
|
Avatar.defaultProps = {
|
||||||
text: null,
|
text: null,
|
||||||
|
|
Loading…
Reference in a new issue