Skip to content

Commit

Permalink
[Update]GamePage 리뷰 작성 & 수정 CSS 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
ChungO5 committed Aug 4, 2024
1 parent 97774dd commit 14561d6
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 53 deletions.
76 changes: 35 additions & 41 deletions src/components/atoms/StarSelect.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,81 +4,75 @@ import styled from "styled-components";
const StarStyle = styled.ul`
display: flex;
align-items: center;
gap: 20px;
gap: 10px;
list-style-type: none;
padding: 0;
margin: 0;
li {
cursor: pointer;
&.active {
.fa-solid.fa-star {
color: #ffcc00;
}
}
i {
font-size: 30px;
}
}
`;

const StarSelect = ({ setSort, sort }) => {
return (
<StarStyle>
<li
key={1}
value={1}
className={sort === 1 ? "active" : null}
className={sort > 0 ? "active" : null}
onClick={() => setSort(1)}
>
<i class="fa-solid fa-star" />
<i class="fa-regular fa-star" />
<i class="fa-regular fa-star" />
<i class="fa-regular fa-star" />
<i class="fa-regular fa-star" />
{sort > 0 ? (
<i class="fa-solid fa-star" />
) : (
<i class="fa-regular fa-star" />
)}
</li>
<li
key={1}
value={1}
className={sort === 2 ? "active" : null}
className={sort > 1 ? "active" : null}
onClick={() => setSort(2)}
>
<i class="fa-solid fa-star" />
<i class="fa-solid fa-star" />
<i class="fa-regular fa-star" />
<i class="fa-regular fa-star" />
<i class="fa-regular fa-star" />
{sort > 1 ? (
<i class="fa-solid fa-star" />
) : (
<i class="fa-regular fa-star" />
)}
</li>
<li
key={1}
value={1}
className={sort === 3 ? "active" : null}
className={sort > 2 ? "active" : null}
onClick={() => setSort(3)}
>
<i class="fa-solid fa-star" />
<i class="fa-solid fa-star" />
<i class="fa-solid fa-star" />
<i class="fa-regular fa-star" />
<i class="fa-regular fa-star" />
{sort > 2 ? (
<i class="fa-solid fa-star" />
) : (
<i class="fa-regular fa-star" />
)}
</li>
<li
key={1}
value={1}
className={sort === 4 ? "active" : null}
className={sort > 3 ? "active" : null}
onClick={() => setSort(4)}
>
<i class="fa-solid fa-star" />
<i class="fa-solid fa-star" />
<i class="fa-solid fa-star" />
<i class="fa-solid fa-star" />
<i class="fa-regular fa-star" />
{sort > 3 ? (
<i class="fa-solid fa-star" />
) : (
<i class="fa-regular fa-star" />
)}
</li>
<li
key={1}
value={1}
className={sort === 5 ? "active" : null}
className={sort > 4 ? "active" : null}
onClick={() => setSort(5)}
>
<i class="fa-solid fa-star" />
<i class="fa-solid fa-star" />
<i class="fa-solid fa-star" />
<i class="fa-solid fa-star" />
<i class="fa-solid fa-star" />
{sort > 4 ? (
<i class="fa-solid fa-star" />
) : (
<i class="fa-regular fa-star" />
)}
</li>
</StarStyle>
);
Expand Down
23 changes: 16 additions & 7 deletions src/components/molecules/Comment.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,17 @@ const CommentBox = styled.div`
}
`;

const Comment = ({ item, styled, reviewsubmit, reviewEdit, setReviewEdit }) => {
const Comment = ({
item,
styled,
reviewsubmit,
reviewEdit,
setReviewEdit,
setSort,
sort,
}) => {
const [ishelpful, setIshelpful] = useState();
const [clicked, setClicked] = useState(false);
const star = Math.floor(item.star);

const IsEdit = () => {
if (reviewEdit === true) {
Expand Down Expand Up @@ -137,27 +144,27 @@ const Comment = ({ item, styled, reviewsubmit, reviewEdit, setReviewEdit }) => {
) : null}
</p>
<p className="star">
{star >= 1 ? (
{item.star >= 1 ? (
<i class="fa-solid fa-star" />
) : (
<i class="fa-regular fa-star" />
)}
{star >= 2 ? (
{item.star >= 2 ? (
<i class="fa-solid fa-star" />
) : (
<i class="fa-regular fa-star" />
)}
{star >= 3 ? (
{item.star >= 3 ? (
<i class="fa-solid fa-star" />
) : (
<i class="fa-regular fa-star" />
)}
{star >= 4 ? (
{item.star >= 4 ? (
<i class="fa-solid fa-star" />
) : (
<i class="fa-regular fa-star" />
)}
{star === 5 ? (
{item.star >= 5 ? (
<i class="fa-solid fa-star" />
) : (
<i class="fa-regular fa-star" />
Expand Down Expand Up @@ -196,6 +203,8 @@ const Comment = ({ item, styled, reviewsubmit, reviewEdit, setReviewEdit }) => {
reviewsubmit={reviewsubmit}
reviewEdit={reviewEdit}
setReviewEdit={setReviewEdit}
sort={sort}
setSort={setSort}
/>
</div>
) : null}
Expand Down
19 changes: 14 additions & 5 deletions src/components/molecules/CommentForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,15 @@ const CommentFormBox = styled.div`
form {
display: flex;
}
.buttonBox {
.submitBox {
width: 100%;
display: flex;
justify-content: space-between;
}
.buttonBox {
display: flex;
gap: 20px;
}
.editBox {
width: 100%;
display: flex;
Expand All @@ -36,11 +40,13 @@ const CommentForm = ({
sort,
type,
IsEdit,
star,
}) => {
const [reviewText, setreviewText] = useState("");
const submit = () => {
reviewsubmit(reviewText);
};

return (
<CommentFormBox>
<CommentInput
Expand All @@ -50,12 +56,15 @@ const CommentForm = ({
onChange={setreviewText}
/>
{type ? (
<div className="editBox">
<CommentBtn text="취소" onClick={IsEdit} />
<CommentBtn text="입력" onClick={submit} />
<div className="submitBox">
<StarSelect setSort={setSort} sort={sort} />
<div className="buttonBox">
<CommentBtn text="취소" onClick={IsEdit} />
<CommentBtn text="입력" onClick={submit} />
</div>
</div>
) : (
<div className="buttonBox">
<div className="submitBox">
<StarSelect setSort={setSort} sort={sort} />
<CommentBtn text="입력" onClick={submit} />
</div>
Expand Down
2 changes: 2 additions & 0 deletions src/components/organisms/CommentList.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ const CommentList = ({
reviewsubmit={reviewsubmit}
reviewEdit={reviewEdit}
setReviewEdit={setReviewEdit}
setSort={setStar}
sort={star}
/>
)}
<ReviewSortSelect
Expand Down
1 change: 1 addition & 0 deletions src/pages/GamePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ const GamePage = () => {
if (reviewEdit === true) {
const data = await putReview(myReview.reviewId, {
reviewContent: reviewText,
star: star,
});
if (data.status === 200) {
alert("리뷰 수정 완료");
Expand Down

0 comments on commit 14561d6

Please sign in to comment.