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/fe/#301 header refactoring #355

Merged
merged 9 commits into from
Dec 2, 2024
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
10 changes: 0 additions & 10 deletions frontend/.storybook/preview.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
import type { Preview } from '@storybook/react';
import '../src/index.css';
// ์šฐ์„ ์€ ํฐํŠธ ๋‹ค ํฌํ•จ์‹œ์ผฐ๋Š”๋ฐ, ๋‚˜์ค‘์— ์‚ฌ์šฉํ•  ๊ฒƒ๋“ค๋งŒ ๋”ฐ๋กœ ๋บด์ž.
import '@fontsource/pretendard/100.css';
import '@fontsource/pretendard/200.css';
import '@fontsource/pretendard/300.css';
import '@fontsource/pretendard/400.css';
import '@fontsource/pretendard/500.css';
import '@fontsource/pretendard/600.css';
import '@fontsource/pretendard/700.css';
import '@fontsource/pretendard/800.css';
import '@fontsource/pretendard/900.css';

const preview: Preview = {
parameters: {
Expand Down
1 change: 0 additions & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
"build-storybook": "storybook build"
},
"dependencies": {
"@fontsource/pretendard": "^5.1.0",
"axios": "^1.7.7",
"lz-string": "^1.5.0",
"react": "^18.3.1",
Expand Down
10 changes: 5 additions & 5 deletions frontend/src/App.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#root {
touch-action: pan-y;
font-family: Pretendard, 'Pretendard Variable', sans-serif;
font-family: Pretendard, 'Pretendard Variable', sans-serif !important;
}

.logo {
Expand Down Expand Up @@ -40,10 +40,10 @@
}

.disable-drag {
-webkit-user-select:none;
-moz-user-select:none;
-ms-user-select:none;
user-select:none
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}

.overlay {
Expand Down
32 changes: 21 additions & 11 deletions frontend/src/component/content/Content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { getChannelInfo } from '@/api/channel.api';
import { useContext } from 'react';
import { ChannelContext } from '@/context/ChannelContext';
import { Dropdown } from '../common/dropdown/Dropdown';
import { FooterContext } from '../layout/footer/LayoutFooterProvider';

interface IContentProps {
title: string;
Expand Down Expand Up @@ -35,6 +36,7 @@ interface IContentProps {
*/

export const Content = (props: IContentProps) => {
const { resetFooterContext } = useContext(FooterContext);
const formattedDate = new Date(props.time).toLocaleDateString('ko-KR', {
year: 'numeric',
month: '2-digit',
Expand All @@ -61,31 +63,34 @@ export const Content = (props: IContentProps) => {
const goToChannelInfoPage = () => {
if (channelInfo?.id) {
navigate(`/channelInfo/${channelInfo.id}`);
resetFooterContext();
}
};

const goToHostViewPage = () => {
navigate(props.link);
resetFooterContext();
};

const handleUpdate = () => {
getUpdateChannelInfo();
goToChannelInfoPage();
};

return (
<div className="relative flex w-full flex-row justify-between px-4 py-5">
<button
type="button"
onClick={() => {
navigate(props.link);
}}
>
<header className="border-gray-200 pb-1 text-start text-lg">{props.title}</header>
<section className="flex items-center text-sm leading-5 text-gray-500">
<button type="button" onClick={goToHostViewPage}>
<header className="border-gray-200 pb-1 text-start text-base font-normal">
{props.title}
</header>
<section className="text-grayscale-200 flex items-center text-xs font-normal leading-5">
<time className="mr-4">
{formattedDate} {formattedTime}
</time>
{props.person > 0 && (
<>
<MdGroup className="mr-2 h-5 w-5" aria-label="์ธ์›์ˆ˜ ์•„์ด์ฝ˜" />
<span>{props.person}๋ช…</span>
<span className="text-xs font-normal">{props.person}๋ช…</span>
</>
)}
</section>
Expand All @@ -96,10 +101,15 @@ export const Content = (props: IContentProps) => {
<MdMoreVert className="h-6 w-6" />
</Dropdown.Trigger>
<Dropdown.Menu>
<Dropdown.Item className="flex items-start text-base" onClick={handleUpdate}>
<Dropdown.Item
className="flex items-start text-base font-normal"
onClick={handleUpdate}
>
๊ณต์œ ํ•˜๊ธฐ
</Dropdown.Item>
<Dropdown.Item className="flex items-start text-base">์‚ญ์ œํ•˜๊ธฐ</Dropdown.Item>
<Dropdown.Item className="flex items-start text-base font-normal">
์‚ญ์ œํ•˜๊ธฐ
</Dropdown.Item>
</Dropdown.Menu>
</Dropdown>
{/* {isMenuOpen && (๋“œ๋กญ๋‹ค์šด ๋ฉ”๋‰ด)} */}
Expand Down
42 changes: 42 additions & 0 deletions frontend/src/component/header/HeaderLayout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { ReactNode } from 'react';
import classNames from 'classnames';

interface IHeaderProps {
leftItems?: ReactNode[];
rightItems?: ReactNode[];
title?: ReactNode;
subtitle?: string;
className?: string;
userName?: string;
}

export const HeaderLayout = (props: IHeaderProps) => {
return (
<header
className={classNames(
'absolute flex w-full flex-col gap-2.5 bg-transparent px-4 pb-2 pt-4',
props.className,
)}
>
<div className="flex items-center justify-between">
<div className="flex items-center gap-1">
{props.leftItems &&
props.leftItems.map(item => (
<div className="flex items-center justify-center">{item}</div>
))}
<div className="flex items-center justify-center text-base">
<div className="font-bold">{props.userName}</div>
<div>{props.title}</div>
</div>
</div>
<div className="flex items-center gap-1">
{props.rightItems &&
props.rightItems.map(item => (
<div className="flex items-center justify-center">{item}</div>
))}
</div>
</div>
<div className="text-grayscale-400 ml-8 text-xs">{props.subtitle}</div>
</header>
);
};
26 changes: 15 additions & 11 deletions frontend/src/component/layout/constant/HeaderConst.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import { HeaderBackButton } from '@/component/header/HeaderBackButton';
import { HeaderDropdown } from '@/component/header/HeaderDropdown';
import React, { ReactNode } from 'react';

export const HEADER_TITLE: Record<string, string> = {
'/add-channel/:user/draw': '์— ๋”ฐ๋ฅธ ๊ฒฝ๋กœ ์„ค์ •',
};
Expand All @@ -6,17 +10,17 @@ export const HEADER_SUBTITLE: Record<string, string> = {
'/add-channel/:user/draw': '์‚ฌ์šฉ์ž ๋ณ„๋กœ ์ถœ๋ฐœ์ง€/๋„์ฐฉ์ง€(๋งˆ์ปค), ๊ฒฝ๋กœ(๊ทธ๋ฆผ)์„ ์„ค์ •ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค',
};

export const HEADER_LEFTBUTTON: Record<string, string> = {
'/add-channel': 'back',
'/add-channel/:user': 'back',
'/add-channel/:user/draw': 'back',
'/channel/:channelId/host': 'back',
'/update-channel': 'back',
'/register': 'back',
'/channelInfo/:channelId': 'back',
'/guest-add-channel/:channelId': 'back',
export const HEADER_LEFTITEMS: Record<string, ReactNode[]> = {
'/add-channel': [React.createElement(HeaderBackButton)],
'/add-channel/:user': [React.createElement(HeaderBackButton)],
'/add-channel/:user/draw': [React.createElement(HeaderBackButton)],
'/channel/:channelId/host': [React.createElement(HeaderBackButton)],
'/update-channel': [React.createElement(HeaderBackButton)],
'/register': [React.createElement(HeaderBackButton)],
'/channelInfo/:channelId': [React.createElement(HeaderBackButton)],
'/guest-add-channel/:channelId': [React.createElement(HeaderBackButton)],
};
leedongyull marked this conversation as resolved.
Show resolved Hide resolved

export const HEADER_RIGHTBUTTON: Record<string, string> = {
'/channel/:channelId/host': 'dropdown',
export const HEADER_RIGHTITEMS: Record<string, ReactNode[]> = {
'/channel/:channelId/host': [React.createElement(HeaderDropdown)],
};
24 changes: 9 additions & 15 deletions frontend/src/component/layout/header/LayoutHeader.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,19 @@
import { Header } from '@/component/header/Header';
import { NoticeText } from '@/component/text/NoticeText';
import { useLocation, useParams } from 'react-router-dom';
import { getHeaderInfo } from '@/utils/mapping/HeaderMapping';
import { HeaderLayout } from '@/component/header/HeaderLayout';

export const LayoutHeader = () => {
const params = useParams<Record<string, string | undefined>>();
const urlPath = useLocation();
const headerOption = getHeaderInfo(urlPath.pathname);

return (
<Header className="z-4000">
<Header.MainLayout
leftButton={headerOption.leftButton}
rightButton={headerOption.rightButton}
title={`${params.user || ''}${headerOption.title}`}
/>
{headerOption.subtitle && (
<Header.Subtitle>
<NoticeText>{headerOption.subtitle}</NoticeText>
</Header.Subtitle>
)}
</Header>
<HeaderLayout
className="z-[5000]"
userName={`${params.user || ''}`}
title={`${headerOption.title}`}
subtitle={`${headerOption.subtitle}`}
leftItems={headerOption.leftItems}
rightItems={headerOption.rightItems}
/>
);
};
Loading