-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: 홈 관리 네비게이션에 랜딩페이지로 이동하는 기능 추가 및 TopNav 구조 개선 (#627)
* 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
1 parent
7fe6b20
commit d5126ea
Showing
31 changed files
with
129 additions
and
248 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 0 additions & 35 deletions
35
client/src/components/Design/components/Switch/Switch.stories.tsx
This file was deleted.
Oops, something went wrong.
6 changes: 0 additions & 6 deletions
6
client/src/components/Design/components/Switch/Switch.style.ts
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
5 changes: 0 additions & 5 deletions
5
client/src/components/Design/components/Switch/Switch.type.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
client/src/components/Design/components/TextButton/TextButton.type.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
9 changes: 9 additions & 0 deletions
9
client/src/components/Design/components/TopNav/NavItem.style.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
55
client/src/components/Design/components/TopNav/NavItem.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
14
client/src/components/Design/components/TopNav/NavItem.type.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
50
client/src/components/Design/components/TopNav/TopNav.stories.tsx
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 12 additions & 13 deletions
25
client/src/components/Design/components/TopNav/TopNav.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.