-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
All posts will still display the reply box underneath them. Added default profile picture fallback to notification dropdowns.
- Loading branch information
1 parent
9be726d
commit e35b4fd
Showing
7 changed files
with
137 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import { Link, useOutletContext } from 'react-router-dom'; | ||
import { DEFAULT_PROFILE_PICTURE } from '../../helpers/constants'; | ||
import { | ||
autoResizeTextarea, | ||
getFullNameFromDetails, | ||
getRelativeTimestamp, | ||
} from '../../helpers/util'; | ||
import commentStyles from './css/comment.module.css'; | ||
import postStyles from './css/post.module.css'; | ||
|
||
export function Comments({ postID, comments }) { | ||
const { user } = useOutletContext(); | ||
|
||
async function postComment(e) { | ||
e.preventDefault(); | ||
} | ||
|
||
return ( | ||
<div className={commentStyles.comments}> | ||
{comments.map((comment) => ( | ||
<div key={comment._id} className={commentStyles.comment}> | ||
<img | ||
src={comment.author.profilePicture ?? DEFAULT_PROFILE_PICTURE} | ||
alt="comment profile picture" | ||
/> | ||
|
||
<div className={commentStyles.content}> | ||
<div className={commentStyles.top}> | ||
<Link to={`/${comment.author.handle}`}> | ||
{getFullNameFromDetails(comment.author.details)} | ||
</Link> | ||
|
||
{user._id === comment.author._id && ( | ||
<button className={commentStyles.delete}>Delete</button> | ||
)} | ||
</div> | ||
|
||
<p>{comment.body}</p> | ||
|
||
<div className={postStyles.timestamp}> | ||
{getRelativeTimestamp(comment.timestamp)} | ||
</div> | ||
</div> | ||
</div> | ||
))} | ||
|
||
<form onSubmit={postComment} className={commentStyles.reply}> | ||
<label htmlFor={`reply_${postID}`}>Reply:</label> | ||
<textarea | ||
name="body" | ||
id={`reply_${postID}`} | ||
rows="1" | ||
placeholder="Comment on this post..." | ||
onInput={autoResizeTextarea} | ||
></textarea> | ||
<button className={commentStyles.postComment}>Post</button> | ||
</form> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
.comments { | ||
display: flex; | ||
flex-direction: column; | ||
|
||
& > * { | ||
background-color: var(--main-fade-vl); | ||
padding: 6px; | ||
} | ||
} | ||
|
||
.comment { | ||
border-bottom: 1px solid var(--faint-l); | ||
display: flex; | ||
gap: 6px; | ||
|
||
& > img { | ||
--profile-pciture-size: 42px; | ||
|
||
height: var(--profile-pciture-size); | ||
width: var(--profile-pciture-size); | ||
} | ||
} | ||
|
||
.content { | ||
display: flex; | ||
flex: 1; | ||
flex-direction: column; | ||
font-size: small; | ||
gap: 4px; | ||
|
||
& > p { | ||
white-space: pre-wrap; | ||
word-break: break-word; | ||
} | ||
} | ||
|
||
.top { | ||
display: flex; | ||
justify-content: space-between; | ||
} | ||
|
||
.delete { | ||
background-color: transparent; | ||
font-size: x-small; | ||
|
||
&:hover { | ||
color: var(--main-d); | ||
text-decoration: underline; | ||
} | ||
} | ||
|
||
.reply { | ||
align-items: center; | ||
display: flex; | ||
gap: 6px; | ||
|
||
& > textarea { | ||
flex: 1; | ||
padding-inline: 4px; | ||
resize: none; | ||
} | ||
} | ||
|
||
.postComment { | ||
align-self: flex-end; | ||
composes: bold from '../../buttons/css/button.module.css'; | ||
font-size: small; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters