Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions frontend/components/CommentBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ import type { Comment } from '../types';

export interface CommentBoxProps {
comment: Comment;
username?: string;
username?: string; // TODO: Pass username into CommentBox and make it required
showThreadLine: boolean;
}

function formatDate(dateString: string): string {
Expand Down Expand Up @@ -62,7 +63,7 @@ function formatDate(dateString: string): string {

const DEFAULT_MAX_LENGTH = 200;

export function CommentBox({ comment, username }: CommentBoxProps) {
export function CommentBox({ comment, username, showThreadLine }: CommentBoxProps) {
const theme = useTheme();
const [isExpanded, setIsExpanded] = useState(false);
const [isLiked, setIsLiked] = useState(false);
Expand Down Expand Up @@ -94,13 +95,15 @@ export function CommentBox({ comment, username }: CommentBoxProps) {
size={32}
backgroundColor={isAnonymous ? theme.colors.orange100 : theme.colors.gray300}
/>
<Pane
width={2}
flex={1}
minHeight={20}
marginTop={majorScale(1)}
backgroundColor={theme.colors.gray200}
/>
{showThreadLine && (
<Pane
width={2}
flex={1}
minHeight={20}
marginTop={majorScale(1)}
backgroundColor={theme.colors.gray200}
/>
)}
</Pane>

{/* Comment content */}
Expand Down
27 changes: 27 additions & 0 deletions frontend/components/CommentsPanel.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
'use client';

import React from 'react';

import { Pane } from 'evergreen-ui';

import { CommentBox } from './CommentBox';

import type { Comment } from '../api/commentService';

type CommentsPanelProps = {
comments: Comment[];
};

const CommentsPanel: React.FC<CommentsPanelProps> = ({ comments }) => {
return (
<Pane className='comments-panel flex flex-col gap-6'>
{comments.map((comment, idx) => (
<Pane key={comment.id}>
<CommentBox comment={comment} showThreadLine={idx < comments.length - 1} />
</Pane>
))}
</Pane>
);
};

export default CommentsPanel;
Loading