From d4537c033080e5f8468bd9dccdafee05393d91db Mon Sep 17 00:00:00 2001 From: Sebastian Sdorra Date: Tue, 16 Jun 2020 10:05:11 +0200 Subject: [PATCH] added avatar support --- scm-ui/ui-components/src/Annotate.stories.tsx | 15 ++++++++++++++- scm-ui/ui-components/src/Annotate.tsx | 19 ++++++++++++++++--- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/scm-ui/ui-components/src/Annotate.stories.tsx b/scm-ui/ui-components/src/Annotate.stories.tsx index cecb85ee79..64afc0cca9 100644 --- a/scm-ui/ui-components/src/Annotate.stories.tsx +++ b/scm-ui/ui-components/src/Annotate.stories.tsx @@ -23,11 +23,13 @@ */ import { storiesOf } from "@storybook/react"; -import * as React from "react"; +import React, { FC } from "react"; import styled from "styled-components"; import Annotate, { AnnotatedSource } from "./Annotate"; import { MemoryRouter } from "react-router-dom"; import repository from "./__resources__/repository"; +import { Binder, BinderContext } from "@scm-manager/ui-extensions"; +import { Person } from "./avatar/Avatar"; const Wrapper = styled.div` margin: 2rem; @@ -109,9 +111,20 @@ const source: AnnotatedSource = { ] }; +const Robohash: FC = ({ children }) => { + const binder = new Binder("robohash"); + binder.bind("avatar.factory", (person: Person) => `https://robohash.org/${person.mail}.png`); + return {children}; +}; + storiesOf("Annotate", module) .addDecorator(storyFn => {storyFn()}) .addDecorator(storyFn => {storyFn()}) .add("Default", () => ( + )) + .add("With Avatars", () => ( + + + )); diff --git a/scm-ui/ui-components/src/Annotate.tsx b/scm-ui/ui-components/src/Annotate.tsx index 490c3de82d..3cf25630dd 100644 --- a/scm-ui/ui-components/src/Annotate.tsx +++ b/scm-ui/ui-components/src/Annotate.tsx @@ -34,6 +34,7 @@ import { SingleContributor } from "./repos/changesets"; import DateFromNow from "./DateFromNow"; import { Link } from "react-router-dom"; import { DateInput } from "./dates"; +import { AvatarImage } from "./avatar"; // TODO move types to ui-types @@ -198,11 +199,14 @@ const Popover: FC = ({ annotation, offsetTop, repository, baseDate ref={ref} onMouseEnter={onMouseEnter} onMouseLeave={OnMouseLeave} - className="box changeset-details is-family-primary" + className="box" style={{ top: `${top}px` }} > - + + + + @@ -229,6 +233,12 @@ const dispatchDeferred = (dispatch: Dispatch, action: Action) => { setTimeout(() => dispatch(action), 250); }; +const AuthorImage = styled(AvatarImage)` + width: 1em; + height: 1em; + margin-right: 0.2em; +`; + const AnnotateLine: FC = ({ annotation, showAnnotation, dispatch, nr, children }) => { const link = useRef(null); @@ -264,7 +274,10 @@ const AnnotateLine: FC = ({ annotation, showAnnotation, dispatch, nr, return ( - {annotation.author.name}{" "} + + + {annotation.author.name} + {" "} {" "}