Skip to content

Commit

Permalink
feat(comment): extra spacing for last descendant comment
Browse files Browse the repository at this point in the history
  • Loading branch information
robertu7 authored and gitwoz committed Oct 21, 2024
1 parent e8d1660 commit f1bd26e
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import classNames from 'classnames'
import _uniqBy from 'lodash/uniqBy'
import { useContext, useEffect } from 'react'

Expand All @@ -20,6 +21,7 @@ import {
DESCENDANT_COMMENTS_COMMENT_PRIVATE,
DESCENDANT_COMMENTS_COMMENT_PUBLIC,
} from '../gql'
import styles from './styles.module.css'

type DescendantCommentPublic = NonNullable<
NonNullable<
Expand Down Expand Up @@ -152,8 +154,13 @@ export const DescendantComments = ({

return (
<>
{result.map((node) => (
<li key={node.id}>
{result.map((node, index) => (
<li
key={node.id}
className={classNames({
[styles.lastDescendant]: index === result.length - 1,
})}
>
<CommentFeed
comment={node}
pinnedComment={pinnedComment}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,7 @@
margin-top: var(--sp8);
}
}

.lastDescendant {
margin-bottom: var(--sp16);
}
10 changes: 8 additions & 2 deletions src/components/Comment/ThreadComment/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import classNames from 'classnames'
import { useEffect, useState } from 'react'

import { filterComments } from '~/common/utils'
Expand Down Expand Up @@ -69,8 +70,13 @@ export const CommentThreadComment = ({

{descendants.length > 0 && (
<ul className={styles.descendants}>
{descendants.map((descendantComment) => (
<li key={descendantComment.id}>
{descendants.map((descendantComment, index) => (
<li
key={descendantComment.id}
className={classNames({
[styles.lastDescendant]: index === descendants.length - 1,
})}
>
<CommentFeed
comment={descendantComment}
pinnedComment={pinnedComment}
Expand Down
4 changes: 4 additions & 0 deletions src/components/Comment/ThreadComment/styles.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,7 @@
transition-property: background-color;
}
}

.lastDescendant {
margin-bottom: var(--sp16);
}

0 comments on commit f1bd26e

Please sign in to comment.