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

Feature : 공통컴포넌트 - 헤더 및 레이아웃 작업 #5

Merged
merged 14 commits into from
Aug 4, 2023
Merged
Show file tree
Hide file tree
Changes from 11 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
Binary file added public/fonts/Pretendard-Bold.woff2
Binary file not shown.
Binary file added public/fonts/Pretendard-Medium.woff2
Binary file not shown.
Binary file added public/fonts/Pretendard-Regular.woff2
Binary file not shown.
Binary file added public/fonts/test.woff2
Binary file not shown.
3 changes: 3 additions & 0 deletions src/app/feed/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function Feed() {
return <>포즈피드</>;
}
6 changes: 1 addition & 5 deletions src/app/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,14 @@
box-sizing: border-box;
-ms-overflow-style: none; /* Hide scrollbar for IE and Edge */
scrollbar-width: none; /* Hide scrollbar for Firefox */
font-family: Noto Sans KR, serif;
font-family: Pretendard;
white-space: pre-wrap;
}

::-webkit-scrollbar {
display: none;
}

html {
font-size: 4vw;
}

@media (min-width: 420px) {
html {
font-size: 16px;
Expand Down
10 changes: 7 additions & 3 deletions src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import Header from '@/components/header';
import './globals.css';
import '../../styles/font.css';
import '../../styles/typography.css';

import type { Metadata } from 'next';

Expand Down Expand Up @@ -43,9 +46,10 @@ export const metadata: Metadata = {
export default function RootLayout({ children }: { children: React.ReactNode }) {
return (
<html lang="ko">
<body className="flex h-[100dvh] w-screen justify-center bg-black bg-slate-50">
<div className="relative h-full w-full max-w-450 overflow-y-scroll bg-white text-black">
{children}
<body className="flex h-[100dvh] w-screen touch-none justify-center bg-slate-100 py-px">
<div className="max-w-440 h-full w-full bg-white py-2 text-black drop-shadow-2xl">
seondal marked this conversation as resolved.
Show resolved Hide resolved
<Header />
Copy link
Collaborator

Choose a reason for hiding this comment

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

여기에 <Header />를 두게되면 모든 페이지에 공통으로 이 <Header />가 적용이 될거에요.여기에 두는 것보다는 각 폴더의 layout에 두는 것이 더 적합하다고 생각해요 !

Copy link
Member Author

@seondal seondal Aug 3, 2023

Choose a reason for hiding this comment

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

앱라우팅이 처음이라 잘 몰라서 일단 다른 프로젝트들이 네비게이션이나 헤더는 공통 레이아웃에 두는 것 같아 따라해봤습니다 ㅎㅎ...! 각 폴더의 레이아웃에 두면 오히려 중복이 많아질것 같아서요..
피그마에는 모든 경로에 이 헤더가 있는 것 같아서.. + 서브 헤더가 필요한 경우에는 라우팅으로 구분하려고 했는데 이 방법은 너무 비효율적일까요?

Copy link
Collaborator

Choose a reason for hiding this comment

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

최상단 layout.tsx는 현재 server component여서 pathname을 받아오지 못합니다.

따라서, path에 따라 다른 Header를 보여줄 수 없습니다.

leerob.io와 같은 방식으로 Header에서 다르게 보여주는 방법도 있지만, 저희는 포즈픽,톡,피드 외의 다른 페이지와 Header구성이 전혀 다르기에 적합한 방식이라 생각하지 않습니다.

묶어서 layout을 적용할 수 있는 Route Handler를 이용하면 좋을 것 같습니다. 이 부분은 제가 한 번 해볼게요 !

<div className="px-5 py-4">{children}</div>
</div>
</body>
</html>
Expand Down
2 changes: 1 addition & 1 deletion src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export default function Home() {
return <main className="">ssss</main>;
return <div>ssss</div>;
}
3 changes: 3 additions & 0 deletions src/app/pick/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function Pick() {
return <>포즈픽</>;
}
3 changes: 3 additions & 0 deletions src/app/talk/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function Talk() {
return <>포즈톡</>;
}
8 changes: 8 additions & 0 deletions src/components/header/MainHeader.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export default function MainHeader() {
return (
<div className="flex h-12 items-center justify-between">
<h4>PosePicker</h4>
<div>햄버거아이콘</div>
</div>
);
}
33 changes: 33 additions & 0 deletions src/components/header/Tab.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
'use client';

import Link from 'next/link';
import { usePathname } from 'next/navigation';

const tabData = [
{ path: '/pick', title: '포즈픽' },
{ path: '/talk', title: '포즈톡' },
{ path: '/feed', title: '포즈피드' },
];
seondal marked this conversation as resolved.
Show resolved Hide resolved

export default function Tab() {
const path = usePathname();

return (
<nav className="flex items-center gap-4">
{tabData.map((item) =>
item.path === path ? (
<div key={item.path}>
<div className="py-3">
<h5 className="text-brand">{item.title}</h5>
</div>
<div className="border-b-main-violet relative top-0.5 border-b-2" />
seondal marked this conversation as resolved.
Show resolved Hide resolved
</div>
) : (
<Link href={item.path} className="py-3" key={item.path}>
<h5 className="text-secondary">{item.title}</h5>
</Link>
Copy link
Collaborator

Choose a reason for hiding this comment

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

현재 py-3, key={item.path}코드가 중복되고 있습니다.

이러한 코드를 묶어주면 더 가독성이 있고, 유지보수 측면에서도 좋을 것 같아요.

Copy link
Collaborator

Choose a reason for hiding this comment

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

{tabData.map((item) => (
  <div key={item.path} className="py-3">
    {item.path === path ? (
      <h5 className="text-brand">{item.title}</h5>
    ) : (
      <Link href={item.path}>
        <h5 className="text-secondary">{item.title}</h5>
      </Link>
    )}
  </div>
))}

제가 짜본 코드입니다. 참고 부탁해요 !

Copy link
Member Author

Choose a reason for hiding this comment

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

tailwind는 중복 처리에 불리하다고 생각했는데 규성님처럼 하면 해결되겠군요..! 감사합니다 적용하겠습니다!

)
)}
</nav>
);
}
11 changes: 11 additions & 0 deletions src/components/header/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import MainHeader from './MainHeader';
import Tab from './Tab';

export default function Header() {
return (
<div className="border-b-divider border-b-2 px-5">
<MainHeader />
<Tab />
</div>
);
seondal marked this conversation as resolved.
Show resolved Hide resolved
}
31 changes: 31 additions & 0 deletions src/constants/color.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
export const COLOR = {
white: '#FFFFFF',
gray: {
30 : '#F9F9FB',
50 : '#F7F7FA',
100 :'#F0F0F5',
200 : '#E8E8EE',
300 :'#E1E1E8',
400 :'#CDCED6',
500 :'#A9ABB8',
600 :'#858899',
700 :'#525463',
800 :'#3E404C',
900 :'#2B2D36',
950 :'#252730',
},
black: '#141218',
violet: {
50 :'#141218',
100 :'#E2D9FC',
200 :'#C8B8FA',
300 :'#B29BF8',
400 :'#9C7FF5',
500 :'#8662F3',
600 :'#744CEB',
700 :'#5B2EE0',
800 :'#4B25C1',
900 :'#412499',
950 :'#21005D',
}
} as const;
17 changes: 17 additions & 0 deletions styles/font.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
@font-face {
font-family: "Pretendard";
font-weight: 700;
src: url('/fonts/Pretendard-Bold.woff2') format("woff2");
}

@font-face {
font-family: "Pretendard";
font-weight: 500;
src: url("/fonts/Pretendard-Medium.woff2") format("woff2");
}

@font-face {
font-family: "Pretendard";
font-weight: 400;
src: url("/fonts/Pretendard-Regular.woff2") format("woff2");
}
seondal marked this conversation as resolved.
Show resolved Hide resolved
37 changes: 31 additions & 6 deletions styles/theme/colors.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,32 @@
import { COLOR } from "../../src/constants/color";

export const colors = {
white: '#FFFFFF',
gray: {
'030': '#F9F9FB',
'050': '#F7F7FA',
},
} as const;
// bg
"white": COLOR.white,
"sub-white": COLOR.gray[50],
"divider": COLOR.gray[100],

// border
"default": COLOR.gray[300],
"active": COLOR.gray[900],
"disabled": COLOR.gray[100],

// brand colors
"main-violet-light": COLOR.violet[300],
"main-violet": COLOR.violet[500],
"main-violet-dark": COLOR.violet[700],

// text
"cto": COLOR.black,
"brand": COLOR.violet[500],
"primary":COLOR.gray[900],
"secondary": COLOR.gray[700],
"tertiary": COLOR.gray[500],
"caption": COLOR.gray[400],

// icon
"icon-default": COLOR.gray[800],
"icon-hover": COLOR.gray[600],
"icon-disabled": COLOR.gray[500],

seondal marked this conversation as resolved.
Show resolved Hide resolved
} as const
49 changes: 49 additions & 0 deletions styles/typography.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
h1 {
seondal marked this conversation as resolved.
Show resolved Hide resolved
font-weight: 700;
font-size: 3rem;
line-height: 3.75rem;
letter-spacing: -0.4px;
}
h2 {
font-weight: 700;
font-size: 2rem;
line-height: 3rem;
letter-spacing: -0.4px;
}
h3 {
font-weight: 700;
font-size: 1.5rem;
line-height: 2.25rem;
letter-spacing: -0.3px;
}
h4 {
font-weight: 700;
font-size: 1.25rem;
line-height: 1.875rem;
letter-spacing: -0.2px;
}

/*
subtitle-1 에 해당하는 타이포입니다.
hifi에서 subtitle-2, subtitle-3은 아직 쓰이지 않는 것 같아서 임의로 h5로 사용했어요
*/
h5 {
font-weight: 500;
font-size: 1rem;
line-height: 1.5rem;
letter-spacing: -0.2px;
}

p {
font-weight: 400;
font-size: 1rem;
line-height: 1.5rem;
letter-spacing: -0.1px;
}

caption {
font-weight: 500;
font-size: 0.75rem;
line-height: 1.125rem;
letter-spacing: 0.4px;
}
3 changes: 1 addition & 2 deletions tailwind.config.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
const { colors, pxToRemTailwind, animations } = require('./styles/theme');
const { colors, animations } = require('./styles/theme');

/** @type {import('tailwindcss').Config} */
module.exports = {
content: ['./src/**/*.{js,jsx,ts,tsx}'],
theme: {
extend: {
...pxToRemTailwind,
colors,
keyframes: animations,
animation: {
Expand Down