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
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
next.config.js
32 changes: 31 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,33 @@
{
"extends": "next/core-web-vitals"
"env": {
"browser": true,
"node": true,
"es2021": true
},
"extends": [
"eslint:recommended",
"plugin:react/recommended",
"plugin:@typescript-eslint/recommended",
"next/core-web-vitals"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 12,
"sourceType": "module",
"project": "./tsconfig.json"
},
"plugins": ["react", "react-hooks", "@typescript-eslint"],
"rules": {
"no-console": "warn",
"semi": ["error", "always"],
"quotes": ["error", "single"]
},
"overrides": [
{
"files": ["next.config.js"],
"rules": {
"@typescript-eslint/explicit-module-boundary-types": "off"
}
}
]
}
167 changes: 167 additions & 0 deletions components/BestPost/BestPost.module.css
Copy link
Collaborator

Choose a reason for hiding this comment

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

대문자로 시작하는 파일은 컴포넌트에만 써주시는 게 좋아요! css 파일은 소문자로 시작하는 걸 추천드려요!

bestPost.module.css

그리고 폴더 이름이 BestPost 인만큼 index.module.css 여도 괜찮을 거 같아요!

Copy link
Collaborator Author

@jaehyeongjung jaehyeongjung Jan 16, 2025

Choose a reason for hiding this comment

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

       � BestPost 폴더 > bestPost.tsx (소문자시작) 
                              > index.module.css 이렇게 수정하라는 말씀이실까요 ?

  만약 그러면 그 외에 Dropdown폴더의 경우에도 
Dropdown.module.css , Dropdown.tsx 에서 -> index.module.css, Dropdown.tsx(컴포넌트)가 적절한가요 ?

Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
.BestPostContainer {
width: 1200px;
height: 241px;
margin: 0 auto;
margin-top: 24px;
}

.BestPost {
width: 100%;
height: 217px;
display: flex;
flex-direction: column;
gap: 24px;
}

.BestPostTitle {
width: 109px;
height: 24px;
font-family: Pretendard;
Copy link
Collaborator

Choose a reason for hiding this comment

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

요거 아마 기본일거라 안적어도 될 거에요! (기본 아니면 global.css 에서 선언하면 될 거 같아요)

font-size: 20px;
font-weight: 700;
line-height: 23.87px;
text-align: left;
color: #111827;
white-space: nowrap;
}

.BestPostTopic {
width: 100%;
height: 169px;
display: flex;
gap: 24px;
}

.BestPostTopicMap {
width: 384px;
height: 169px;
border-radius: 8px;
background-color: #f9fafb;
display: flex;
flex-direction: column;
gap: 24px;
}

.BestTopicImg {
width: 102px;
height: 30px;
background-color: #3692ff;
border-radius: 0px 0px 16px 16px;
margin-left: 24px;
display: flex;
align-items: center;
justify-content: center;
}

.BestTopicContentImg img {
width: 100%;
height: 100%;
object-fit: cover;
}

.BestTopicContent {
width: 336px;
height: 72px;
margin: 0 auto;
display: flex;
gap: 8px;
}

.BestTopicDetail {
width: 336px;
height: 24px;
margin: 0 auto;
display: flex;
justify-content: space-between;
}

.BestTopicContentText {
width: 256px;
height: 64px;
font-family: Pretendard;
font-size: 20px;
font-weight: 600;
line-height: 32px;
text-align: left;
overflow: hidden;
text-overflow: ellipsis;
}

.BestTopicContentImg {
width: 72px;
height: 72x;
border-radius: 6px;
border: 1px solid #e5e7eb;
}

.BestTopicDetailData {
width: 133px;
height: 24px;
display: flex;
gap: 8px;
}

.BestTopicDetailDate {
width: 79px;
height: 24px;
font-family: Pretendard;
font-size: 14px;
font-weight: 400;
line-height: 24px;
text-align: left;
color: #9ca3af;
}

.BestTopicImgInner {
display: flex;
height: 26px;
width: 54px;
gap: 4px;
align-items: center;
}

.BestPostTopicImgInnerText {
width: 34px;
height: 26px;
font-family: Pretendard;
font-size: 16px;
font-weight: 600;
color: white;
display: flex;
align-items: center;
justify-content: center;
padding-top: 3px;
line-height: normal;
text-align: center;
}

