-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[나윤주] sprint10 #294
Merged
lisarnjs
merged 13 commits into
codeit-bootcamp-frontend:Next-나윤주
from
naynara87:Next-나윤주-sprint10
Aug 20, 2024
The head ref may contain hidden characters: "Next-\uB098\uC724\uC8FC-sprint10"
Merged
[나윤주] sprint10 #294
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
84793e5
docs: Readme.md 작성
a6e2392
feat: config 수정
fe05be2
feat: board[id] / addboard ui 작성
001f50c
feat: article fetch 연결
8d8c4e7
fix: type 정의 수정
ec530a9
fix: 경로 수정
d3e6b4a
fix: image upload 컴포넌트 오류 개선
83f0876
refactor: article type 추가
aea6d35
fix: img 불러오기 에러 config 추가
fff4048
refactor: article관련 리팩토링
10c072c
feat: 댓글 달기 기능 추가
4f126f2
refactor: 자유게시판 추가 내용 리팩토링
cd35490
feat: addBoard > axios post submit 기능
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
.article { | ||
margin: 32px auto; | ||
} | ||
.article-title { | ||
font-size: 20px; | ||
font-weight: 400; | ||
margin-bottom: 16px; | ||
} | ||
.writer-info { | ||
border-bottom: 1px solid var(--gray200); | ||
display: flex; | ||
align-items: center; | ||
gap: 8px; | ||
padding: 16px 0; | ||
.profile-info { | ||
display: flex; | ||
align-items: center; | ||
gap: 8px; | ||
font-size: 14px; | ||
font-weight: 300; | ||
} | ||
.profile-wrap { | ||
position: relative; | ||
width: 40px; | ||
height: 40px; | ||
border-radius: 50%; | ||
overflow: hidden; | ||
img { | ||
object-fit: contain; | ||
} | ||
} | ||
.date { | ||
font-size: 14px; | ||
color: var(--gray400); | ||
font-weight: 300; | ||
} | ||
.divided { | ||
position: relative; | ||
display: inline-block; | ||
margin: 0 25px; | ||
height: 30px; | ||
width: 1px; | ||
background-color: var(--gray200); | ||
} | ||
} | ||
.article-content { | ||
padding: 24px 0; | ||
p { | ||
font-weight: 300; | ||
font-size: 18px; | ||
} | ||
.article-image-wrap { | ||
position: relative; | ||
max-width: 600px; | ||
height: 600px; | ||
margin: 20px 0; | ||
img { | ||
object-fit: contain; | ||
} | ||
} | ||
} | ||
.btn-favorite { | ||
display: inline-flex; | ||
width: fit-content; | ||
align-items: center; | ||
gap: 8px; | ||
border: 1px solid var(--gray200); | ||
background: var(--white); | ||
border-radius: 2em; | ||
padding: 0.5em 1em; | ||
font-size: 16px; | ||
color: var(--gray500); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import { useEffect, useState } from "react"; | ||
import styles from "./Article.module.scss"; | ||
import Image from "next/image"; | ||
import Icon from "@/components/ui/Icon"; | ||
import axios from "@/lib/axios"; | ||
import { Article as ArticleType } from "@/types/articleTypes"; | ||
import { formatDate } from "@/lib/utils/formatDate"; | ||
|
||
interface ArticleProps { | ||
id: number; | ||
} | ||
|
||
function Article({ id }: ArticleProps) { | ||
const [article, setArticle] = useState<ArticleType | null>(null); | ||
const fetchArticle = async (articleId: number) => { | ||
try { | ||
const response = await axios.get(`/articles/${articleId}`); | ||
setArticle(response.data); | ||
} catch (error) { | ||
console.error("Failed to fetch the article:", error); | ||
} | ||
}; | ||
|
||
useEffect(() => { | ||
if (id) { | ||
fetchArticle(id); | ||
} | ||
}, [id]); | ||
|
||
if (!article) { | ||
return <p>Loading...</p>; | ||
} | ||
|
||
return ( | ||
<article className={styles.article}> | ||
<h3 className={styles["article-title"]}>{article.title}</h3> | ||
<div className={styles["writer-info"]}> | ||
<div className={styles["profile-info"]}> | ||
<div className={styles["profile-wrap"]}> | ||
<Image | ||
src="/img/profile.png" | ||
alt="프로필 이미지" | ||
className={styles["profile-image"]} | ||
fill | ||
/> | ||
</div> | ||
<div className={styles["nick-name"]}>{article.writer.nickname}</div> | ||
</div> | ||
<div className={styles.date}>{formatDate(article.createdAt)}</div> | ||
<div className={styles.divided}></div> | ||
<button className={styles["btn-favorite"]}> | ||
<Icon type="heart" size="md" /> | ||
|
||
{article.likeCount} | ||
</button> | ||
</div> | ||
<div className={styles["article-content"]}> | ||
<p>{article.content}</p> | ||
{article.image && ( | ||
<div className={styles["article-image-wrap"]}> | ||
<Image | ||
src={article.image} | ||
alt="게시글 이미지" | ||
className={styles["article-image"]} | ||
fill | ||
/> | ||
</div> | ||
)} | ||
</div> | ||
</article> | ||
); | ||
} | ||
|
||
export default Article; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
.input-label { | ||
display: block; | ||
font-size: 18px; | ||
color: var(--gray800); | ||
margin-bottom: 16px; | ||
font-weight: 700; | ||
|
||
@media (max-width: 767px) { | ||
font-size: 14px; | ||
margin-bottom: 8px; | ||
} | ||
} | ||
.image-add-wrap { | ||
display: flex; | ||
gap: 25px; | ||
@media (max-width: 1200px) { | ||
gap: 16px; | ||
} | ||
@media (max-width: 767px) { | ||
gap: 8px; | ||
} | ||
|
||
.image-add-btn { | ||
width: 282px; | ||
aspect-ratio: 1/1; | ||
font-size: 16px; | ||
color: var(--gray400); | ||
background-color: var(--gray100); | ||
border-radius: 12px; | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
align-items: center; | ||
gap: 12px; | ||
cursor: pointer; | ||
} | ||
|
||
.image-add-box { | ||
position: relative; | ||
width: 282px; | ||
aspect-ratio: 1/1; | ||
overflow: hidden; | ||
border-radius: 12px; | ||
img { | ||
object-fit: cover; | ||
} | ||
} | ||
} | ||
.btn-delete { | ||
position: absolute; | ||
background: transparent; | ||
width: 24px; | ||
height: 24px; | ||
right: 10px; | ||
top: 10px; | ||
background: url("/img/icon/ic_X.svg") no-repeat center center; | ||
&:hover { | ||
background-image: url("/img/icon/ic_X_blue.svg"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { useState, ChangeEvent } from "react"; | ||
import Image from "next/image"; | ||
import styles from "./FileInput.module.scss"; | ||
import Icon from "@/components/ui/Icon"; | ||
|
||
interface FileInputProps { | ||
label: string; | ||
imagePreviewUrl: string; | ||
onImageChange: (e: ChangeEvent<HTMLInputElement>) => void; | ||
onImageDelete: () => void; | ||
} | ||
|
||
function FileInput({ | ||
label, | ||
imagePreviewUrl, | ||
onImageChange, | ||
onImageDelete, | ||
}: FileInputProps) { | ||
return ( | ||
<div className="input-group"> | ||
<label className={styles["input-label"]}>{label}</label> | ||
<div className={styles["image-add-wrap"]}> | ||
<label | ||
className={styles["image-add-btn"]} | ||
aria-label="이미지 등록 버튼" | ||
> | ||
<input | ||
id="image-upload" | ||
className="sr-only" | ||
type="file" | ||
onChange={onImageChange} | ||
accept="image/*" | ||
/> | ||
<Icon type="plus" size="lg" /> | ||
<span>이미지 등록</span> | ||
</label> | ||
{imagePreviewUrl && ( | ||
<div className={styles["image-add-box"]}> | ||
<Image src={imagePreviewUrl} alt="이미지" fill /> | ||
<button | ||
type="button" | ||
onClick={onImageDelete} | ||
className={styles["btn-delete"]} | ||
aria-label="이미지 제거 버튼" | ||
/> | ||
</div> | ||
)} | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
export default FileInput; |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import React, { ChangeEvent } from "react"; | ||
|
||
// Props 타입 정의 | ||
interface NumberInputProps { | ||
label: string; | ||
name: string; | ||
value: number; | ||
onChange: (e: ChangeEvent<HTMLInputElement>) => void; // 타입 정의 수정 | ||
placeholder?: string; | ||
} | ||
|
||
function NumberInput({ | ||
label, | ||
name, | ||
value, | ||
onChange, | ||
placeholder, | ||
}: NumberInputProps) { | ||
return ( | ||
<div className="input-group"> | ||
<label>{label}</label> | ||
<input | ||
type="number" | ||
name={name} | ||
value={value} | ||
onChange={onChange} | ||
placeholder={placeholder} | ||
/> | ||
</div> | ||
); | ||
} | ||
|
||
export default NumberInput; |
Empty file.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
저번에 보여드렸던 것처럼 _responsive.scss 파일에 이런 media 구문을 @mixin으로 함수화 시켜서 정리해주시면 편할 거에요 👍