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

[SP2] blog tab navigation #228

Merged
merged 37 commits into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
7145e8a
feat : blog 탭 생성
f0rever0 Oct 18, 2023
8bbcfe5
style : change header style
f0rever0 Oct 18, 2023
94a89ee
feat : 블로그 탭 네비게이션
f0rever0 Oct 18, 2023
12efe7d
style : 전체적인 컬러 코드 변경
f0rever0 Oct 18, 2023
78c2717
feat : blog 탭 생성
f0rever0 Oct 18, 2023
80adbca
style : change header style
f0rever0 Oct 18, 2023
c10ea97
feat : 블로그 탭 네비게이션
f0rever0 Oct 18, 2023
9c116aa
style : 전체적인 컬러 코드 변경
f0rever0 Oct 18, 2023
d9ea44c
Merge branch 'feat/#218-blog-tab-navigation' of https://github.com/so…
f0rever0 Oct 19, 2023
88ae4c1
refactor : change to inline export
f0rever0 Oct 19, 2023
4c2e5f6
refactor: apply color systems
f0rever0 Oct 19, 2023
babab4f
style : header 선택한 탭에 밑줄
f0rever0 Oct 19, 2023
85aa5ef
fix : change constant color
f0rever0 Oct 19, 2023
5c178a1
fix : blog tab mobile boder style
f0rever0 Oct 20, 2023
8966d63
fix : blog tab description
f0rever0 Oct 20, 2023
7dc7385
feat : blog 탭 생성
f0rever0 Oct 18, 2023
43776ca
style : change header style
f0rever0 Oct 18, 2023
8f2e09a
feat : 블로그 탭 네비게이션
f0rever0 Oct 18, 2023
dc3d174
style : 전체적인 컬러 코드 변경
f0rever0 Oct 18, 2023
51d8a5e
feat : blog 탭 생성
f0rever0 Oct 18, 2023
190d379
refactor : change to inline export
f0rever0 Oct 19, 2023
c02989e
refactor: apply color systems
f0rever0 Oct 19, 2023
2064b1e
style : header 선택한 탭에 밑줄
f0rever0 Oct 19, 2023
51d8f9a
fix : change constant color
f0rever0 Oct 19, 2023
d0557d7
fix : blog tab mobile boder style
f0rever0 Oct 20, 2023
5c31a0d
fix : blog tab description
f0rever0 Oct 21, 2023
bb6d10a
style : change tab style
f0rever0 Oct 21, 2023
6058f69
Merge branch 'feat/#218-blog-tab-navigation' of https://github.com/so…
f0rever0 Oct 21, 2023
59cc555
fix : color 상수 코드 사용
f0rever0 Oct 21, 2023
7f2037a
style : footer color 상수로 바꾸기
f0rever0 Oct 21, 2023
74553a9
refactor : change folder name
f0rever0 Oct 21, 2023
3f1bfb4
feat : tab description 어절 단위 줄바꿈
f0rever0 Oct 21, 2023
afe94b6
chore : sopt color libaray 적용
f0rever0 Oct 22, 2023
dc96bc5
style : header 디자인 변경
f0rever0 Oct 22, 2023
5423574
feat : add blog tab title hover style
f0rever0 Oct 22, 2023
1ed8aaf
chore : blogTab 변수명 수정
f0rever0 Oct 22, 2023
173801f
Merge branch 'develop' into feat/#218-blog-tab-navigation
f0rever0 Oct 23, 2023
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
2 changes: 1 addition & 1 deletion src/components/Footer/OriginFooter/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { mainColor } from '@src/lib/styles/colors';
export const Root = styled.footer`
width: 100%;
min-height: 162px;
background-color: #2a2a2a;
background-color: #17171c;
Copy link
Member

Choose a reason for hiding this comment

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

요것 이제 새 컬러 상수를 사용해 주셔요..!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

요 컬러는 mds에 없어서...! 색상코드를 넣었습니다! pd에게 다시 확인하고 커밋해둘게요!


/* 태블릿 + 데스크탑 뷰 */
@media (min-width: 766px) {
Expand Down
150 changes: 10 additions & 140 deletions src/components/Header/Desktop/DesktopHeader.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
import styled from '@emotion/styled';
import Link from 'next/link';
import { css } from '@emotion/react';
import { useCallback, useEffect, useState } from 'react';
import { LOGO_IMAGE_URL } from '@src/assets/mainLogo/base64_logo';
import useHeader from '@src/hooks/useHeader';
import { GrowDown } from '@src/lib/styles/animation';
import { menuTapList } from '../menuTapList';
import { BaseMenuTap, MenuTapType, ParentMenuTap } from '../types';
import { MenuTapType, SingleMenuTap } from '../types';

function DesktopHeader() {
const { handleClickLogo, handleIsSelected } = useHeader();
const [isSubTapOpened, setIsSubTapOpened] = useState(false);

return (
<>
Expand All @@ -20,147 +18,44 @@ function DesktopHeader() {
</CenterAligner>
<MenuTitlesWrapper>
{menuTapList.map((menuTap) => (
<MenuTap
key={menuTap.title}
menuTap={menuTap}
handleIsSelected={handleIsSelected}
isSubTapOpened={isSubTapOpened}
setIsSubTapOpened={setIsSubTapOpened}
/>
<MenuTap key={menuTap.title} menuTap={menuTap} handleIsSelected={handleIsSelected} />
))}
</MenuTitlesWrapper>
</Wrapper>
{isSubTapOpened && <SubMenuWrapper />}
</>
);
}

type MenuTapProps = {
menuTap: BaseMenuTap;
menuTap: SingleMenuTap;
handleIsSelected: (path: string | string[]) => boolean;
isSubTapOpened: boolean;
setIsSubTapOpened: (isOpened: boolean) => void;
};

function MenuTap({ menuTap, handleIsSelected, isSubTapOpened, setIsSubTapOpened }: MenuTapProps) {
function MenuTap({ menuTap, handleIsSelected }: MenuTapProps) {
switch (menuTap.type) {
case MenuTapType.Anchor:
return (
<MenuTitleAnchor
href={menuTap.href}
target="_blank"
rel="noreferrer"
onClick={() => setIsSubTapOpened(false)}
onMouseEnter={() => setIsSubTapOpened(false)}
>
<MenuTitleAnchor href={menuTap.href} target="_blank" rel="noreferrer">
{menuTap.title}
</MenuTitleAnchor>
);
case MenuTapType.Router:
return (
<MenuTitle
isSelected={handleIsSelected(menuTap.href)}
onClick={() => setIsSubTapOpened(false)}
onMouseEnter={() => setIsSubTapOpened(false)}
>
<MenuTitle isSelected={handleIsSelected(menuTap.href)}>
<Link href={menuTap.href}>{menuTap.title}</Link>
</MenuTitle>
);
case MenuTapType.Parent:
return (
<ParentMenu
menuTap={menuTap}
handleIsSelected={handleIsSelected}
isSubTapOpened={isSubTapOpened}
setIsSubTapOpened={setIsSubTapOpened}
/>
);
}
}

type ParentMenuProps = {
menuTap: ParentMenuTap;
handleIsSelected: (path: string | string[]) => boolean;
isSubTapOpened: boolean;
setIsSubTapOpened: (isOpened: boolean) => void;
};

function ParentMenu({
menuTap,
handleIsSelected,
isSubTapOpened,
setIsSubTapOpened,
}: ParentMenuProps) {
const [isOpened, setIsOpened] = useState(false);

const closeSubTap = useCallback(() => {
setIsSubTapOpened(false);
setIsOpened(false);
}, [setIsSubTapOpened, setIsOpened]);

const onMouseIn = () => {
setIsSubTapOpened(true);
setIsOpened(true);
};

useEffect(() => {
if (!isSubTapOpened) {
setIsOpened(false);
}
}, [isSubTapOpened]);

useEffect(() => {
if (isSubTapOpened) {
document.addEventListener('click', closeSubTap);
}
return () => {
document.removeEventListener('click', closeSubTap);
};
}, [closeSubTap, isSubTapOpened]);

return (
<ParentMenuTitle
isSelected={handleIsSelected(menuTap.children.map((t) => t.href))}
isOpened={isOpened}
onMouseEnter={onMouseIn}
onClick={(e) => e.stopPropagation()}
>
{menuTap.title}
{isOpened && (
<SubMenu>
{menuTap.children.map((c) => {
switch (c.type) {
case MenuTapType.Anchor:
return (
<MenuTitle type="sub" key={c.title}>
<MenuTitleAnchor href={c.href} target="_blank" rel="noreferrer">
{c.title}
</MenuTitleAnchor>
</MenuTitle>
);
case MenuTapType.Router:
return (
<MenuTitle type="sub" isSelected={handleIsSelected(c.href)} key={c.title}>
<Link href={c.href}>{c.title}</Link>
</MenuTitle>
);
}
})}
</SubMenu>
)}
</ParentMenuTitle>
);
}

interface MenuTitleProps {
isSelected?: boolean;
isOpened?: boolean;
type?: 'main' | 'sub';
}

export const Wrapper = styled.div`
max-width: 1280px;
width: 90%;
max-width: 1200px;
width: 100%;
display: flex;
justify-content: space-between;
`;
Expand All @@ -175,21 +70,6 @@ export const SubMenuWrapper = styled.div`
animation: growdown 0.4s forwards;
`;

const SubMenu = styled.div`
position: absolute;
z-index: 1;
display: flex;
align-items: center;
justify-content: center;