.BestTopicDetailDataNickname {
width: 61px;
height: 100%;
white-space: nowrap;
font-family: Pretendard;
font-size: 14px;
font-weight: 400;
line-height: 24px;
text-align: left;
}

.BestTopicDetailDataFavorite {
display: flex;
align-items: center;
width: 64px;
height: 100%;
gap: 4px;
}

.BestTopicDetailDataFavoriteNum {
width: 44px;
height: 100%;
font-family: Pretendard;
font-size: 14px;
font-weight: 400;
text-align: left;
color: #6b7280;
display: flex;
align-items: center;
}
99 changes: 99 additions & 0 deletions components/BestPost/BestPost.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
import styles from "./BestPost.module.css";
import medal from "@/public/medal.svg";
import React, { useState, useEffect } from "react"; // React import 추가
import heart from "@/public/heart.svg";
import Image from "next/image";

export default function BestPost() {
const [articles, setArticles] = useState<any[]>([]);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Article 타입 선언해서 쓰면 좋을 거 같아요!


useEffect(() => {
const fetchArticles = async () => {
const response = await fetch("/api/BestApi");
const data = await response.json();
setArticles(data.list || []); // API에서 받은 데이터를 상태에 저장
};

fetchArticles();
}, []);

return (
<>
<div className={styles.BestPostContainer}>
<div className={styles.BestPost}>
<div className={styles.BestPostTitle}>베스트 게시글</div>
<div className={styles.BestPostTopic}>
{articles.map((article) => (
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
{articles.map((article) => (
{articles.map(({content, likeCount ... }) => (

요런 식으로 구조분해할당하면 좋을 거 같아요!

<div className={styles.BestPostTopicMap}>
Copy link
Collaborator

Choose a reason for hiding this comment

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

여기 key props 추가해주세요!

Suggested change
<div className={styles.BestPostTopicMap}>
<div className={styles.BestPostTopicMap} key={index}>

<div className={styles.BestTopicImg}>
<div className={styles.BestTopicImgInner}>
<Image
src={medal}
alt="medal"
width={16}
height={16}
/>
<p
className={
styles.BestPostTopicImgInnerText
}
>
Best
</p>
</div>
</div>
<div className={styles.BestTopicContent}>
<div
className={styles.BestTopicContentText}
>
{article.content}
</div>
<div
className={styles.BestTopicContentImg}
>
<img src={article.image}></img>
</div>
</div>
<div className={styles.BestTopicDetail}>
<div className={styles.BestTopicDetailData}>
<div
className={
styles.BestTopicDetailDataNickname
}
>
{article.writer.nickname}
</div>
<div
className={
styles.BestTopicDetailDataFavorite
}
>
<Image
src={heart}
alt="heart"
width={16}
height={16}
/>
<div
className={
styles.BestTopicDetailDataFavoriteNum
}
>
{article.likeCount}
</div>
</div>
</div>
<div className={styles.BestTopicDetailDate}>
{new Date(
article.createdAt
).toLocaleDateString()}
</div>
</div>
</div>
))}
</div>
</div>
</div>
</>
);
}
53 changes: 53 additions & 0 deletions components/Dropdown/Dropdown.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
.dropdownContainer {
border: 1px solid #e5e7eb;
border-radius: 12px;
width: 130px;
height: 42px;
position: relative;
padding-left: 24px;
padding-top: 12px;
}

.dropdownButton {
width: 90px;
height: 18px;
display: flex;
justify-content: space-between;
align-items: center;
border: none;
background-color: white;

}
.dropdownMenu ul {
list-style-type: none; /* 동그라미 점 제거 */
padding: 0; /* 기본 padding 제거 */
margin: 0; /* 기본 margin 제거 */
}

.dropdownMenu {
display: block;
}

.dropdownItem {
width: 90px;
height: 23px;
font-family: Pretendard;
font-size: 14px;
font-weight: 400;
line-height: 26px;
text-align: left;
border: 1px solid #e5e7eb;
background-color: floralwhite;
display: flex;
align-items: center;
justify-content: center;
border-bottom: 1px solid #e5e7eb; /* 항목 간 구분선 추가 */
}

.text {
font-family: Pretendard;
font-size: 16px;
font-weight: 400;
line-height: 26px;
text-align: left;
}
Loading
Loading