Working comment history, styling in progress

This commit is contained in:
Belén Curcio
2018-09-14 12:37:25 -03:00
parent ced45a914c
commit f391d7b7ad
4 changed files with 40 additions and 3 deletions
@@ -1,14 +1,23 @@
import * as React from "react";
import { StatelessComponent } from "react";
import { CommentHistoryContainer_me as MeData } from "talk-stream/__generated__/CommentHistoryContainer_me.graphql";
import { HorizontalGutter } from "talk-ui/components";
import { HorizontalGutter, Typography } from "talk-ui/components";
import HistoryComment from "./HistoryComment";
export interface CommentHistoryProps {
me: MeData;
}
const CommentHistory: StatelessComponent<CommentHistoryProps> = props => {
return <HorizontalGutter size="double">Comments</HorizontalGutter>;
const comments = props.me.comments.edges.map(edge => edge.node);
return (
<HorizontalGutter size="double">
<Typography variant="heading3">Comment History</Typography>
{comments.map(comment => (
<HistoryComment key={comment.id} comment={comment} />
))}
</HorizontalGutter>
);
};
export default CommentHistory;
@@ -0,0 +1,26 @@
import * as React from "react";
import { StatelessComponent } from "react";
import { Flex, RelativeTime, Typography } from "talk-ui/components";
import HTMLContent from "../../../components/HTMLContent";
export interface CommentHistoryProps {
comment: {
body: string | null;
createdAt: string;
};
}
const HistoryComment: StatelessComponent<CommentHistoryProps> = props => {
return (
<Flex>
<Typography variant="bodyCopy">
{props.comment.body && <HTMLContent>{props.comment.body}</HTMLContent>}
</Typography>
<div>
<RelativeTime date={props.comment.createdAt} />
</div>
</Flex>
);
};
export default HistoryComment;
@@ -25,6 +25,8 @@ const enhanced = withFragmentContainer<CommentHistoryContainerProps>({
node {
id
body
createdAt
replyCount
}
}
}
@@ -2,7 +2,7 @@ import { GQLUserTypeResolver } from "talk-server/graph/tenant/schema/__generated
import { User } from "talk-server/models/User";
const User: GQLUserTypeResolver<User> = {
comments: (asset, input, ctx) =>
comments: (_, input, ctx) =>
ctx.user ? ctx.loaders.Comments.forUser(ctx.user.id, input) : [],
};