Skip to content

Commit c545b47

Browse files
committed
Style comments and use avatars
1 parent 71c4b3c commit c545b47

4 files changed

Lines changed: 63 additions & 37 deletions

File tree

app/lib/comment-item.tsx

Lines changed: 37 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ const CommentItem_CommentFragment = gql(/* GraphQL */ `
1818
profile {
1919
id
2020
username
21+
avatarUrl
2122
}
2223
}
2324
`);
@@ -49,26 +50,43 @@ export function CommentItem(props: {
4950
}
5051
}, [deleteCommentMutation.data]);
5152
return (
52-
<div className="pb-4">
53-
<div className="text-sm">
54-
<Link href={`/profile/${props.comment.profile?.id}`}>
55-
<a className="font-bold">{props.comment.profile?.username} </a>
56-
</Link>
57-
<span>{createdAt}</span>
58-
{user?.id && user.id === props.comment.profile?.id ? (
59-
<button
60-
className="ml-2 text-xs text-gray-400 hover:text-gray-900"
61-
onClick={() => {
62-
deleteComment({
63-
commentId: props.comment.id,
64-
});
65-
}}
66-
>
67-
delete
68-
</button>
69-
) : null}
53+
<div className="flex space-x-3 py-4">
54+
<img
55+
className="h-6 w-6 rounded-full"
56+
src={props.comment.profile?.avatarUrl}
57+
alt=""
58+
/>
59+
<div className="flex-1 space-y-1">
60+
<div className="flex items-center justify-between">
61+
<h3 className="text-sm font-medium">
62+
{props.comment.profile?.username}
63+
</h3>
64+
<p className="text-sm text-gray-500">{createdAt}</p>
65+
</div>
66+
<p className="text-sm text-gray-500">{props.comment.message}</p>
7067
</div>
71-
<div className="flex-1 md:flex-grow">{props.comment.message}</div>
7268
</div>
69+
70+
// <div className="pb-4">
71+
// <div className="text-sm">
72+
// <Link href={`/profile/${props.comment.profile?.id}`}>
73+
// <a className="font-bold">{props.comment.profile?.username} </a>
74+
// </Link>
75+
// <span>{createdAt}</span>
76+
// {user?.id && user.id === props.comment.profile?.id ? (
77+
// <button
78+
// className="ml-2 text-xs text-gray-400 hover:text-gray-900"
79+
// onClick={() => {
80+
// deleteComment({
81+
// commentId: props.comment.id,
82+
// });
83+
// }}
84+
// >
85+
// delete
86+
// </button>
87+
// ) : null}
88+
// </div>
89+
// <div className="flex-1 md:flex-grow">{props.comment.message}</div>
90+
// </div>
7391
);
7492
}

