added option to pass className prop to AvatarImage

This commit is contained in:
Sebastian Sdorra
2020-02-19 13:34:30 +01:00
parent bd57acf138
commit a83ef175be

View File

@@ -7,17 +7,21 @@ import { useBinder } from "@scm-manager/ui-extensions";
type Props = { type Props = {
person: Person; person: Person;
representation?: "rounded" | "rounded-border"; representation?: "rounded" | "rounded-border";
className?: string;
}; };
const AvatarImage: FC<Props> = ({ person, representation = "rounded-border" }) => { const AvatarImage: FC<Props> = ({ person, representation = "rounded-border", className }) => {
const binder = useBinder(); const binder = useBinder();
const avatarFactory = binder.getExtension(EXTENSION_POINT); const avatarFactory = binder.getExtension(EXTENSION_POINT);
if (avatarFactory) { if (avatarFactory) {
const avatar = avatarFactory(person); const avatar = avatarFactory(person);
const className = representation === "rounded" ? "is-rounded" : "has-rounded-border"; let classes = representation === "rounded" ? "is-rounded" : "has-rounded-border";
if (className) {
classes += " " + className;
}
return <Image className={className} src={avatar} alt={person.name} />; return <Image className={classes} src={avatar} alt={person.name} />;
} }
return null; return null;