@selfcommunity/react-ui
Version:
React UI Components to integrate a Community created with SelfCommunity Platform.
40 lines (39 loc) • 1.73 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const jsx_runtime_1 = require("react/jsx-runtime");
const styles_1 = require("@mui/material/styles");
const system_1 = require("@mui/system");
const material_1 = require("@mui/material");
const classnames_1 = tslib_1.__importDefault(require("classnames"));
const ParticipantPlaceholder_1 = tslib_1.__importDefault(require("./ParticipantPlaceholder"));
const react_core_1 = require("@selfcommunity/react-core");
const PREFIX = 'SCParticipantTileAvatar';
const classes = {
root: `${PREFIX}-root`
};
const Root = (0, styles_1.styled)(material_1.Box, {
name: PREFIX,
slot: 'Root',
overridesResolver: (props, styles) => styles.root
})(({ theme }) => ({
height: 'auto !important',
'& img': {
borderRadius: '50%',
width: 100,
height: 100
}
}));
function ParticipantTileAvatar(inProps) {
// PROPS
const props = (0, system_1.useThemeProps)({
props: inProps,
name: PREFIX
});
const { className, user, participant } = props, rest = tslib_1.__rest(props, ["className", "user", "participant"]);
// CONTEXT
const scContext = (0, react_core_1.useSCContext)();
// RENDER
return ((0, jsx_runtime_1.jsx)(Root, Object.assign({ className: (0, classnames_1.default)(className, classes.root) }, rest, { children: user ? ((0, jsx_runtime_1.jsx)("img", { src: `${user.avatar}` })) : participant && participant.identity ? ((0, jsx_runtime_1.jsx)("img", { src: `${scContext.settings.portal}/api/v2/avatar/${participant.identity}` })) : ((0, jsx_runtime_1.jsx)(ParticipantPlaceholder_1.default, {})) })));
}
exports.default = ParticipantTileAvatar;
;