Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 17 additions & 57 deletions react-app/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions react-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"test:watch": "vitest"
},
"dependencies": {
"dompurify": "^3.4.17",
"react": "^19.2.0",
"react-dom": "^19.2.0",
"react-router-dom": "^7.9.0"
Expand Down
86 changes: 86 additions & 0 deletions react-app/src/components/Comment/Comment.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
@use "../../styles/media" as *;

.comment {
& {
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;
}
}
44 changes: 44 additions & 0 deletions react-app/src/components/Comment/Comment.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { useState } from 'react';
import { Link } from 'react-router-dom';
import type { Comment as CommentModel } from '../../models';
import { buttonProps } from '../../utils/activateOnKey';
import { sanitizedHtml } from '../../utils/sanitize';
import './Comment.scss';

export function Comment({ comment }: { comment: CommentModel }) {
const [collapsed, setCollapsed] = useState(false);

if (comment.deleted) {
return (
<div className="comment">
<div className="deleted-meta">
<span className="collapse">[deleted]</span> | Comment Deleted
</div>
</div>
);
}

return (
<div className="comment">
<div className={collapsed ? 'meta meta-collapse' : 'meta'}>
<span className="collapse" aria-expanded={!collapsed} {...buttonProps(() => setCollapsed((c) => !c))}>
[{collapsed ? '+' : '-'}]
</span>{' '}
<Link to={`/user/${comment.user}`}>{comment.user}</Link>
<span className="time">{comment.time_ago}</span>
</div>
<div className="comment-tree">
<div hidden={collapsed}>
<p className="comment-text" dangerouslySetInnerHTML={sanitizedHtml(comment.content)} />
<ul className="subtree">
{comment.comments.map((sub) => (
<li key={sub.id}>
<Comment comment={sub} />
</li>
))}
</ul>
</div>
</div>
</div>
);
}
Loading
Loading