app/lib/feed-item.tsx

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ const FeedItem_PostFragment = gql(/* GraphQL */ `
141141
profile {
142142
id
143143
username
144+
avatarUrl
144145
}
145146
...VoteButtons_PostFragment
146147
...DeleteButton_PostFragment
@@ -161,7 +162,7 @@ export function FeedItem(props: {
161162
<div className="flex-1 md:flex-grow">
162163
<Link href={props.post.url}>
163164
<a>
164-
<h2 className="text-2xl font-medium text-gray-900 title-font mb-2">
165+
<h2 className="text-2xl font-medium text-gray-900 hover:text-green-500 title-font mb-2">
165166
{props.post.title}
166167
</h2>
167168
</a>
@@ -174,7 +175,7 @@ export function FeedItem(props: {
174175
{props.post.voteTotal === 1 ? "point" : "points"}
175176
</span>
176177
<Link href={`/item/${props.post.id}`}>
177-
<a className="text-gray-400 mr-3 inline-flex items-center text-sm pr-3 py-1 border-r-2 border-gray-200">
178+
<a className="text-gray-400 hover:text-green-400 mr-3 inline-flex items-center text-sm pr-3 py-1 border-r-2 border-gray-200">
178179
<CommentIcon className="w-4 h-4 mr-1" />
179180
{props.post.commentCollection?.totalCount}{" "}
180181
{props.post.commentCollection?.totalCount === 1
@@ -183,13 +184,16 @@ export function FeedItem(props: {
183184
</a>
184185
</Link>
185186
<Link href={`/profile/${props.post.profile?.id}`}>
186-
<a className="text-gray-400 mr-3 inline-flex items-center text-sm pr-3 py-1 border-r-2 border-gray-200">
187-
<UserIcon className="w-4 h-4 mr-1" />
187+
<a className="text-gray-400 hover:text-green-400 mr-3 inline-flex items-center text-sm pr-3 py-1 border-r-2 border-gray-200">
188+
<img
189+
className="inline-block h-4 w-4 rounded-full w-4 h-4 mr-1"
190+
src={props.post.profile?.avatarUrl}
191+
/>
188192
{props.post.profile?.username}
189193
</a>
190194
</Link>
191195
<Link href={`/item/${props.post.id}`}>
192-
<a className="text-gray-400 inline-flex items-center text-sm">
196+
<a className="text-gray-400 hover:text-green-400 inline-flex items-center text-sm">
193197
<CalendarIcon className="w-4 h-4 mr-1" />
194198
{createdAt}
195199
</a>
@@ -235,7 +239,7 @@ const DeleteButton = (props: {
235239
return (
236240
<>
237241
<button
238-
className="text-gray-400 inline-flex items-center text-sm pl-3 ml-3 border-l-2 border-gray-200"
242+
className="text-gray-400 hover:text-green-400 inline-flex items-center text-sm pl-3 ml-3 border-l-2 border-gray-200"
239243
onClick={() => setShow(true)}
240244
>
241245
<TrashIcon className="w-4 h-4 mr-1" />

app/lib/icons.tsx

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -51,18 +51,13 @@ export function CommentIcon(props: { className?: string }) {
5151

5252
export function PointIcon(props: { className?: string }) {
5353
return (
54-
<svg
55-
viewBox="0 0 24 24"
56-
className="w-4 h-4 mr-1"
57-
stroke="currentColor"
58-
strokeWidth="2"
59-
fill="none"
60-
strokeLinecap="round"
61-
strokeLinejoin="round"
62-
{...props}
63-
>
64-
<path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"></path>
65-
<circle cx="12" cy="12" r="3"></circle>
54+
<svg viewBox="0 0 24 24" stroke="currentColor" fill="none" {...props}>
55+
<path
56+
strokeLinecap="round"
57+
strokeLinejoin="round"
58+
strokeWidth="2"
59+
d="M13 10V3L4 14h7v7l9-11h-7z"
60+
></path>
6661
</svg>
6762
);
6863
}

app/pages/profile/[profileId].tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ const ProfileRouteQuery = gql(/* GraphQL */ `
1616
id
1717
username
1818
bio
19+
avatarUrl
1920
website
2021
latestPosts: postCollection(
2122
orderBy: [{ createdAt: DescNullsFirst }]
@@ -81,12 +82,20 @@ const Profile: NextPage = () => {
8182
<span className="inline-block font-bold pr-2 w-20">User</span>{" "}
8283
{profile.username}
8384
</div>
85+
<div>
86+
<span className="inline-block font-bold pr-2 w-20">Avatar</span>{" "}
87+
<img
88+
className="inline-block h-6 w-6 rounded-full"
89+
src={profile.avatarUrl}
90+
/>
91+
</div>
8492
<div>
8593
<span className="inline-block font-bold pr-2 w-20">
8694
Website
8795
</span>{" "}
8896
{profile.website}
8997
</div>
98+
9099
<div className="mb-10">
91100
<span className="inline-block font-bold pr-2 w-20">Bio</span>{" "}
92101
{profile.bio}

0 commit comments

Comments
 (0)