Skip to content
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

[최영선] Sprint8 #242

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
16 changes: 8 additions & 8 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"react-router-dom": "^6.24.0",
"react-scripts": "^5.0.1",
"sass": "^1.77.6",
"styled-components": "^6.1.11",
"styled-components": "^6.1.12",
"web-vitals": "^2.1.4"
},
"scripts": {
Expand Down
File renamed without changes
12 changes: 11 additions & 1 deletion public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,17 @@
<html lang="ko">
<head>
<meta charset="utf-8" />
<title>중고마켓</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta property="og:url" content="https://pandamarket-choiys.netlify.app/" />
<meta property="og:title" content="판다마켓" />
<meta property="og:type" content="website" />
<meta
property="og:image"
content="https://pandamarket-choiys.netlify.app/preview_img.png"
/>
<meta property="og:description" content="일상의 모든 물건을 거래해보세요" />
<title>판다마켓</title>
<link rel="icon" href="/panda_face.png" />
</head>
<body>
<div id="root"></div>
Expand Down
File renamed without changes
File renamed without changes
1 change: 1 addition & 0 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import MarketPage from "./pages/Market/MarketPage";
import AddItemPage from "./pages/AddItems/AddItemPage";
import HomePage from "./pages/Home/HomePage";
import ProductdetailPage from "./pages/ProductDetail/ProductDetailPage";
import "../src/css/global.css";

function App() {
return (
Expand Down
20 changes: 9 additions & 11 deletions src/api.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
const API_BASE_URL = "https://panda-market-api.vercel.app/";

export async function getProducts({
order = "favoriteCount",
offset = 0,
limit = 10,
orderBy = "recent",
page = 1,
pageSize = 10,
}) {
const query = `order=${order}&offset=${offset}&limit=${limit}`;
const response = await fetch(
`https://panda-market-api.vercel.app/Products?${query}`
);
const query = `orderBy=${orderBy}&page=${page}&pageSize=${pageSize}`;
const response = await fetch(`${API_BASE_URL}Products?${query}`);
if (!response.ok) {
throw new Error("상품 목록을 불러오는 데 실패했습니다.");
}
Expand All @@ -15,9 +15,7 @@ export async function getProducts({
}

export async function getProductById(productId) {
const response = await fetch(
`https://panda-market-api.vercel.app/Products/${productId}`
);
const response = await fetch(`${API_BASE_URL}Products/${productId}`);
if (!response.ok) {
throw new Error("상세 페이지를 불러오는 데 실패했습니다.");
}
Expand All @@ -27,7 +25,7 @@ export async function getProductById(productId) {

export async function getCommentById(productId) {
const response = await fetch(
`https://panda-market-api.vercel.app/Products/${productId}/comments?limit=3`
`${API_BASE_URL}Products/${productId}/comments?limit=3`
);
if (!response.ok) {
throw new Error("댓글 목록을 불러오는 데 실패했습니다.");
Expand Down
18 changes: 18 additions & 0 deletions src/components/Button.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import styled from "styled-components";

const StyledCommonButton = styled.button`
height: 42px;
padding: 12px 20px;
border-radius: 8px;
margin: auto 0;
border: none;
color: var(--gray-50);
background-color: var(--blue-100);
cursor: pointer;
text-align: center;
align-items: center;
font-size: 18px;
font-weight: 600;
`;

export default StyledCommonButton;
11 changes: 0 additions & 11 deletions src/components/Nav.css

This file was deleted.

61 changes: 48 additions & 13 deletions src/components/Nav.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,55 @@
import "./Nav.css";
import pandaIcon from "../images/logo_image.png";
import styled from "styled-components";
import { Link } from "react-router-dom";
import StyledCommonButton from "./Button";

const StyledNavContainer = styled.nav`
display: flex;
align-items: center;
justify-content: space-between;
width: 100%;
padding: 10px 100px;
border-bottom: 1px solid var(--gray-200);
`;

const FrontNavContainer = styled.div`
display: flex;
align-items: center;
justify-content: space-between;
margin: 0;
`;

const StyledLogo = styled.img`
margin-right: 10px;
`;

const StyledLink = styled(Link)`
text-decoration: none;
margin-left: 10px;
color: var(--gray-600);
font-size: 18px;
font-weight: 700;
`;

const StyledButton = styled(StyledCommonButton)`
font-size: 16px;
font-weight: 700;
`;

function Nav() {
return (
<div className="nav-container">
<img className="logo-img" src={pandaIcon} alt="판다마켓 로고" />
<div className="link-container">
<a className="link link-community" href="https://www.google.com/">
자유게시판
</a>
<a className="link link-market" href="https://www.google.com/">
중고마켓
</a>
</div>
<button>로그인</button>
</div>
<StyledNavContainer>
<FrontNavContainer>
<Link to={`/`}>
<StyledLogo src={pandaIcon} alt="판다마켓 로고" />
</Link>
<div>
<StyledLink href="https://www.google.com/">자유게시판</StyledLink>
<StyledLink to={`/market`}>중고마켓</StyledLink>
</div>
</FrontNavContainer>
<StyledButton>로그인</StyledButton>
</StyledNavContainer>
);
Comment on lines +41 to +52
Copy link
Collaborator

Choose a reason for hiding this comment

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

확실히 이전보다 styled-components 숙련도가 올라왔네요! 👍

}

Expand Down
25 changes: 25 additions & 0 deletions src/css/global.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
html,
body {
width: 100%;
margin: 0;
padding: 0;
box-sizing: border-box;
}

:root {
/* Gray scale */
--gray-900: #111827;
--gray-800: #1f2937;
--gray-700: #374151;
--gray-600: #4b5563;
--gray-500: #6b7280;
--gray-400: #9ca3af;
--gray-200: #e5e7eb;
--gray-100: #f3f4f6;
--gray-50: #f9fafb;

/* Primary color */
--blue-100: #3692ff;
--blue-200: #1967d6;
--blue-300: #1251aa;
}
28 changes: 28 additions & 0 deletions src/hooks/useFetch.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { useState, useCallback, useEffect } from "react";

const useFetch = (fetchCallback, dependencies = []) => {
const [data, setData] = useState(null);
const [error, setError] = useState(null);
const [loading, setLoading] = useState(true);

const fetchData = useCallback(async () => {
setLoading(true);
try {
const result = await fetchCallback();
setData(result);
setError(null);
} catch (error) {
setError(error.message);
} finally {
setLoading(false);
}
}, dependencies);

useEffect(() => {
fetchData();
}, [fetchData]);

return { data, error, loading };
};

export default useFetch;
Comment on lines +1 to +28
Copy link
Collaborator

Choose a reason for hiding this comment

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

useFetch 좋아요! 파트 2때, 사용하신 react-queryuseQuery가 정말 편하게 많은걸 해준다는걸 느끼셨죠!? 이렇게 직접 만들면서 사용해야하거든요~

Binary file added src/images/empty_comment_img.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/images/x_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
48 changes: 0 additions & 48 deletions src/pages/AddItems/AddItemPage.css

This file was deleted.

Loading
Loading