-
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.
- Loading branch information
1 parent
10cf7e3
commit 0e7cc5c
Showing
12 changed files
with
170 additions
and
70 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { useState } from "react"; | ||
import { Link } from "remix"; | ||
import type { LinksFunction } from "remix"; | ||
import type { Comment as CommentType } from "~/types"; | ||
import stylesUrl from "./comment.css"; | ||
|
||
export const links: LinksFunction = () => { | ||
return [{ href: stylesUrl, rel: "stylesheet" }]; | ||
}; | ||
|
||
type CommentProps = { | ||
comment: CommentType; | ||
}; | ||
|
||
export default function Comment({ comment }: CommentProps) { | ||
const [hidden, hide] = useState(false); | ||
return ( | ||
<> | ||
{!comment.deleted && ( | ||
<article className="comment"> | ||
<div | ||
className={`meta-bar ${hidden ? "hidden" : ""}`} | ||
onClick={() => hide(!hidden)} | ||
> | ||
<span className="meta"> | ||
<Link to={`/user/${comment.user}`}>{comment.user}</Link>{" "} | ||
{comment.time_ago} | ||
</span> | ||
</div> | ||
|
||
<div | ||
className="body" | ||
dangerouslySetInnerHTML={{ __html: comment.content }} | ||
></div> | ||
|
||
{!hidden && comment.comments.length > 0 && ( | ||
<ul className="children"> | ||
{comment.comments.map((c) => ( | ||
<li key={c.id}> | ||
<Comment comment={c} /> | ||
</li> | ||
))} | ||
</ul> | ||
)} | ||
</article> | ||
)} | ||
</> | ||
); | ||
} |
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,46 @@ | ||
.comment { | ||
border-top: 1px solid rgba(0, 0, 0, 0.1); | ||
} | ||
html.dark .comment { | ||
border-top: 1px solid rgba(255, 255, 255, 0.1); | ||
} | ||
.comment .meta-bar { | ||
padding: 1em 0; | ||
cursor: pointer; | ||
background: 100% 50% no-repeat url(/assets/icons/fold.svg); | ||
background-size: 1em 1em; | ||
} | ||
.comment .hidden.meta-bar { | ||
background-image: url(/assets/icons/unfold.svg); | ||
} | ||
.comment .children { | ||
padding: 0 0 0 1em; | ||
margin: 0; | ||
} | ||
.comment .hidden .body, | ||
.comment .hidden .children { | ||
display: none; | ||
} | ||
@media (min-width: 720px) { | ||
.comment .children { | ||
padding: 0 0 0 2em; | ||
} | ||
} | ||
.comment li { | ||
list-style: none; | ||
} | ||
.comment .meta { | ||
display: block; | ||
font-size: 14px; | ||
color: var(--fg-light); | ||
} | ||
.comment a { | ||
color: var(--fg-light); | ||
} | ||
/* prevent crazy overflow layout bug on mobile */ | ||
.comment .body :global(*) { | ||
overflow-wrap: break-word; | ||
} | ||
.comment :global(pre) { | ||
overflow-x: auto; | ||
} |
This file was deleted.
Oops, something went wrong.
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,27 @@ | ||
.item h1 { | ||
font-weight: 500; | ||
} | ||
.item { | ||
border-bottom: 1em solid rgba(0, 0, 0, 0.1); | ||
margin: 0 -2em 2em -2em; | ||
padding: 0 2em 2em 2em; | ||
} | ||
html.dark .item { | ||
border-bottom: 1em solid rgba(255, 255, 255, 0.1); | ||
} | ||
.item .main-link { | ||
display: block; | ||
text-decoration: none; | ||
} | ||
.item small { | ||
display: block; | ||
font-size: 14px; | ||
} | ||
.item .meta { | ||
font-size: 0.8em; | ||
font-weight: 300; | ||
color: var(--fg-light); | ||
} | ||
.item .comments > :global(.comment):first-child { | ||
border-top: none; | ||
} |
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
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 |
---|---|---|
|
@@ -15,4 +15,5 @@ export type Comment = { | |
level: number; | ||
url: string; | ||
comments: Comment[]; | ||
deleted: boolean; | ||
}; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.