diff --git a/scm-ui/ui-components/src/__resources__/avatar.png b/scm-ui/ui-components/src/__resources__/avatar.png new file mode 100644 index 0000000000..71632a3a51 Binary files /dev/null and b/scm-ui/ui-components/src/__resources__/avatar.png differ diff --git a/scm-ui/ui-components/src/__snapshots__/storyshots.test.ts.snap b/scm-ui/ui-components/src/__snapshots__/storyshots.test.ts.snap index 0ec9bb0c76..17a73282c2 100644 --- a/scm-ui/ui-components/src/__snapshots__/storyshots.test.ts.snap +++ b/scm-ui/ui-components/src/__snapshots__/storyshots.test.ts.snap @@ -32389,6 +32389,272 @@ exports[`Storyshots Forms|Textarea OnSubmit 1`] = ` `; +exports[`Storyshots Layout|Footer Default 1`] = ` + +`; + +exports[`Storyshots Layout|Footer Full 1`] = ` + +`; + +exports[`Storyshots Layout|Footer With Avatar 1`] = ` + +`; + +exports[`Storyshots Layout|Footer With Plugin Links 1`] = ` + +`; + exports[`Storyshots Loading Default 1`] = `
= ({person, representation = "rounded-border"}) => { - const avatarFactory = binder.getExtension(EXTENSION_POINT); - if (avatarFactory) { - const avatar = avatarFactory(person); +const AvatarImage: FC = ({ person, representation = "rounded-border" }) => { + const binder = useBinder(); + const avatarFactory = binder.getExtension(EXTENSION_POINT); + if (avatarFactory) { + const avatar = avatarFactory(person); - const className = representation === "rounded" ? "is-rounded" : "has-rounded-border"; + const className = representation === "rounded" ? "is-rounded" : "has-rounded-border"; - return {person.name}; - } + return {person.name}; + } - return null; + return null; }; export default AvatarImage; diff --git a/scm-ui/ui-components/src/avatar/AvatarWrapper.tsx b/scm-ui/ui-components/src/avatar/AvatarWrapper.tsx index 09ed7391cf..695cb36064 100644 --- a/scm-ui/ui-components/src/avatar/AvatarWrapper.tsx +++ b/scm-ui/ui-components/src/avatar/AvatarWrapper.tsx @@ -1,18 +1,13 @@ -import React, { Component, ReactNode } from "react"; -import { binder } from "@scm-manager/ui-extensions"; +import React, { FC } from "react"; +import { useBinder } from "@scm-manager/ui-extensions"; import { EXTENSION_POINT } from "./Avatar"; -type Props = { - children: ReactNode; +const AvatarWrapper: FC = ({ children }) => { + const binder = useBinder(); + if (binder.hasExtension(EXTENSION_POINT)) { + return <>{children}; + } + return null; }; -class AvatarWrapper extends Component { - render() { - if (binder.hasExtension(EXTENSION_POINT)) { - return <>{this.props.children}; - } - return null; - } -} - export default AvatarWrapper; diff --git a/scm-ui/ui-components/src/layout/Footer.stories.tsx b/scm-ui/ui-components/src/layout/Footer.stories.tsx new file mode 100644 index 0000000000..a4f85bc4ef --- /dev/null +++ b/scm-ui/ui-components/src/layout/Footer.stories.tsx @@ -0,0 +1,56 @@ +import React from "react"; +import { storiesOf } from "@storybook/react"; +import Footer from "./Footer"; +import { Binder, BinderContext } from "@scm-manager/ui-extensions"; +import { Me } from "@scm-manager/ui-types"; +import { EXTENSION_POINT } from "../avatar/Avatar"; +// @ts-ignore ignore unknown png +import avatar from "../__resources__/avatar.png"; + +const trillian: Me = { + name: "trillian", + displayName: "Trillian McMillian", + mail: "tricia@hitchhiker.com", + groups: ["crew"], + _links: {} +}; + +const bindAvatar = (binder: Binder) => { + binder.bind(EXTENSION_POINT, () => { + return avatar; + }); +}; + +const bindLinks = (binder: Binder) => { + binder.bind("footer.links", () => REST API); + binder.bind("footer.links", () => CLI); +}; + +const withBinder = (binder: Binder) => { + return ( + +