From 0703bd1bb85a508327f64808df96de3d0df99e03 Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Mon, 16 Feb 2026 01:16:25 +0000 Subject: [PATCH] feat: migrate CommentComponent from Angular to React - Create Comment.types.ts with Comment interface and CommentProps - Create Comment.tsx with useState hook, React Router Link, recursive rendering - Create Comment.module.scss with migrated styles (removed :host >>> selector, inlined SCSS variables) Co-Authored-By: Jenna Mansueto --- src/components/Comment/Comment.module.scss | 83 ++++++++++++++++++++++ src/components/Comment/Comment.tsx | 49 +++++++++++++ src/components/Comment/Comment.types.ts | 14 ++++ 3 files changed, 146 insertions(+) create mode 100644 src/components/Comment/Comment.module.scss create mode 100644 src/components/Comment/Comment.tsx create mode 100644 src/components/Comment/Comment.types.ts diff --git a/src/components/Comment/Comment.module.scss b/src/components/Comment/Comment.module.scss new file mode 100644 index 00000000..f7a974b1 --- /dev/null +++ b/src/components/Comment/Comment.module.scss @@ -0,0 +1,83 @@ +$mobile-only: "only screen and (max-width : 768px)"; +$tablet-only: "only screen and (max-width : 1024px)"; + +a { + font-weight: bold; + text-decoration: none; + &:hover { + text-decoration: underline; + } +} + +.meta { + font-size: 13px; + color: #696969; + font-weight: bold; + letter-spacing: 0.5px; + margin-bottom: 8px; + a { + text-decoration: none; + + &:hover { + text-decoration: underline; + } + } + .time { + padding-left: 5px; + } +} + +@media #{$mobile-only} { + .meta { + font-size: 14px; + margin-bottom: 10px; + .time { + padding: 0; + float: right; + } + } +} + +.meta-collapse { + margin-bottom: 20px; +} + +.deleted-meta { + font-size: 12px; + font-weight: bold; + letter-spacing: 0.5px; + margin: 30px 0; + a { + text-decoration: none; + } +} + +.collapse { + font-size: 13px; + letter-spacing: 2px; + cursor: pointer; +} + +.comment-tree { + margin-left: 24px; +} + +@media #{$tablet-only} { + .comment-tree { + margin-left: 8px; + } +} + +.comment-text { + font-size: 15px; + margin-top: 0; + margin-bottom: 20px; + word-wrap: break-word; + line-height: 1.5em; +} + +.subtree { + margin-left: 0; + padding: 0; + list-style-type: none; +} diff --git a/src/components/Comment/Comment.tsx b/src/components/Comment/Comment.tsx new file mode 100644 index 00000000..8a84e584 --- /dev/null +++ b/src/components/Comment/Comment.tsx @@ -0,0 +1,49 @@ +import React, { useState } from 'react'; +import { Link } from 'react-router-dom'; +import { CommentProps } from './Comment.types'; +import styles from './Comment.module.scss'; + +const Comment: React.FC = ({ comment }) => { + const [collapse, setCollapse] = useState(false); + + if (comment.deleted) { + return ( +
+
+ [deleted] | Comment Deleted +
+
+ ); + } + + return ( +
+
+ setCollapse(!collapse)}> + [{collapse ? '+' : '-'}] + {' '} + {comment.user} + {comment.time_ago} +
+
+ {!collapse && ( +
+

+

    + {comment.comments.map((subComment) => ( +
  • + +
  • + ))} +
+
+ )} +
+
+ ); +}; + +export default Comment; diff --git a/src/components/Comment/Comment.types.ts b/src/components/Comment/Comment.types.ts new file mode 100644 index 00000000..0d029f84 --- /dev/null +++ b/src/components/Comment/Comment.types.ts @@ -0,0 +1,14 @@ +export interface Comment { + id: number; + level: number; + user: string; + time: number; + time_ago: string; + content: string; + deleted: boolean; + comments: Comment[]; +} + +export interface CommentProps { + comment: Comment; +}