@homebound/beam 2.256.1 → 2.256.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -10,7 +10,8 @@ function Avatar({ src, name, size = "md", showName = false, ...others }) {
|
|
|
10
10
|
const tid = (0, utils_1.useTestIds)(others, "avatar");
|
|
11
11
|
const px = sizeToPixel[size];
|
|
12
12
|
const [showFallback, setShowFallback] = (0, react_1.useState)(src === undefined);
|
|
13
|
-
|
|
13
|
+
// Define min-width as well as width to prevent the image from shrinking when displayed within a flex-child that allows shrinking.
|
|
14
|
+
const styles = Css_1.Css.br100.wPx(px).hPx(px).mwPx(px).overflowHidden.$;
|
|
14
15
|
const img = showFallback ? ((0, jsx_runtime_1.jsx)("div", { css: { ...styles, ...Css_1.Css[sizeToFallbackTypeScale[size]].bgGray400.gray100.df.aic.jcc.$ }, ...tid, children: name ? nameToInitials(name) : (0, jsx_runtime_1.jsx)(Icon_1.Icon, { icon: "userCircle", inc: sizeToIconInc[size] }) })) : ((0, jsx_runtime_1.jsx)("img", { src: src, alt: name, css: { ...styles, ...Css_1.Css.objectCover.$ }, onError: () => setShowFallback(true), loading: "lazy", ...tid }));
|
|
15
16
|
return showName && name ? ((0, jsx_runtime_1.jsxs)("div", { css: Css_1.Css.dif.aic.gap1.if(size === "lg" || size === "xl").fdc.$, children: [img, (0, jsx_runtime_1.jsx)("span", { css: Css_1.Css[sizeToTypeScale[size]].$, children: name })] })) : (img);
|
|
16
17
|
}
|