From 71af95cc8aa352f82d9b1570f40343786616535a Mon Sep 17 00:00:00 2001 From: Germain Date: Wed, 9 Aug 2023 15:21:32 +0100 Subject: [PATCH] Allow passing style attribute down to Avatar component --- src/components/Avatar/Avatar.tsx | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/components/Avatar/Avatar.tsx b/src/components/Avatar/Avatar.tsx index 1616b31a..5e7c6fba 100644 --- a/src/components/Avatar/Avatar.tsx +++ b/src/components/Avatar/Avatar.tsx @@ -38,15 +38,13 @@ export const Avatar = forwardRef(function Avatar( type = "round", className = "", size, + style = {}, onError, ...props }, ref, ) { const hash = useIdColorHash(id); - const style = { - "--cpd-avatar-size": size, - } as React.CSSProperties; const fallbackInitial = <>{getInitialLetter(name)}; return ( @@ -59,7 +57,12 @@ export const Avatar = forwardRef(function Avatar( data-type={type} data-color={hash} className={classnames(styles.avatar, className)} - style={style} + style={ + { + ...style, + "--cpd-avatar-size": size, + } as React.CSSProperties + } > {!src ? ( fallbackInitial