@etsoo/materialui
Version:
TypeScript Material-UI Implementation
26 lines (25 loc) • 786 B
JavaScript
import { jsx as _jsx } from "react/jsx-runtime";
import { BusinessUtils } from "@etsoo/appscript";
import { useAppContext } from "./app/ReactApp";
import Avatar from "@mui/material/Avatar";
/**
* User avatar
* @param props Props
* @returns Component
*/
export function UserAvatar(props) {
// Global app
const app = useAppContext();
// Destruct
const { src, title, formatTitle = (title) => {
return BusinessUtils.formatAvatarTitle(title, 3, app?.get("me") ?? "ME");
} } = props;
// Format
const fTitle = formatTitle(title);
const count = fTitle.length;
return (_jsx(Avatar, { title: title, src: src, sx: {
width: 48,
height: 32,
fontSize: count <= 2 ? "15px" : "12px"
}, children: fTitle }));
}