width: 300px;
top: 80px;
left: 25%; /* it is bad practice */
transform: translateX(-50%);

cursor: default;
`;

export const CenterAligner = styled.div`
display: flex;
align-items: center;
Expand Down Expand Up @@ -256,24 +136,14 @@ export const MenuTitle = styled.div<MenuTitleProps>`
line-height: 36px;
font-weight: ${({ isSelected }) => (isSelected ? '700' : '500')};

color: ${({ type, isSelected }) =>
type === 'sub' ? (isSelected ? '#fff' : 'rgba(255, 255, 255, 0.5)') : '#fff'};
color: ${({ isSelected }) => (isSelected ? '#fff' : 'rgba(255, 255, 255, 0.5)')};
cursor: pointer;
position: relative;
${({ isOpened }) => isOpened && menuTitleUnderline};
${({ isSelected }) => isSelected && menuTitleUnderline}

&:not(:last-child) {
padding-right: 40px;
}

&:hover {
color: #fff;
${({ type }) => type !== 'sub' && menuTitleUnderline}
}
`;

const ParentMenuTitle = styled(MenuTitle)`
position: relative;
`;

export default DesktopHeader;
4 changes: 2 additions & 2 deletions src/components/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import MobileHeader from './Mobile/MobileHeader';
import styles from './header.module.scss';

