diff --git a/src/components/Article/Comment.module.scss b/src/components/Article/Comment.module.scss
index 50064a39..1344c1fd 100644
--- a/src/components/Article/Comment.module.scss
+++ b/src/components/Article/Comment.module.scss
@@ -3,6 +3,7 @@
margin: 0 -2.4rem 1.5em;
padding: 0.8rem 2.4rem;
transition: background-color 0.3s;
+ border: 1px solid red;
&:hover {
background-color: #f6f6f6;
@@ -32,25 +33,25 @@
}
}
-.commentLevel1 {
- margin-left: 3.2rem;
-}
-
-.commentLevel2 {
- margin-left: 6.4rem;
-}
-
-.commentLevel3 {
- margin-left: 9.6rem;
-}
-
-.commentLevel4 {
- margin-left: 12.8rem;
-}
-
-.commentLevel5 {
- margin-left: 16rem;
-}
+//.commentLevel1 {
+// margin-left: 3.2rem;
+//}
+//
+//.commentLevel2 {
+// margin-left: 6.4rem;
+//}
+//
+//.commentLevel3 {
+// margin-left: 9.6rem;
+//}
+//
+//.commentLevel4 {
+// margin-left: 12.8rem;
+//}
+//
+//.commentLevel5 {
+// margin-left: 16rem;
+//}
.commentControls {
@include font-size(1.2rem);
diff --git a/src/components/Article/Comment.tsx b/src/components/Article/Comment.tsx
index 0b3e5ee9..1f5411cf 100644
--- a/src/components/Article/Comment.tsx
+++ b/src/components/Article/Comment.tsx
@@ -12,6 +12,7 @@ import { formatDate } from '../../utils'
import { SharePopup } from './SharePopup'
import stylesHeader from '../Nav/Header.module.scss'
import Userpic from '../Author/Userpic'
+import CommentWrapper from './CommentWrapper'
export default (props: {
level?: number
@@ -34,114 +35,116 @@ export default (props: {
)
return (
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
)
}
diff --git a/src/components/Article/CommentWrapper.tsx b/src/components/Article/CommentWrapper.tsx
new file mode 100644
index 00000000..bd577b8c
--- /dev/null
+++ b/src/components/Article/CommentWrapper.tsx
@@ -0,0 +1,71 @@
+import type { JSX } from 'solid-js/jsx-runtime'
+import { Switch, Match } from 'solid-js'
+
+type Props = {
+ level?: number
+ children: JSX.Element
+}
+
+const CommentWrapper = (props: Props) => {
+ return (
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ )
+}
+
+export default CommentWrapper
diff --git a/src/components/Article/CommentsTree.tsx b/src/components/Article/CommentsTree.tsx
index 44938ae2..d300ca91 100644
--- a/src/components/Article/CommentsTree.tsx
+++ b/src/components/Article/CommentsTree.tsx
@@ -1,4 +1,4 @@
-import { For, Show, createMemo, createSignal, onMount } from 'solid-js'
+import { For, Show, createMemo, createSignal, onMount, createEffect } from 'solid-js'
import { useSession } from '../../context/session'
import Comment from './Comment'
import { t } from '../../utils/intl'
@@ -49,6 +49,25 @@ export const CommentsTree = (props: { shoutSlug: string }) => {
return level
}
onMount(async () => await loadMore())
+
+ function nestComments(commentList) {
+ const commentMap = {}
+ commentList.forEach((comment) => (commentMap[comment.id] = comment))
+ commentList.forEach((comment) => {
+ if (comment.replyTo !== null) {
+ const parent = commentMap[comment.replyTo]
+ ;(parent.children = parent.children || []).push(comment)
+ }
+ })
+ return commentList.filter((comment) => {
+ return comment.replyTo === null
+ })
+ }
+
+ createEffect(() => {
+ console.log('!!! reactions():', nestComments(reactions()))
+ })
+
return (
<>
}>
@@ -83,15 +102,20 @@ export const CommentsTree = (props: { shoutSlug: string }) => {
-
- {(reaction: Reaction) => (
-
- )}
-
+
+
+ {(reaction: Reaction) => (
+ <>
+ {JSON.stringify(getCommentLevel(reaction))}
+
+ >
+ )}
+
+