]> Untitled Git - lemmy-ui.git/commitdiff
Merge branch 'main' into comment-depth
authorSleeplessOne1917 <abias1122@gmail.com>
Wed, 14 Jun 2023 23:46:11 +0000 (23:46 +0000)
committerGitHub <noreply@github.com>
Wed, 14 Jun 2023 23:46:11 +0000 (23:46 +0000)
src/assets/css/main.css
src/shared/components/comment/comment-node.tsx
src/shared/components/comment/comment-nodes.tsx

index 3ff70e47f2b1d965d5b8b55cde78173e31d910fd..e1adfc53e1fde6077b34e16b552c8a6604b73825 100644 (file)
@@ -218,6 +218,11 @@ blockquote {
   overflow-y: auto;
 }
 
+.comments {
+  list-style: none;
+  padding: 0;
+}
+
 .thumbnail {
   object-fit: cover;
   min-height: 60px;
index 8559f38baa1355d0809ed3766d34f328a35dc639..51826462352b4d3f8bcec75e2e03f189851079c6 100644 (file)
@@ -270,6 +270,7 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
       this.props.moderators
     );
 
+
     const borderColor = this.props.node.depth
       ? colorList[(this.props.node.depth - 1) % colorList.length]
       : colorList[0];
@@ -284,26 +285,17 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
       node.comment_view.counts.child_count > 0;
 
     return (
-      <div
-        className={`comment ${
-          this.props.node.depth && !this.props.noIndent ? "ml-1" : ""
-        }`}
-      >
+      <li className="comment" role="comment">
         <div
           id={`comment-${cv.comment.id}`}
           className={classNames(`details comment-node py-2`, {
             "border-top border-light": !this.props.noBorder,
             mark: this.isCommentNew || this.commentView.comment.distinguished,
           })}
-          style={
-            !this.props.noIndent && this.props.node.depth
-              ? `border-left: 2px ${borderColor} solid !important`
-              : ""
-          }
         >
           <div
             className={classNames({
-              "ml-2": !this.props.noIndent && this.props.node.depth,
+              "ml-2": !this.props.noIndent,
             })}
           >
             <div className="d-flex flex-wrap align-items-center text-muted small">
@@ -1169,6 +1161,8 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
             allLanguages={this.props.allLanguages}
             siteLanguages={this.props.siteLanguages}
             hideImages={this.props.hideImages}
+            isChild={!this.props.noIndent}
+            depth={this.props.node.depth + 1}
             finished={this.props.finished}
             onCommentReplyRead={this.props.onCommentReplyRead}
             onPersonMentionRead={this.props.onPersonMentionRead}
@@ -1192,8 +1186,8 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
           />
         )}
         {/* A collapsed clearfix */}
-        {this.state.collapsed && <div className="row col-12"></div>}
-      </div>
+        {this.state.collapsed && <div className="row col-12" />}
+      </li>
     );
   }
 
index 3f9b48ef68eaa0dffa5fb5ded882ce53a25c7557..e9876e6965ea8c57af46ea870b121244d486d419 100644 (file)
@@ -1,3 +1,4 @@
+import classNames from "classnames";
 import { Component } from "inferno";
 import {
   AddAdmin,
@@ -25,6 +26,7 @@ import {
   TransferCommunity,
 } from "lemmy-js-client";
 import { CommentNodeI, CommentViewType } from "../../interfaces";
+import { colorList } from "../../utils";
 import { CommentNode } from "./comment-node";
 
 interface CommentNodesProps {
@@ -44,6 +46,8 @@ interface CommentNodesProps {
   allLanguages: Language[];
   siteLanguages: number[];
   hideImages?: boolean;
+  isChild?: boolean;
+  depth?: number;
   finished: Map<CommentId, boolean | undefined>;
   onSaveComment(form: SaveComment): void;
   onCommentReplyRead(form: MarkCommentReplyAsRead): void;
@@ -74,8 +78,18 @@ export class CommentNodes extends Component<CommentNodesProps, any> {
   render() {
     const maxComments = this.props.maxCommentsShown ?? this.props.nodes.length;
 
-    return (
-      <div className="comments">
+    const borderColor = this.props.depth
+      ? colorList[this.props.depth % colorList.length]
+      : colorList[0];
+
+    return this.props.nodes.length > 0 ? (
+      <ul
+        className={classNames("comments", {
+          "ms-1": !!this.props.isChild,
+          "border-top border-light": !this.props.noBorder,
+        })}
+        style={`border-left: 2px solid ${borderColor} !important;`}
+      >
         {this.props.nodes.slice(0, maxComments).map(node => (
           <CommentNode
             key={node.comment_view.comment.id}
@@ -116,7 +130,7 @@ export class CommentNodes extends Component<CommentNodesProps, any> {
             onPurgeComment={this.props.onPurgeComment}
           />
         ))}
-      </div>
-    );
+      </ul>
+    ) : null;
   }
 }