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
24 changes: 24 additions & 0 deletions lionblog-seongil/src/components/Posts/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,27 @@ export const SmallPost = ({ post }) => {
</div>
);
};

export const BigPost = ({ post }) => {
const likeBtnClick = () => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์ด ํ•จ์ˆ˜๋Š” ์ข‹์•„์š”๋ฅผ ๋ˆ„๋ฅด๋Š” ์ด๋ฒคํŠธ๊ฐ€ ๋ฐœ์ƒํ–ˆ์„ ๋•Œ ํ˜ธ์ถœ๋˜๋Š” ํ•จ์ˆ˜์ธ๋ฐ์š” ! ์ด๋Ÿฐ ์ด๋ฒคํŠธ ํ•ธ๋“ค๋Ÿฌ ํ•จ์ˆ˜๋Š” ๋ณดํ†ต handle์–ด์ฉŒ๊ตฌ๋กœ ์ด๋ฆ„์„ ์ง“๋Š” ๊ฒƒ์ด ์ผ๋ฐ˜์ ์ž…๋‹ˆ๋‹ค ~ ์ฐธ๊ณ ํ•ด ์ฃผ์„ธ์š” !

Suggested change
const likeBtnClick = () => {
const handleLike = () => {

alert("์ข‹์•„์š”");
};
return (
<div className="w-max flex flex-col justify-center items-center">
<div className="block group py-10 px-8 mr-5 my-5 ring-8 ring-transparent border-2 border-box border-white hover:bg-orange-400 hover:text-black hover:border-transparent hover:ring-orange-200 rounded-xl font-medium">
<h1 className="font-extrabold text-2xl truncate">{post.title}</h1>
<p className="mt-2">{post.author.username}</p>
<div className="flex flex-wrap mt-5">
{post.tags.map((tag) => (
<span key={tag.id} className="tag m-1">
#{tag.content}
</span>
))}
</div>
<div onClick={likeBtnClick}>
{post.like_users.length > 0 && `โค๏ธ ${post.like_users.length}`}
</div>
</div>
</div>
);
};
4 changes: 3 additions & 1 deletion lionblog-seongil/src/routes/HomePage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ const HomePage = () => {
</div>
<div className="grid grid-cols-4 px-10 mt-10">
{postList.map((post) => (
<SmallPost key={post.id} post={post} />
<Link to={"/" + post.id}>
Copy link

@kimnamheeee kimnamheeee Apr 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๏ฟฝSmallPost ์ปดํฌ๋„ŒํŠธ ์ž์ฒด๊ฐ€ Link๋กœ ๊ฐ์‹ธ์ ธ ์žˆ๊ธฐ ๋•Œ๋ฌธ์— ์—ฌ๊ธฐ์„œ๋Š” Link๋กœ ๊ฐ์‹ธ์ง€ ์•Š์•„๋„ ์ปดํฌ๋„ŒํŠธ๋ฅผ ๋ˆŒ๋ €์„ ๋•Œ PostDetailPage๋กœ ์ด๋™ํ•ฉ๋‹ˆ๋‹ค !!

<SmallPost key={post.id} post={post} />
</Link>
))}
</div>
<div className="flex justify-center m-20">
Expand Down
45 changes: 44 additions & 1 deletion lionblog-seongil/src/routes/PostCreatePage.jsx

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๋„ˆ๋ฌด ์•ผ๋ฌด์ง€๋„ค์š”

Original file line number Diff line number Diff line change
@@ -1,5 +1,48 @@
const PostCreatePage = () => {
return <div>Post Create Page</div>;
const handleSignUpSubmit = () => {
alert("๊ฒŒ์‹œ๋ฌผ์„ ๋“ฑ๋กํ•ฉ๋‹ˆ๋‹ค");
};
return (
<div className="flex flex-col items-center w-1/2">
<h3 className="font-bold text-2xl">๊ฒŒ์‹œ๊ธ€ ์ž‘์„ฑ</h3>
<form className="form gap-2" onSubmit={handleSignUpSubmit}>
<label required type="text" className="label">
์ œ๋ชฉ:
</label>
<input
required
placeholder="์ œ๋ชฉ์„ ์ž‘์„ฑํ•˜์„ธ์š”"
type="text"
id="title"
className="input"
/>
<label required className="label">
๋‚ด์šฉ:
</label>
<input
className="h-64 input"
placeholder="๋‚ด์šฉ์„ ์ž‘์„ฑํ•˜์„ธ์š”"
required
type="text"
id="content"
/>
<label required className="label">
ํƒœ๊ทธ:
</label>
<input
className="input"
placeholder="ํƒœ๊ทธ๋ฅผ ์ถ”๊ฐ€ํ•˜์„ธ์š”"
type="text"
id="tag"
/>
<div className="flex flex-row items-center gap-5">
<button type="submit" className="button mt-7">
์™„๋ฃŒ
</button>
</div>
</form>
</div>
);
};

export default PostCreatePage;
33 changes: 31 additions & 2 deletions lionblog-seongil/src/routes/PostDetailPage.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,34 @@
import posts from "../data/posts";
import { BigPost } from "../components/Posts";
import { useParams } from "react-router-dom";
import { Link } from "react-router-dom";

const PostDetailPage = () => {
return <div>Post Detail Page</div>;
const postId = useParams().postId;
const post = posts.find((post) => post.id === parseInt(postId));
const handleDeleteClick = () => {
alert("์‚ญ์ œ"); // TODO: add api call for sign up
};
return (
<div>
<BigPost key={post.id} post={post} />
<form>
<div className="flex flex-row items-center gap-5">
<Link to={`/${post.id}/edit`}>
<button type="submit" className="button mt-7">
์ˆ˜์ •
</button>
</Link>
<button
type="button"
className="button mt-7"
onClick={handleDeleteClick}
>
์‚ญ์ œ
</button>
</div>
</form>
</div>
);
};

export default PostDetailPage;
60 changes: 59 additions & 1 deletion lionblog-seongil/src/routes/PostEditPage.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,63 @@
import posts from "../data/posts";
import { useParams } from "react-router-dom";
const PostEditPage = () => {
return <div>Post Edit Page</div>;
const handleSignUpSubmit = () => {
alert("์ˆ˜์ • ์™„๋ฃŒ");
};
const postId = useParams().postId;
const post = posts.find((post) => post.id === parseInt(postId));
return (
<div className="flex flex-col items-center w-1/2">
<h3 className="font-bold text-2xl">๊ฒŒ์‹œ๊ธ€ ์ˆ˜์ •</h3>
<form className="form gap-2" onSubmit={handleSignUpSubmit}>
<label required type="text" className="label">
์ œ๋ชฉ:
</label>
<input
required
value={post.title}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์ด๋ ‡๊ฒŒ ์„ค์ •ํ•˜๋ฉด ์•„๋งˆ ๊ฐ’ ์ˆ˜์ •์ด ์•ˆ ๋  ๊ฑฐ์˜ˆ์š”! defaultValue ์†์„ฑ์„ ์‚ฌ์šฉํ•ด ๋ด์š” ~

Suggested change
value={post.title}
defaultValue={post.title}

type="text"
id="title"
className="input"
/>
<label required className="label">
๋‚ด์šฉ:
</label>
<input
className="h-64 input"
value={post.content}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์—ฌ๊ธฐ๋„ ๋งˆ์ฐฌ๊ฐ€์ง€๋กœ defaultValue๋ฅผ ์“ฐ๋ฉด ์ข‹์„ ๊ฒƒ ๊ฐ™์•„์š”!

Suggested change
value={post.content}
defaultValue={post.content}

required
type="text"
id="content"
/>
<label required className="label">
ํƒœ๊ทธ:
</label>
<input
className="input"
placeholder="ํƒœ๊ทธ๋ฅผ ์ถ”๊ฐ€ํ•˜์„ธ์š”"
required
type="text"
id="tag"
/>
<div className="w-full flex flex-row justify-left flex-wrap mt-5">
{post.tags.map((tag) => (
<div className="gap-0.5">
<span key={tag.id} className="tag m-1 -mr-px">
#{tag.content}
</span>
<span className="tag text-xs">X</span>
</div>
))}
</div>
<div className="flex flex-row items-center gap-5">
<button type="submit" className="button mt-7">
์™„๋ฃŒ
</button>
</div>
</form>
</div>
);
};

export default PostEditPage;
29 changes: 28 additions & 1 deletion lionblog-seongil/src/routes/SignInPage.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,32 @@
const SignInPage = () => {
return <div>Sign In Page</div>;
const handleSignUpSubmit = () => {
alert("๋กœ๊ทธ์ธ ํ•˜๊ธฐ"); // TODO: add api call for sign up
};
return (
<div className="flex flex-col items-center w-1/2">
<h3 className="font-bold text-2xl">ํšŒ์›๊ฐ€์ž…</h3>
<form className="form gap-2" onSubmit={handleSignUpSubmit}>
<label htmlFor="email" className="label">
*์ด๋ฆ„:
</label>
<input required type="text" id="username" className="input" />
Comment on lines +10 to +12

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์ด ๋ถ€๋ถ„์— ์‚ฌ์šฉ์ž๊ฐ€ ์ด๋ฉ”์ผ์„ ์ž…๋ ฅํ•˜๊ฒŒ ๋˜์–ด์žˆ๋Š” ๋งŒํผ ์ฝ”๋“œ์—๋„ ๊ธฐ๋Šฅ์„ ๋ฐ˜์˜ํ•ด์„œ ์ผ๊ด€์„ฑ์„ ์œ ์ง€ํ•ด ์ฃผ๋Š” ๊ฑด ์–ด๋–จ๊นŒ์š”!!

Suggested change
*์ด๋ฆ„:
</label>
<input required type="text" id="username" className="input" />
*์ด๋ฉ”์ผ:
</label>
<input required type="text" id="email" className="input" />


<label required htmlFor="username" className="label">
*๋น„๋ฐ€๋ฒˆํ˜ธ:
</label>
<input required type="password" id="password" className="input" />

<div className="flex flex-row items-center gap-5">
<button type="reset" className="button mt-7">
์ดˆ๊ธฐํ™”
</button>
<button type="submit" className="button mt-7">
๋กœ๊ทธ์ธ
</button>
</div>
</form>
</div>
);
};

export default SignInPage;