move changesets and avatar components to ui-components

This commit is contained in:
Sebastian Sdorra
2018-12-10 08:45:59 +01:00
parent 8d622f548d
commit 97c4b0998b
18 changed files with 74 additions and 47 deletions

View File

@@ -0,0 +1,8 @@
// @flow
export type Person = {
name: string,
mail?: string
};
export const EXTENSION_POINT = "avatar.factory";

View File

@@ -0,0 +1,34 @@
//@flow
import React from "react";
import {binder} from "@scm-manager/ui-extensions";
import {Image} from "..";
import type { Person } from "./Avatar";
import { EXTENSION_POINT } from "./Avatar";
type Props = {
person: Person
};
class AvatarImage extends React.Component<Props> {
render() {
const { person } = this.props;
const avatarFactory = binder.getExtension(EXTENSION_POINT);
if (avatarFactory) {
const avatar = avatarFactory(person);
return (
<Image
className="has-rounded-border"
src={avatar}
alt={person.name}
/>
);
}
return null;
}
}
export default AvatarImage;

View File

@@ -0,0 +1,19 @@
//@flow
import * as React from "react";
import {binder} from "@scm-manager/ui-extensions";
import { EXTENSION_POINT } from "./Avatar";
type Props = {
children: React.Node
};
class AvatarWrapper extends React.Component<Props> {
render() {
if (binder.hasExtension(EXTENSION_POINT)) {
return <>{this.props.children}</>;
}
return null;
}
}
export default AvatarWrapper;

View File

@@ -0,0 +1,4 @@
// @flow
export { default as AvatarWrapper } from "./AvatarWrapper";
export { default as AvatarImage } from "./AvatarImage";