-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #212 from KJongHwa/React-김종화
[김종화] Sprint7
- Loading branch information
Showing
49 changed files
with
17,205 additions
and
1,636 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,43 +1,32 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<html lang="ko"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
<meta name="theme-color" content="#000000" /> | ||
<meta | ||
name="description" | ||
content="Web site created using create-react-app" | ||
/> | ||
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" /> | ||
<!-- | ||
manifest.json provides metadata used when your web app is installed on a | ||
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/ | ||
--> | ||
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" /> | ||
<!-- | ||
Notice the use of %PUBLIC_URL% in the tags above. | ||
It will be replaced with the URL of the `public` folder during the build. | ||
Only files inside the `public` folder can be referenced from the HTML. | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>판다마켓</title> | ||
|
||
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will | ||
work correctly both with client-side routing and a non-root public URL. | ||
Learn how to configure a non-root public URL by running `npm run build`. | ||
<!-- | ||
Font preloading | ||
- 페이지가 처음 로딩될 때 텍스트가 순간적으로 깜빡이거나 바뀌는 듯한 현상을 보신 적이 있으신가요? (Flash of Unstyled Text, FOUT) | ||
브라우저가 지정된 폰트를 다운로드 받는 동안 임시로 대체 폰트("fallback font")를 사용하기 때문인데요, 폰트를 preload하면 텍스트 렌더링을 보다 매끄럽게 할 수 있습니다. | ||
- 브라우저는 rel="preload"로 지정된 리소스를 우선적으로 준비합니다. | ||
- 폰트, 페이지 상단의 이미지, 가장 먼저 실행되어야 하는 스크립트 등에 preload 속성을 사용하는 경우가 많아요. | ||
- href의 리소스 유형에 따라 <link>의 `as` 속성값을 정해야 해요. 일반적인 폰트 파일(예: .woff, .ttf 등)이라면 as="font"겠지만, 우리가 사용하는 웹폰트는 css 형식이기 때문에 as="style"을 사용합니다. | ||
--> | ||
<title>React App</title> | ||
<link | ||
rel="preload" | ||
href="https://cdn.jsdelivr.net/gh/orioncactus/[email protected]/dist/web/static/pretendard.min.css" | ||
as="style" | ||
onload="this.onload=null;this.rel='stylesheet'" | ||
/> | ||
<!-- 간혹 보안 등의 이슈로 자바스크립트를 지원하지 않는 브라우저 환경에서도 최소한의 스타일이 로딩될 수 있도록 합니다. --> | ||
<noscript | ||
><link | ||
rel="stylesheet" | ||
href="https://cdn.jsdelivr.net/gh/orioncactus/[email protected]/dist/web/static/pretendard.min.css" | ||
/></noscript> | ||
</head> | ||
<body> | ||
<noscript>You need to enable JavaScript to run this app.</noscript> | ||
<div id="root"></div> | ||
<!-- | ||
This HTML file is a template. | ||
If you open it directly in the browser, you will see an empty page. | ||
You can add webfonts, meta tags, or analytics to this file. | ||
The build step will place the bundled scripts into the <body> tag. | ||
To begin the development, run `npm start` or `yarn start`. | ||
To create a production bundle, use `npm run build` or `yarn build`. | ||
--> | ||
</body> | ||
</html> |
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,26 @@ | ||
export async function getProducts(params = {}) { | ||
const { productid, comments } = params; | ||
const query = new URLSearchParams(params).toString(); | ||
|
||
try { | ||
let url = "https://panda-market-api.vercel.app/products"; | ||
|
||
if (productid) { | ||
url += `/${productid}`; | ||
} | ||
|
||
if (comments && productid) { | ||
url += `/comments`; | ||
} | ||
|
||
const response = await fetch(`${url}?${query}`); | ||
if (!response.ok) { | ||
throw new Error(`HTTP 오류: ${response.status}`); | ||
} | ||
const body = await response.json(); | ||
return body; | ||
} catch (error) { | ||
console.error("상품을 불러오는데 실패했습니다.:", error); | ||
throw error; | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,45 @@ | ||
.headerLeft { | ||
display: flex; | ||
align-items: center; | ||
} | ||
|
||
.headerLogo { | ||
margin-right: 16px; | ||
} | ||
|
||
.globalHeader nav ul { | ||
display: flex; | ||
list-style: none; | ||
gap: 8px; | ||
font-weight: bold; | ||
font-size: 16px; | ||
color: #4b5563; | ||
} | ||
|
||
.globalHeader nav ul li a:hover { | ||
color: var(--blue); | ||
} | ||
|
||
.loginLink { | ||
font-size: 16px; | ||
font-weight: 600; | ||
border-radius: 8px; | ||
padding: 11.5px 23px; | ||
} | ||
|
||
@media (min-width: 768px) { | ||
.globalHeader nav ul { | ||
gap: 36px; | ||
font-size: 18px; | ||
} | ||
|
||
.headerLogo { | ||
margin-right: 35px; | ||
} | ||
} | ||
|
||
@media (min-width: 1280px) { | ||
.headerLogo { | ||
margin-right: 47px; | ||
} | ||
} |
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 React from "react"; | ||
import Logo from "../../assets/images/logo/logo.svg"; | ||
import { Link, NavLink, useLocation } from "react-router-dom"; | ||
import "./Header.css"; | ||
|
||
// react-router-dom의 NavLink를 이용하면 활성화된 네비게이션 항목을 하이라이트해줄 수 있어요! | ||
function getLinkStyle({ isActive }) { | ||
return { color: isActive ? "var(--blue)" : undefined }; | ||
} | ||
|
||
function Header() { | ||
const location = useLocation(); // 현재 경로 정보 | ||
|
||
return ( | ||
<header className="globalHeader"> | ||
<div className="headerLeft"> | ||
<Link to="/" className="headerLogo" aria-label="홈으로 이동"> | ||
<img src={Logo} alt="판다마켓 로고" width="153" /> | ||
</Link> | ||
|
||
<nav> | ||
<ul> | ||
<li> | ||
<NavLink to="/community" style={getLinkStyle}> | ||
자유게시판 | ||
</NavLink> | ||
</li> | ||
<li> | ||
{/* React Router v6 이전 버전에서는 NavLink `isActive` prop으로 바로 스타일 정보를 넣어줄 수 있었지만, 최신 버전에서는 className 또는 style을 이용해야 해요 */} | ||
{/* /additem 페이지에서도 네이게이션의 '중고마켓' 링크 하이라이트 */} | ||
<NavLink | ||
to="/items" | ||
style={({ isActive }) => | ||
location.pathname === "/additem" || isActive | ||
? { color: "var(--blue)" } | ||
: {} | ||
} | ||
> | ||
중고마켓 | ||
</NavLink> | ||
</li> | ||
</ul> | ||
</nav> | ||
</div> | ||
|
||
<Link to="/login" className="loginLink button"> | ||
로그인 | ||
</Link> | ||
</header> | ||
); | ||
} | ||
|
||
export default Header; |
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,27 @@ | ||
import React from "react"; | ||
import styled from "styled-components"; | ||
import { ReactComponent as CloseIcon } from "../../assets/images/icons/ic_x.svg"; | ||
|
||
const Button = styled.button` | ||
background-color: ${({ theme }) => theme.colors.gray[0]}; | ||
width: 20px; | ||
height: 20px; | ||
border-radius: 50%; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
&:hover { | ||
background-color: ${({ theme }) => theme.colors.blue[0]}; | ||
} | ||
`; | ||
|
||
function DeleteButton({ onClick, label }) { | ||
return ( | ||
<Button aria-label={`${label} 삭제`} onClick={onClick}> | ||
<CloseIcon /> | ||
</Button> | ||
); | ||
} | ||
|
||
export default DeleteButton; |
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 @@ | ||
.sortButtonWrapper { | ||
position: relative; | ||
} | ||
|
||
.sortDropdownTriggerButton { | ||
border: 1px solid #e5e7eb; | ||
border-radius: 12px; | ||
padding: 9px; | ||
margin-left: 8px; | ||
} | ||
|
||
.dropdownMenu { | ||
position: absolute; | ||
top: 110%; | ||
right: 0; | ||
background: #fff; | ||
border-radius: 8px; | ||
border: 1px solid #e5e7eb; | ||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); | ||
z-index: 99; | ||
} | ||
|
||
.dropdownItem { | ||
padding: 12px 44px; | ||
border-bottom: 1px solid #e5e7eb; | ||
font-size: 16px; | ||
color: #1f2937; | ||
cursor: pointer; | ||
} | ||
|
||
.dropdownItem:last-child { | ||
border-bottom: none; | ||
} |
Oops, something went wrong.