@selfcommunity/react-ui
Version:
React UI Components to integrate a Community created with SelfCommunity Platform.
37 lines (36 loc) • 1.39 kB
JavaScript
import { __rest } from "tslib";
import { jsx as _jsx } from "react/jsx-runtime";
import { styled } from '@mui/material/styles';
import { useThemeProps } from '@mui/system';
import { Box } from '@mui/material';
import classNames from 'classnames';
import ParticipantPlaceholder from './ParticipantPlaceholder';
import { useSCContext } from '@selfcommunity/react-core';
const PREFIX = 'SCParticipantTileAvatar';
const classes = {
root: `${PREFIX}-root`
};
const Root = styled(Box, {
name: PREFIX,
slot: 'Root',
overridesResolver: (props, styles) => styles.root
})(({ theme }) => ({
height: 'auto !important',
'& img': {
borderRadius: '50%',
width: 100,
height: 100
}
}));
export default function ParticipantTileAvatar(inProps) {
// PROPS
const props = useThemeProps({
props: inProps,
name: PREFIX
});
const { className, user, participant } = props, rest = __rest(props, ["className", "user", "participant"]);
// CONTEXT
const scContext = useSCContext();
// RENDER
return (_jsx(Root, Object.assign({ className: classNames(className, classes.root) }, rest, { children: user ? (_jsx("img", { src: `${user.avatar}` })) : participant && participant.identity ? (_jsx("img", { src: `${scContext.settings.portal}/api/v2/avatar/${participant.identity}` })) : (_jsx(ParticipantPlaceholder, {})) })));
}