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

React 김주동 sprint6 #95

Closed
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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
# production
/build

# bacup
/backups
.bak

# misc
.DS_Store
.env.local
Expand Down
132 changes: 118 additions & 14 deletions package-lock.json

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

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "fe10-sprint-mission5",
"name": "fe10-sprint-mission6",
"version": "0.1.0",
"private": true,
"dependencies": {
Expand All @@ -10,6 +10,7 @@
"react-dom": "^18.2.0",
"react-router-dom": "^6.22.3",
"react-scripts": "5.0.1",
"styled-components": "^6.1.8",
"web-vitals": "^2.1.4"
},
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="keywords" content="Codeit - FE10 Sprint Mission 5">
<meta name="keywords" content="Codeit - FE10 Sprint Mission 6">
<meta name="author" content="[email protected]">
<meta property="og:type" content="website" />
<meta property="og:title" content="판다마켓" />
Expand Down
18 changes: 18 additions & 0 deletions public/index.html.bak
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="keywords" content="Codeit - FE10 Sprint Mission 5">
<meta name="author" content="[email protected]">
<meta property="og:type" content="website" />
<meta property="og:title" content="판다마켓" />
<meta property="og:description" content="일상의 모든 물건을 거래해 보세요" />
<meta property="og:image" content="/og-image.png" />
<meta property="og:url" content="" />
<title>판다마켓</title>
</head>
<body>
<div id="root"></div>
</body>
</html>
18 changes: 18 additions & 0 deletions src/api/itemApi.js.bak
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
export async function getProducts(params = {}) {
// Using URLSearchParams allows for easy automatic encoding of parameter values.
const query = new URLSearchParams(params).toString();

try {
const response = await fetch(
`https://panda-market-api.vercel.app/products?${query}`
);
if (!response.ok) {
throw new Error(`HTTP error: ${response.status}`);
}
const body = await response.json();
return body;
} catch (error) {
console.error("Failed to fetch products:", error);
throw error;
}
}
4 changes: 4 additions & 0 deletions src/assets/images/icons/ic_plus.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 src/assets/images/icons/ic_x.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 11 additions & 2 deletions src/components/Layout/Header.jsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import React from 'react'
import Logo from '../../assets/images/logo/logo.svg'
import { Link, NavLink } from 'react-router-dom'
import { Link, NavLink, useLocation } from 'react-router-dom'
import './Header.css'

function getLinkStyle ({ isActive }) {
return { color: isActive ? 'var(--blue)' : undefined }
}

function Header () {
const location = useLocation() // 현재 경로 정보

return (
<header className='globalHeader'>
<div className='headerLeft'>
Expand All @@ -23,7 +25,14 @@ function Header () {
</NavLink>
</li>
<li>
<NavLink to='/items' style={getLinkStyle}>
<NavLink
to='/items'
style={({ isActive }) =>
location.pathname === '/additem' || isActive
? { color: 'var(--blue)' }
: {}
}
>
중고마켓
</NavLink>
</li>
Expand Down
53 changes: 53 additions & 0 deletions src/components/Layout/Header.jsx.bak
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";


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>


<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;
Loading
Loading