diff --git a/src/common/util/date.tsx b/src/common/util/date.tsx index 9980acb..d88e37a 100644 --- a/src/common/util/date.tsx +++ b/src/common/util/date.tsx @@ -14,6 +14,25 @@ export const dateToKorean = (date: Date) => { + outputDate.getDate() + '일'; } +export const relativeDateToKorean = (date: Date) => { + const outputDate = new Date(date); + const now = new Date(); + + const diffHours = now.getHours() - outputDate.getHours(); + + if (diffHours < 0) { + return dateToKorean(date); + } else if (diffHours < 1) { + return `방금 전`; + } else if (diffHours < 24) { + return `${diffHours}시간 전`; + } else if (diffHours < 24 * 7) { + return `${diffHours / 24}일 전`; + } else { + return dateToKorean(date); + } +} + export const shortDateToKorean = (date: Date) => { const outputDate = new Date(date); return (outputDate.getMonth() + 1) + '월 ' diff --git a/src/components/blog/BlogSideBar.tsx b/src/components/blog/BlogSideBar.tsx index be55dd6..e847b7f 100644 --- a/src/components/blog/BlogSideBar.tsx +++ b/src/components/blog/BlogSideBar.tsx @@ -23,12 +23,12 @@ function BlogSideBar({folders, tags, username, profileUrl, selectedFolder, setSe return (
- -
+ +
{username}
{username === loginState.username && ( -
+
diff --git a/src/components/common/Header.tsx b/src/components/common/Header.tsx index a4cf373..2ee0acd 100644 --- a/src/components/common/Header.tsx +++ b/src/components/common/Header.tsx @@ -74,10 +74,10 @@ function Header() { return (
- + logo -
+ className="size-8 mb-1"/> +
DIGLOG
diff --git a/src/components/common/ProfileImageCircle.tsx b/src/components/common/ProfileImageCircle.tsx index 43d4ca2..08c3fae 100644 --- a/src/components/common/ProfileImageCircle.tsx +++ b/src/components/common/ProfileImageCircle.tsx @@ -12,6 +12,9 @@ function ProfileImageCircle({profileUrl, size, onClick, addStyle}: { if (size === "lg") { imageSize = "size-32"; iconSize = "size-28"; + } else if (size === "md") { + imageSize = "size-28"; + iconSize = "size-24"; } else { imageSize += "size-10"; iconSize += "size-6"; diff --git a/src/components/folder/FolderMoveModal.tsx b/src/components/folder/FolderMoveModal.tsx deleted file mode 100644 index 0f509d4..0000000 --- a/src/components/folder/FolderMoveModal.tsx +++ /dev/null @@ -1,53 +0,0 @@ -import {FillButton} from "../common/FillButton.tsx"; -import {useState} from "react"; -import {TextButton} from "../common/TextButton.tsx"; -import {useSelector} from "react-redux"; -import {RootState} from "../../store.tsx"; -import ModalLayout from "../../layout/ModalLayout.tsx"; -import {FolderType} from "../../common/types/blog.tsx"; - -function FolderMoveModal({selectedFolder, folders, handleFolderMove, setShowModal}: { - selectedFolder: FolderType | null, - folders: FolderType[], - handleFolderMove: (folderId: string) => void - setShowModal: (showModal: boolean) => void, -}) { - - const loginState = useSelector((state: RootState) => state.loginSlice); - - const [selectedFolderId, setSelectedFolderId] = useState(""); - - const handleFolderChange = () => { - handleFolderMove(selectedFolderId); - - setShowModal(false); - } - - return ( - -
-

- "{selectedFolder?.title}" 폴더를 이동할 곳을 골라주세요. -

- - {folders.map(folder => ( - - ))} -
- setShowModal(false)}/> - -
-
-
- ); -} - -export default FolderMoveModal; \ No newline at end of file diff --git a/src/components/post/CommentCard.tsx b/src/components/post/CommentCard.tsx index d438a34..c52bf8c 100644 --- a/src/components/post/CommentCard.tsx +++ b/src/components/post/CommentCard.tsx @@ -1,4 +1,4 @@ -import {fullDateToKorean} from "../../common/util/date.tsx"; +import {relativeDateToKorean} from "../../common/util/date.tsx"; import {MdOutlineAddComment, MdOutlineComment, MdOutlinePerson} from "react-icons/md"; import {ChangeEvent, useState} from "react"; import CommentTextField from "./CommentTextField.tsx"; @@ -72,14 +72,14 @@ function CommentCard({comment, handleLoadMoreSubComment, handleCommentSubmit, pa ? user_image : } -

+

{comment.member.username}

-

- {fullDateToKorean(comment.createdAt)} +

+ {relativeDateToKorean(comment.createdAt)}

-
+
{!showEditTextField && comment.taggedUsername && @@ -93,12 +93,12 @@ function CommentCard({comment, handleLoadMoreSubComment, handleCommentSubmit, pa taggedUsername={comment.taggedUsername} originalComment={comment} handleShowTextField={handleShowEdit}/> - :
{comment.content}
} + :
{comment.content}
}
{depth === 0 &&
} diff --git a/src/components/post/PostCard.tsx b/src/components/post/PostCard.tsx index e256304..ac117fa 100644 --- a/src/components/post/PostCard.tsx +++ b/src/components/post/PostCard.tsx @@ -2,7 +2,7 @@ import {PostResponse} from "../../common/types/post.tsx"; import {getImgSrc, removeHtmlTags} from "../../common/util/html.tsx"; import DOMPurify from "dompurify"; import {MdImage} from "react-icons/md"; -import {dateToKorean} from "../../common/util/date.tsx"; +import {relativeDateToKorean} from "../../common/util/date.tsx"; import {Link} from "react-router-dom"; function PostCard({post}: { post: PostResponse }) { @@ -23,13 +23,13 @@ function PostCard({post}: { post: PostResponse }) {
-
+
+ className="font-semibold text-lime-700 hover:text-lime-400"> {post.username} -
- {dateToKorean(post.createdAt)} +
+ {relativeDateToKorean(post.createdAt)}
{/*
*/} @@ -40,11 +40,11 @@ function PostCard({post}: { post: PostResponse }) { {/*
*/}
-
+
{post.title}
-
+
{removeHtmlTags(safeContent)}
diff --git a/src/pages/MainPage.tsx b/src/pages/MainPage.tsx index 1285c54..ae3ba64 100644 --- a/src/pages/MainPage.tsx +++ b/src/pages/MainPage.tsx @@ -33,7 +33,7 @@ function MainPage() { return (
-
+
최근 게시글
-
+
+ addStyle="!text-xl !font-jalnan"/> } onClick={handleMenuOpen} diff --git a/src/pages/blog/BlogTagPage.tsx b/src/pages/blog/BlogTagPage.tsx index 164345f..e49610c 100644 --- a/src/pages/blog/BlogTagPage.tsx +++ b/src/pages/blog/BlogTagPage.tsx @@ -78,7 +78,7 @@ function BlogTagPage() {
+ addStyle="flex justify-start !text-xl !font-jalnan"/>
{tags.map(tag =>
-
+
{post.title}
@@ -211,9 +211,11 @@ function PostPage() { }}/>)}
-
-
+
+
+
{loginState.isLogin ?
-
+
diff --git a/src/pages/post/WritePage.tsx b/src/pages/post/WritePage.tsx index 9834f1f..ebd11eb 100644 --- a/src/pages/post/WritePage.tsx +++ b/src/pages/post/WritePage.tsx @@ -231,7 +231,7 @@ function WritePage() { return ( -
+