export function Header() {
const isDesktop = useIsDesktop('992px');
const isTablet = useIsTablet('766px', '991.9px');
const isDesktop = useIsDesktop('940px');
const isTablet = useIsTablet('768px', '939px');
const isMobile = useIsMobile();

return (
Expand Down
16 changes: 2 additions & 14 deletions src/components/Header/Mobile/HeaderMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Link from 'next/link';
import { useEffect } from 'react';
import useHeader from '@src/hooks/useHeader';
import { menuTapList } from '../menuTapList';
import { BaseMenuTap, MenuState, MenuTapType } from '../types';
import { MenuState, MenuTapType, SingleMenuTap } from '../types';
import * as S from './HeaderMenu.style';

function useNoScroll(isMenuShown: MenuState) {
Expand All @@ -27,7 +27,7 @@ interface HeaderMenuProps {
}

type MenuTapProps = {
menuTap: BaseMenuTap;
menuTap: SingleMenuTap;
handleIsSelected: (path: string) => boolean;
};

Expand All @@ -47,18 +47,6 @@ function MenuTap({ menuTap, handleIsSelected }: MenuTapProps) {
<Link href={menuTap.href}>{menuTap.title}</Link>
</S.MenuTitle>
);
case MenuTapType.Parent:
return (
<>
{menuTap.children.map((childMenuTap) => (
<MenuTap
key={childMenuTap.title}
menuTap={childMenuTap}
handleIsSelected={handleIsSelected}
/>
))}
</>
);
}
}

Expand Down
7 changes: 4 additions & 3 deletions src/components/Header/header.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,20 @@
justify-content: center;
align-items: center;
position: fixed;
background-color: rgba(22, 22, 28, 0.9);
background-color: #0f0f12;
Copy link
Member

Choose a reason for hiding this comment

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

여기도요!!!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

scss 파일에서 color 코드를 불러오려는데

./src/components/Header/header.module.scss
SassError: Can't find stylesheet to import.
  ╷
2 │ @import '@src/lib/styles/colors.ts';
  │         ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  ╵
  src/components/Header/header.module.scss 2:9  root stylesheet

이러한 에러가 계속 떠서 아예 styled-component를 통일하게 사용하도록 style.ts로 바꿨습니다!

backdrop-filter: blur(20px);
z-index: 100;
padding: 0 20px;
top: 0;

@include tablet {
height: 48px;
padding: 0 48px;
}

@include mobile {
height: 48px;
min-height: 48px;
padding: 0 20px;

justify-content: space-between;
}
}
15 changes: 2 additions & 13 deletions src/components/Header/menuTapList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,9 @@ export const menuTapList: MenuTapList = [
href: '/project',
},
{
type: MenuTapType.Parent,
type: MenuTapType.Router,
Copy link
Member

Choose a reason for hiding this comment

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

좋네용.. 사실 이제 MenuTapType.Anchor 도 사라지긴 해서 type 이라는 친구도 없어도 되긴 혀요

다른 것이 추가될 수도 있으니 살려두어도 괜찮을 것 같습니당

Copy link
Contributor Author

Choose a reason for hiding this comment

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

MenuTapType.Anchor 도 지울까 했는데,,, 일단 살려뒀습니다!

title: '블로그',
children: [
{
type: MenuTapType.Router,
title: '활동후기',
href: '/review',
},
{
type: MenuTapType.Router,
title: '솝티클',
href: '/sopticle',
},
],
href: '/blog',
},
{
type: MenuTapType.Router,
Expand Down
10 changes: 1 addition & 9 deletions src/components/Header/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,10 @@ export const enum MenuTapType {
Parent = 'PARENT',
}

export type ParentMenuTap = {
type: MenuTapType.Parent;
title: string;
children: SingleMenuTap[];
};

export type SingleMenuTap = {
type: MenuTapType.Router | MenuTapType.Anchor;
title: string;
href: string;
};

export type BaseMenuTap = SingleMenuTap | ParentMenuTap;

export type MenuTapList = BaseMenuTap[];
export type MenuTapList = SingleMenuTap[];
22 changes: 11 additions & 11 deletions src/lib/styles/colors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ export const colors = {
white: '#FFFFFF',
black: '#000000',

gray10: '#F0F0F0',
gray30: '#E4E4E5',
gray50: '#C3C3C6',
gray100: '#9D9DA4',
gray200: '#808087',
gray300: '#66666D',
gray400: '#515159',
gray500: '#3F3F47',
gray600: '#2E2E35',
gray700: '#202025',
gray800: '#17171C',
gray10: '#FCFCFC',
gray30: '#F0F0F0',
gray50: '#E4E4E5',
gray100: '#C3C3C6',
gray200: '#9D9DA4',
gray300: '#808087',
gray400: '#66666D',
gray500: '#515159',
gray600: '#3F3F47',
gray700: '#2E2E35',
gray800: '#202025',
gray900: '#0F0F12',
Copy link
Member

Choose a reason for hiding this comment

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

최신 브랜치를 머지해주쎄용~!!


blue50: '#C8E1FF',
Expand Down
2 changes: 1 addition & 1 deletion src/lib/styles/global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export const global = css`
}

body {
background-color: #16161c;
background-color: #0f0f12;
line-height: 1;
}

Expand Down
1 change: 1 addition & 0 deletions src/pages/blog.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from '@src/views/BlogPage';
Copy link
Contributor Author

Choose a reason for hiding this comment

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

/blog 로 접속하면 해당 페이지입니다!

10 changes: 10 additions & 0 deletions src/views/BlogPage/BlogPage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import PageLayout from '@src/components/common/PageLayout';
import Navigation from './components/navigation';

export default function BlogPage() {
return (
<PageLayout>
<Navigation />
</PageLayout>
);
}
Copy link
Member

Choose a reason for hiding this comment

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

suggestion;

해당 코드를 pages/blog 컴포넌트에 바로 작성하는 건 어떨까요? 앞으로는 기존 구조 대신 페이지 컴포넌트 내에 바로 작성하는 것을 제안드립니다.

[제안 이유]

  1. views/BlogPage/BlogPage -> views/BlogPage/index -> pages/blog에 re-export하는 과정이 복잡하고 불필요하게 느껴진다. (위 구조를 취해야 하는 이유를 모르겠음)
  2. 페이지 컴포넌트 내에서만 사용할 수 있는 함수를 사용하기 어렵다.

@SeojinSeojin @f0rever0 다들 어떻게 생각하시나요?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

사실 저도 이번에 og 버그를 잡으면서 SSR을 위해서 re-export를 하던 구조를 깨버렸기 때문에...
논의를 다시 했으면 했어요!
다만 이번에 작업 시간이 빠듯하다보니까 미뤄뒀었는데, 혜준언니가 말해준거에 동감하는 바입니다!

Loading
Loading