Improve comment field.

This commit is contained in:
2025-06-04 20:09:44 +08:00
parent b9dc7b4af2
commit 2f1859c0fb

View File

@@ -23,7 +23,9 @@ import Markdown from "react-markdown";
import "../markdown.css"; import "../markdown.css";
import Loading from "../components/loading.tsx"; import Loading from "../components/loading.tsx";
import { import {
MdAdd, MdArrowDownward, MdArrowUpward, MdAdd,
MdArrowDownward,
MdArrowUpward,
MdOutlineArticle, MdOutlineArticle,
MdOutlineComment, MdOutlineComment,
MdOutlineDataset, MdOutlineDataset,
@@ -33,7 +35,7 @@ import {
} from "react-icons/md"; } from "react-icons/md";
import { app } from "../app.ts"; import { app } from "../app.ts";
import { uploadingManager } from "../network/uploading.ts"; import { uploadingManager } from "../network/uploading.ts";
import { ErrorAlert } from "../components/alert.tsx"; import { ErrorAlert, InfoAlert } from "../components/alert.tsx";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import Pagination from "../components/pagination.tsx"; import Pagination from "../components/pagination.tsx";
import showPopup, { useClosePopup } from "../components/popup.tsx"; import showPopup, { useClosePopup } from "../components/popup.tsx";
@@ -1116,25 +1118,32 @@ function Comments({ resourceId }: { resourceId: number }) {
return ( return (
<div> <div>
<div className={"mt-4 mb-6 textarea w-full p-4 h-28 flex flex-col"}> {app.isLoggedIn() ? (
<textarea <div className={"mt-4 mb-6 textarea w-full p-4 h-40 flex flex-col"}>
placeholder={t("Write down your comment")} <textarea
className={"w-full resize-none grow"} placeholder={t("Write down your comment")}
value={commentContent} className={"w-full resize-none grow"}
onChange={(e) => setCommentContent(e.target.value)} value={commentContent}
/> onChange={(e) => setCommentContent(e.target.value)}
<div className={"flex flex-row-reverse"}> />
<button <div className={"flex flex-row-reverse"}>
onClick={sendComment} <button
className={`btn btn-primary h-8 text-sm mx-2 ${commentContent === "" && "btn-disabled"}`} onClick={sendComment}
> className={`btn btn-primary h-8 text-sm mx-2 ${commentContent === "" && "btn-disabled"}`}
{isLoading ? ( >
<span className={"loading loading-spinner loading-sm"}></span> {isLoading ? (
) : null} <span className={"loading loading-spinner loading-sm"}></span>
Submit ) : null}
</button> Submit
</button>
</div>
</div> </div>
</div> ) : (
<InfoAlert
message={t("You need to log in to comment")}
className={"my-4 alert-dash"}
/>
)}
<CommentsList <CommentsList
resourceId={resourceId} resourceId={resourceId}
page={page} page={page}