Skip to content
Merged
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
8 changes: 8 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
},
"dependencies": {
"@svgr/webpack": "^8.1.0",
"dayjs": "^1.11.13",
"next": "14.2.23",
"react": "^18",
"react-dom": "^18",
Expand Down
Binary file added public/assets/img/comment_empty.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions public/assets/img/icon_add.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions public/assets/img/icon_back.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions public/assets/img/icon_close.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions public/assets/img/icon_dot.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions public/assets/img/icon_wish_active.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/components/board-best-list.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
line-clamp: 2;
}
.board_best_box .content figure {
overflow: hidden;
display: block;
width: 70px;
height: 70px;
Expand Down
2 changes: 1 addition & 1 deletion src/components/board-best-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import formatDate from "@/lib/format-data";
export default function BoardBestList(data: Article) {
return (
<li className={styles.board_best_box}>
<Link href="">
<Link href={`/board/${data.id}`}>
<div className={styles.best}>
<img src="/assets/img/icon_best.svg" alt="베스트" />
Best
Expand Down
41 changes: 41 additions & 0 deletions src/components/board-comment.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
.comment {
padding-right: 30px;
position: relative;
padding-bottom: 12px;
margin-bottom: 24px;
border-bottom: 1px solid #e5e7eb;
}
.comment > h3 {
font-size: 14px;
font-weight: 400;
line-height: 1.7142;
margin-bottom: 24px;
}
.comment > .info {
display: flex;
}
.comment > .info > figure {
overflow: hidden;
display: block;
margin-right: 8px;
width: 32px;
height: 32px;
border-radius: 9999px;
}
.comment > .info > figure > img {
width: 100%;
height: 100%;
object-fit: cover;
}
.comment > .info > .right {
font-size: 12px;
line-height: 1.5;
}
.comment > .info > .right > p {
color: #4b5563;
margin-bottom: 4px;
}
.comment > .info > .right > span {
display: block;
color: #9ca3af;
}
37 changes: 37 additions & 0 deletions src/components/board-comment.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import formatDateNow from "@/lib/format-data-now";
import ToggleMenu from "@/components/toggle-menu";
import styles from "./board-comment.module.css";
import { Comment } from "../../types";

/**
* 질문하기
* Comment 인터페이스의 타입을 전부 사용안했는데 오류가 나지않는 이유??
* 예를 들어 createdAt는 ?. 처럼 선택적이 아니지만 오류가 안남
*/
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

타입스크립트 관련해서 질문있습니다.
Comment 인터페이스의 타입을 전부 사용안했는데 오류가 나지않는 이유가 뭘까요?

Copy link
Collaborator

Choose a reason for hiding this comment

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

TypeScript는 타입을 선언하는 것만으로는 오류를 발생시키지 않습니다.
즉, 타입이 정의되어 있지만 사용되지 않았다고 해서 TypeScript가 이를 강제하지는 않습니다.


const BoardComment = (props: Comment) => {
return (
<li className={styles.comment}>
<ToggleMenu />
<h3>{props.content}</h3>
<div className={styles.info}>
<figure>
<img
src={
props.writer.image
? props.writer.image
: "/assets/img/icon_my.svg"
}
alt={props.writer.nickname}
/>
Comment on lines +19 to +26
Copy link
Collaborator

Choose a reason for hiding this comment

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

src에 조건문을 넣기보단 src가 달라짐에따라 img 태그자체를 조건부 랜더링하는게 더 괜찮아보이네요

</figure>
<div className={styles.right}>
<p>{props.writer.nickname}</p>
<span>{formatDateNow(props.updatedAt)}</span>
</div>
</div>
</li>
);
};

export default BoardComment;
1 change: 1 addition & 0 deletions src/components/board-list.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
flex-direction: column;
}
.board_common_box .right figure {
overflow: hidden;
display: block;
margin-bottom: 16px;
margin-left: auto;
Expand Down
2 changes: 1 addition & 1 deletion src/components/board-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import formatDate from "@/lib/format-data";
export default function BoardList(data: Article) {
return (
<li className={styles.board_common_box}>
<Link href="">
<Link href={`/board/${data.id}`}>
<div className={styles.left}>
<h4>{data.title}</h4>
<div className={styles.bottom}>
Expand Down
22 changes: 22 additions & 0 deletions src/components/form/form-input.tsx
Copy link
Collaborator

Choose a reason for hiding this comment

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

이 컴포넌트는 결국 input을 고스란히 반환할 뿐인 스타일컴포넌트군요 props의 확장성을 좀더 고민해보시면 좋겠네요

Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import styles from "./form.module.css";

interface Props {
type: string;
placeholder: string;
value?: string;
onChange: (e: React.ChangeEvent<HTMLInputElement>) => void;
}

const FormInput = ({ type, placeholder, value, onChange }: Props) => {
return (
<input
className={styles.input}
type={type}
placeholder={placeholder}
value={value}
onChange={onChange}
/>
);
};

export default FormInput;
21 changes: 21 additions & 0 deletions src/components/form/form-textarea.tsx
Copy link
Collaborator

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
@@ -0,0 +1,21 @@
import styles from "./form.module.css";

interface Props {
placeholder: string;
height?: number;
value?: string;
onChange: (e: React.ChangeEvent<HTMLTextAreaElement>) => void;
}

const FormTextarea = ({ placeholder, height, value, onChange }: Props) => {
return (
<textarea
value={value}
onChange={onChange}
className={styles.textarea}
placeholder={placeholder}
style={{ height: height && `${height}px` }}></textarea>
);
};

export default FormTextarea;
52 changes: 52 additions & 0 deletions src/components/form/form.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
.input {
display: block;
background: inherit;
border: none;
outline: none;
box-shadow: none;
border-radius: 0;
padding: 0;
overflow: visible;
}
.input {
width: 100%;
background-color: #f3f4f6;
font-size: 16px;
padding: 0 24px;
border-radius: 12px;
height: 56px;
display: flex;
align-items: center;
}
.input::placeholder {
color: #9ca3af;
}

.textarea {
display: block;
background: inherit;
border: none;
outline: none;
box-shadow: none;
border-radius: 0;
padding: 0;
overflow: visible;
resize: none;
}
.textarea {
width: 100%;
background-color: #f3f4f6;
font-size: 16px;
padding: 16px 24px;
border-radius: 12px;
height: 282px;
}
.textarea::placeholder {
color: #9ca3af;
}

@media (max-width: 744px) {
.textarea {
height: 200px;
}
}
31 changes: 31 additions & 0 deletions src/components/toggle-menu.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { useState } from "react";
import styles from "./toggle.menu.module.css";
import { useOutsideClick } from "@/hooks/useOutsideClick";

const ToggleMenu = () => {
const [menu, setMenu] = useState(false);

const onMenuToggle = () => {
setMenu(!menu);
};

const ref = useOutsideClick(() => {
setMenu(false);
});
Comment on lines +12 to +14
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍👍


return (
<div className={styles.menu}>
<p onClick={onMenuToggle} ref={ref}>
<img src="/assets/img/icon_dot.svg" alt="메뉴버튼" />
</p>
{menu && (
<ul>
<li>수정하기</li>
<li>삭제하기</li>
</ul>
)}
</div>
);
};

export default ToggleMenu;
25 changes: 25 additions & 0 deletions src/components/toggle.menu.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
.menu {
position: absolute;
top: 0;
right: 0;
}
.menu > p {
cursor: pointer;
}
.menu > ul {
position: absolute;
top: calc(100% + 5px);
right: 0;
z-index: 10;
width: 100px;
text-align: center;
border: 1px solid #e5e7eb;
background-color: #fff;
padding: 5px 0;
border-radius: 12px;
}
.menu > ul > li {
padding: 5px 0;
font-size: 14px;
cursor: pointer;
}
27 changes: 0 additions & 27 deletions src/hooks/useMediaQuery.tsx
Original file line number Diff line number Diff line change
@@ -1,30 +1,3 @@
/* isMount 안쓰고 하는방법.. 근데 안됨
import { useEffect, useState } from "react";
import { useMediaQuery } from "react-responsive";

export const useIsMo = () => {
const [isMobile, setIsMobile] = useState(false);
const mobile = useMediaQuery({ query: "(max-width: 744px)" });

useEffect(() => {
setIsMobile(mobile);
}, [mobile]);

return isMobile;
};

export const useIsTa = () => {
const [isTablet, setIsTablet] = useState(false);
const tablet = useMediaQuery({ query: "(max-width: 1200px)" });

useEffect(() => {
setIsTablet(tablet);
}, [tablet]);

return isTablet;
};
*/

import { useMediaQuery } from "react-responsive";

export const useIsMo = () => {
Expand Down
17 changes: 17 additions & 0 deletions src/lib/fetch-board.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { Review } from "../../types";

const fetchBoard = async (id: number): Promise<Review | null> => {
const url = `https://panda-market-api.vercel.app/articles/${id}`;
try {
const response = await fetch(url);
if (!response.ok) {
throw new Error();
}
return await response.json();
} catch (err) {
console.error(err);
return null;
}
};

export default fetchBoard;
Loading
Loading