Skip to content

Commit

Permalink
refactor: 홈 관리 네비게이션에 랜딩페이지로 이동하는 기능 추가 및 TopNav 구조 개선 (#627)
Browse files Browse the repository at this point in the history
* style: 불필요한 directory 구조 한 단계 제거 (Common)

* style: 행동디자인에서 Switch 바깥으로 분리

* refactor: TopNav 자유롭게 사용할 수 있도록 변경

* style: 디렉토리 구조 변하면서 생긴 import 수정

* style: 사용하지 않는 import 문 제거

* design: TextButton color onTertiary 추가

* remove: 사용하지 않게된 Switch 제거

* remove: 사용하지 않는 Back 컴포넌트 제거

* feat: 흔듯콘 아이콘 추가

* refactor: TopNav, NavElement를 사용해 navigate 책임 이동

* refactor: 변경된 TopNav 적용

* style: 콘솔 경고창 에러를 방지하기 위해 변경

* feat: noEmphasis prop 추가 (true일 때 강조되지 않음)

* design: 마진 맞춰줌

* remove: navigate 기능이 들어오면서 스토리북에서 변경되는 것을 보여줄 수 없어서 스토리북에서 제거

* style: emotion css를 위한 추가

* style: NavElement -> NavItem으로 이름 변경

* Merge branch 'fe-dev' into feature/#614

---------

Co-authored-by: Soyeon Choe <[email protected]>
  • Loading branch information
jinhokim98 and soi-ha authored Sep 26, 2024
1 parent 7fe6b20 commit d5126ea
Show file tree
Hide file tree
Showing 31 changed files with 129 additions and 248 deletions.
1 change: 1 addition & 0 deletions client/src/components/Design/components/Icon/Icon.style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const ICON_DEFAULT_COLOR: Record<IconType, IconColor> = {
toss: 'white',
meatballs: 'black',
editPencil: 'gray',
heundeut: 'gray',
};

export const iconStyle = ({iconType, theme, iconColor}: IconStylePropsWithTheme) => {
Expand Down
2 changes: 2 additions & 0 deletions client/src/components/Design/components/Icon/Icon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import X from '@assets/image/x.svg';
import PencilMini from '@assets/image/pencil_mini.svg';
import Meatballs from '@assets/image/meatballs.svg';
import EditPencil from '@assets/image/editPencil.svg';
import Heundeut from '@assets/image/heundeut.svg';
import {IconProps} from '@HDcomponents/Icon/Icon.type';
import {useTheme} from '@theme/HDesignProvider';

Expand All @@ -34,6 +35,7 @@ const ICON = {
toss: <img src={Toss} width="16" height="16" alt="toss icon" />,
meatballs: <Meatballs />,
editPencil: <EditPencil />,
heundeut: <Heundeut />,
};

export const Icon: React.FC<IconProps> = ({iconColor, iconType, ...htmlProps}: IconProps) => {
Expand Down
3 changes: 2 additions & 1 deletion client/src/components/Design/components/Icon/Icon.type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ export type IconType =
| 'pencilMini'
| 'toss'
| 'meatballs'
| 'editPencil';
| 'editPencil'
| 'heundeut';

export type IconColor = ColorKeys;

Expand Down
35 changes: 0 additions & 35 deletions client/src/components/Design/components/Switch/Switch.stories.tsx

This file was deleted.

This file was deleted.

24 changes: 0 additions & 24 deletions client/src/components/Design/components/Switch/Switch.tsx

This file was deleted.

5 changes: 0 additions & 5 deletions client/src/components/Design/components/Switch/Switch.type.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
/** @jsxImportSource @emotion/react */
import {forwardRef} from 'react';

import {useTheme} from '@theme/HDesignProvider';

import Text from '../Text/Text';

import {TextButtonProps} from './TextButton.type';
Expand All @@ -11,8 +9,6 @@ export const TextButton: React.FC<TextButtonProps> = forwardRef<HTMLButtonElemen
{textColor, textSize, children, ...htmlProps}: TextButtonProps,
ref,
) {
const {theme} = useTheme();

return (
<button ref={ref} {...htmlProps}>
<Text size={textSize} textColor={textColor}>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {TextSize} from '../Text/Text.type';

export type TextColor = 'black' | 'gray';
export type TextColor = 'black' | 'gray' | 'onTertiary';

export interface TextButtonStyleProps {
textColor: TextColor;
Expand Down
20 changes: 0 additions & 20 deletions client/src/components/Design/components/TopNav/Back.tsx

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import {css} from '@emotion/react';

export const navItemStyle = css({
padding: '0 0.5rem',

':first-of-type': {
paddingLeft: 0,
},
});
55 changes: 55 additions & 0 deletions client/src/components/Design/components/TopNav/NavItem.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/** @jsxImportSource @emotion/react */
import type {NavItemProps} from './NavItem.type';

import {useLocation, useNavigate} from 'react-router-dom';

import getDeletedLastPath from '@utils/getDeletedLastPath';

import TextButton from '../TextButton/TextButton';

import {navItemStyle} from './NavItem.style';

const NavItem = ({displayName, routePath, onHandleRouteInFunnel, noEmphasis = false, children}: NavItemProps) => {
const navigate = useNavigate();
const location = useLocation();
const matchPath = location.pathname.includes(routePath);

const handleNavigation = () => {
if (onHandleRouteInFunnel) {
onHandleRouteInFunnel();
return;
}

switch (routePath) {
case '/':
navigate('/');
break;
case '-1':
navigate(-1);
break;
default:
navigate(`${getDeletedLastPath(location.pathname)}${routePath}`);
break;
}
};

const getTextColor = () => {
if (noEmphasis) return 'gray';

return matchPath ? 'onTertiary' : 'gray';
};

return (
<li css={navItemStyle} onClick={handleNavigation}>
{children ? (
children
) : (
<TextButton textColor={getTextColor()} textSize="bodyBold">
{displayName}
</TextButton>
)}
</li>
);
};

export default NavItem;
14 changes: 14 additions & 0 deletions client/src/components/Design/components/TopNav/NavItem.type.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
export type NavItemOptionProps = {
displayName?: string;
onHandleRouteInFunnel?: () => void;
};

export type NavItemRequireProps = {
routePath: string;
};

export type NavItemStyleProps = {
noEmphasis?: boolean;
};

export type NavItemProps = NavItemRequireProps & NavItemOptionProps & NavItemStyleProps & React.PropsWithChildren;
50 changes: 0 additions & 50 deletions client/src/components/Design/components/TopNav/TopNav.stories.tsx

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,3 @@ export const topNavStyle = css({
padding: '0 1rem',
width: '100%',
});

export const topNavNonStyle = css({
display: 'flex',
justifyContent: 'space-between',
alignItems: 'center',
padding: '0 1rem',
width: '100%',
height: '1.5rem',
});
25 changes: 12 additions & 13 deletions client/src/components/Design/components/TopNav/TopNav.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
/** @jsxImportSource @emotion/react */
import React from 'react';
import NavItem from './NavItem';
import {topNavStyle} from './TopNav.style';

import Switch from '@HDcomponents/Switch/Switch';

import {topNavNonStyle, topNavStyle} from './TopNav.style';
import Back from './Back';
type TopNavProps = React.PropsWithChildren & {
Element?: React.ReactNode;
};

const TopNav: React.FC<React.PropsWithChildren> = ({children}) => {
const hasBack = React.Children.toArray(children).some(child => React.isValidElement(child) && child.type === Back);
const hasSwitch = React.Children.toArray(children).some(
child => React.isValidElement(child) && child.type === Switch,
const TopNav = ({children}: TopNavProps) => {
return (
<nav>
<ul css={topNavStyle}>{children}</ul>
</nav>
);

const isExistNav = hasBack || hasSwitch;

return <div css={isExistNav ? topNavStyle : topNavNonStyle}>{children}</div>;
};

TopNav.Item = NavItem;

export default TopNav;
4 changes: 0 additions & 4 deletions client/src/components/Design/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,12 @@ import Input from './components/Input/Input';
import LabelInput from './components/LabelInput/LabelInput';
import ListButton from './components/ListButton/ListButton';
import LabelGroupInput from './components/LabelGroupInput/LabelGroupInput';
import Switch from './components/Switch/Switch';
import Top from './components/Top/Top';
import Tab from './components/Tabs/Tab';
import Tabs from './components/Tabs/Tabs';
import Text from './components/Text/Text';
import TextButton from './components/TextButton/TextButton';
import Title from './components/Title/Title';
import Back from './components/TopNav/Back';
import TopNav from './components/TopNav/TopNav';
import DepositCheck from './components/DepositCheck/DepositCheck';
import DepositToggle from './components/DepositToggle/DepositToggle';
Expand All @@ -48,15 +46,13 @@ export {
LabelInput,
ListButton,
LabelGroupInput,
Switch,
Top,
Tab,
Tabs,
Text,
TextButton,
Title,
TopNav,
Back,
MainLayout,
FunnelLayout,
ContentLayout,
Expand Down
File renamed without changes.
File renamed without changes.
3 changes: 0 additions & 3 deletions client/src/hooks/useEventPageLayout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@ import getEventIdByUrl from '@utils/getEventIdByUrl';

import {ROUTER_URLS} from '@constants/routerUrls';

import useNavSwitch from './useNavSwitch';
import useRequestGetEvent from './queries/event/useRequestGetEvent';

const useEventPageLayout = () => {
const navProps = useNavSwitch();
const eventId = getEventIdByUrl();
const {eventName, bankName, accountNumber} = useRequestGetEvent();

Expand All @@ -23,7 +21,6 @@ const useEventPageLayout = () => {

return {
eventId,
navProps,
isAdmin,
isLoginPage,
eventOutline,
Expand Down
Loading

0 comments on commit d5126ea

Please sign in to comment.