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

[정해찬] sprint 8 #117

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
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.DS_Store
._.DS_Store
**/.DS_Store
**/._.DS_Store

pandamarket/
.vscode/
Copy link
Collaborator

Choose a reason for hiding this comment

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

.vscode 폴더 내용은 프로젝트의 성격에 따라 공유되어야할때도 있긴 합니다.

next_sprint/node_modules/
3 changes: 3 additions & 0 deletions next_sprint/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "next/core-web-vitals"
}
40 changes: 40 additions & 0 deletions next_sprint/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/versions

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# env files (can opt-in for committing if needed)
.env*

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts
40 changes: 40 additions & 0 deletions next_sprint/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://nextjs.org/docs/pages/api-reference/create-next-app).

## Getting Started

First, run the development server:

```bash
npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun dev
```

Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.

You can start editing the page by modifying `pages/index.js`. The page auto-updates as you edit the file.

[API routes](https://nextjs.org/docs/pages/building-your-application/routing/api-routes) can be accessed on [http://localhost:3000/api/hello](http://localhost:3000/api/hello). This endpoint can be edited in `pages/api/hello.js`.

The `pages/api` directory is mapped to `/api/*`. Files in this directory are treated as [API routes](https://nextjs.org/docs/pages/building-your-application/routing/api-routes) instead of React pages.

This project uses [`next/font`](https://nextjs.org/docs/pages/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel.

## Learn More

To learn more about Next.js, take a look at the following resources:

- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
- [Learn Next.js](https://nextjs.org/learn-pages-router) - an interactive Next.js tutorial.

You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome!

## Deploy on Vercel

The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.

Check out our [Next.js deployment documentation](https://nextjs.org/docs/pages/building-your-application/deploying) for more details.
11 changes: 11 additions & 0 deletions next_sprint/components/Button.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

export default function Button({ children, handleClick, disabled = false}) {
return (
<>
<button onClick={handleClick} disabled={disabled}
className={`${ disabled ? "bg-gray-400" : "bg-custom_blue"} w-[88px] h-[42px] rounded-lg px-[23px] py-3 text-base font-semibold leading-[19.09px] text-white`}>
{children}
</button>
</>
);
}
Comment on lines +1 to +11
Copy link
Collaborator

Choose a reason for hiding this comment

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

생각보다 Button은 다양한 형태가 있고, 단 하나의 형태를 위해 컴포넌트를 사용하실거라면 이렇게 파일로 만드실 필요는 없습니다. 게다가 width, height도 픽셀고정이라 좋은 컴포넌트 형태가 아닙니다.

57 changes: 57 additions & 0 deletions next_sprint/components/DropDown.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import { useState } from "react";
import Image from "next/image";

export default function DropDown({
handleOptionClick,
sortOption,
selectedOption,
isOpen,
setIsOpen,
Comment on lines +8 to +9
Copy link
Collaborator

Choose a reason for hiding this comment

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

나중에 Dropdown 컴포넌트가 깊어지거나 할 가능성이 있는데요, 그럴땐 이렇게 props drilling을 유발할 수 있는 prop보다는 Context 사용을 고려해보세요.

isKebab,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Dropdown의 성질이 kebab만 있는게 아니고 다른 형태도 있을 수 있습니다. type={"kebab"} 이런식으로 prop을 받게끔 한다면 좀 더 명확하고 확장성있겠습니다.

}) {
const toggleOpen = () => setIsOpen((prev) => !prev);

return (
<div className="relative w-40">
{isKebab ? (
<button onClick={toggleOpen} className="pl-[155px]">
<Image src="/img/btn_dropDown.png" width={3} height={13} alt="드롭다운 케밥 아이콘" />
</button>
) : (
<button
onClick={toggleOpen}
className="w-full text-left px-4 py-2 border rounded-lg bg-white focus:outline-none"
>
{selectedOption}
</button>
)}

{!isKebab && (
<Image
src="/img/drop_arrow.png"
alt="drop-arrow"
width={15.7}
height={14.2}
className="absolute right-5 top-4"
/>
)}
Comment on lines +16 to +37
Copy link
Collaborator

Choose a reason for hiding this comment

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

isKebab 조건이 둘로 나뉩니다. 이런 경우, 차라리 if(isKebab) return (... ) 이후 return (...) 하는 느낌으로 아예 isKebab일 때의 모습을 한쪽으로 몰아놓는게 가독성과 Testability가 좋습니다.


{isOpen && (
<ul className="absolute left-0 mt-1 w-full border rounded-lg bg-white shadow-md z-10">
<li
className="px-4 py-2 hover:bg-gray-100 cursor-pointer"
onClick={() => handleOptionClick(sortOption[0])}
>
{sortOption[0]}
</li>
<li
className="px-4 py-2 hover:bg-gray-100 cursor-pointer"
onClick={() => handleOptionClick(sortOption[1])}
>
{sortOption[1]}
</li>
</ul>
)}
</div>
);
}
28 changes: 28 additions & 0 deletions next_sprint/components/Footer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
export default function Footer() {
return (
<footer className="flex bg-custom_coolGray900 h-40 mt-auto justify-around">
<p className="text-gray-400 mt-8">©codeit - 2024</p>
<div className="flex space-x-6 mt-8">
<p className="text-gray-200">Privacy Policy</p>
<p className="text-gray-200">FAQ</p>
</div>
<div className="flex gap-3 mt-8">
<a href="http://facebook.com" rel="noopener noreferrer" target="_blank" className="social_box">
<img src="/img/facebook.png" alt="facebook" />
</a>

<a href="http://twitter.com" rel="noopener noreferrer" target="_blank" className="social_box">
<img src="/img/twitter.png" alt="twitter" />
</a>

<a href="http://youtube.com" rel="noopener noreferrer" target="_blank" className="social_box">
<img src="/img/youtube.png" alt="youtube" />
</a>

<a href="http://instagram.com" rel="noopener noreferrer" target="_blank" className="social_box">
<img src="/img/insta.png" alt="instagram" />
</a>
</div>
</footer>
);
}
38 changes: 38 additions & 0 deletions next_sprint/components/Header.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import Image from "next/image";
import Link from "next/link";
import Button from "./Button";
import { useRouter } from "next/router";
import { useEffect, useState } from "react";

export default function Header() {
const router = useRouter();

const handleClick = () => {
router.push('/login');
}

return (
<>
<header className="flex fixed w-full flex-wrap items-center px-4 lg:px-[200px] sm:px-6 h-[70px] border-b-[1px] bg-white z-[1000]">
<Link href="/" >
<Image src="/img/panda_logo.png" alt="logo" width={153} height={51} />
</Link>

<div className="flex space-x-8 ml-[8%]" >
<Link href="/community/community" className={`${router.pathname.includes('/community')?'text-custom_blue':'text-primary'}
font-bold text-lg`}>
자유게시판
</Link>
<Link href="/market" className={`${router.pathname==='/market'?'text-custom_blue':'text-primary'}
font-bold text-lg`}>
중고마켓
</Link>
</div>

<div className="ml-auto">
<Button handleClick={handleClick}>로그인</Button>
</div>
</header>
</>
);
}
7 changes: 7 additions & 0 deletions next_sprint/jsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"compilerOptions": {
"paths": {
"@/*": ["./*"]
}
}
}
Comment on lines +1 to +7
Copy link
Collaborator

Choose a reason for hiding this comment

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

보통 src 밑의 파일들을 absolute import합니다.

6 changes: 6 additions & 0 deletions next_sprint/next.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
};

export default nextConfig;
Loading