UNPKG

@gravity-ui/uikit

Version:

Gravity UI base styling and components

32 lines (31 loc) 1.99 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Avatar = void 0; const tslib_1 = require("tslib"); const jsx_runtime_1 = require("react/jsx-runtime"); const React = tslib_1.__importStar(require("react")); const filterDOMProps_1 = require("../utils/filterDOMProps.js"); const AvatarIcon_1 = require("./AvatarIcon/index.js"); const AvatarImage_1 = require("./AvatarImage/index.js"); const AvatarText_1 = require("./AvatarText/index.js"); const constants_1 = require("./constants.js"); require("./Avatar.css"); exports.Avatar = React.forwardRef((props, ref) => { const { size = constants_1.DEFAULT_AVATAR_SIZE, theme = 'normal', view = 'filled', backgroundColor, borderColor, title, className, style: styleProp, qa, } = props; const style = { backgroundColor, color: borderColor, ...styleProp }; const renderContent = () => { if ('imgUrl' in props && props.imgUrl) { return ((0, jsx_runtime_1.jsx)(AvatarImage_1.AvatarImage, { imgUrl: props.imgUrl, fallbackImgUrl: props.fallbackImgUrl, sizes: props.sizes, srcSet: props.srcSet, alt: props.alt || title, loading: props.loading, withImageBorder: props.withImageBorder, size: size })); } if ('icon' in props && props.icon) { return (0, jsx_runtime_1.jsx)(AvatarIcon_1.AvatarIcon, { icon: props.icon, color: props.color, size: size }); } if ('text' in props && props.text) { return (0, jsx_runtime_1.jsx)(AvatarText_1.AvatarText, { text: props.text, color: props.color, size: size }); } return null; }; return ((0, jsx_runtime_1.jsx)("div", { className: (0, constants_1.bAvatar)({ size, theme, view, 'with-border': Boolean(borderColor) }, className), title: title, role: "img", style: style, "data-qa": qa, ref: ref, ...(0, filterDOMProps_1.filterDOMProps)(props, { labelable: true }), children: renderContent() })); }); exports.Avatar.displayName = 'Avatar'; //# sourceMappingURL=Avatar.js.map