-
Notifications
You must be signed in to change notification settings - Fork 28
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
Refactor/1270 헤어 콘텐츠 깨짐 현상 수정 및 모바일 버전 로고 변경 #1283
Merged
Merged
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
fcaa0cf
refactor: 헤어 콘텐츠 깨짐 현상 수정 및 모바일 버전 로고 변경
GC-Park 86a636d
refactor: 삼항 연산자를 이용해 코드 가독성 향상
GC-Park 3665e9b
refactor: 탭 사이즈 변경
GC-Park cfd8fed
refactor: 새로운 네이밍과 상수 분리 적용
GC-Park 039a69b
refactor: 가독성을 위해 useState 위치 변경
GC-Park 89a3df7
refactor: 상수 파일 분리
GC-Park File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
/** @jsxImportSource @emotion/react */ | ||
|
||
import PropTypes from 'prop-types'; | ||
import { useContext, useState } from 'react'; | ||
import { useContext, useState, useEffect } from 'react'; | ||
import { useHistory, Link, NavLink } from 'react-router-dom'; | ||
import MobileLogo from '../../assets/images/woteco-logo.png'; | ||
import LogoImage from '../../assets/images/logo.svg'; | ||
import { PATH } from '../../constants'; | ||
import GithubLogin from '../GithubLogin/GithubLogin'; | ||
|
@@ -23,7 +24,7 @@ import { | |
loginButtonStyle, | ||
} from './NavBar.styles'; | ||
import { UserContext } from '../../contexts/UserProvider'; | ||
import { APP_MODE, BASE_URL, isProd } from '../../configs/environment'; | ||
import { APP_MODE, isProd } from '../../configs/environment'; | ||
|
||
const navigationConfig = [ | ||
{ | ||
|
@@ -40,6 +41,8 @@ const navigationConfig = [ | |
}, | ||
]; | ||
|
||
const MOBILE_SCREEN_SIZE = "420px"; | ||
|
||
const NavBar = () => { | ||
const history = useHistory(); | ||
const logoTag = isProd ? 'BETA' : APP_MODE; | ||
|
@@ -50,6 +53,9 @@ const NavBar = () => { | |
|
||
const [isDropdownToggled, setDropdownToggled] = useState(false); | ||
const [isWritingDropdownToggled, setWritingDropdownToggled] = useState(false); | ||
const [isMobile, setIsMobile] = useState(false); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. useState끼리 모아두면 요 컴포넌트가 어떤 state를 포함하는지 좀 더 쉽게 알 수 있을 것 같네요 ㅎㅎ 참고만 해주세요~ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 저희도 같은 생각입니다!!! 😊 수정하도록 하겠습니다 감사합니다! |
||
|
||
const mobileScreen = window.matchMedia(`(max-width: ${MOBILE_SCREEN_SIZE})`); | ||
|
||
const goMain = () => { | ||
history.push(PATH.ROOT); | ||
|
@@ -77,6 +83,16 @@ const NavBar = () => { | |
} | ||
}; | ||
|
||
useEffect(() => { | ||
const handleResize = () => { | ||
setIsMobile(mobileScreen.matches); | ||
}; | ||
mobileScreen.addEventListener('change', handleResize); | ||
return () => { | ||
mobileScreen.removeEventListener('change', handleResize); | ||
}; | ||
}, [mobileScreen]); | ||
|
||
return ( | ||
<Container | ||
isDropdownToggled={isDropdownToggled || isWritingDropdownToggled} | ||
|
@@ -87,13 +103,14 @@ const NavBar = () => { | |
> | ||
<Wrapper> | ||
<Logo onClick={goMain} role="link" aria-label="프롤로그 홈으로 이동하기"> | ||
<img src={LogoImage} alt="" /> | ||
<img src={isMobile ? MobileLogo : LogoImage} alt="" /> | ||
{!isProd && <span>{logoTag}</span>} | ||
</Logo> | ||
<Menu role="menu"> | ||
<Navigation> | ||
{navigationConfig.map(({ path, title }) => ( | ||
<NavLink | ||
style={{ whiteSpace: 'nowrap' }} | ||
exact | ||
key={path} | ||
to={path} | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MOBILE_MAX_SIZE 어떠신가요~? 가볍게 제안드려봅니다 ㅎㅎ 그리고 해당 상수가 prolog 서비스에서 공용으로 사용하는 mobile breakpoint라면 좀더 공통적인 파일 위치에 선언되어 있음 좋지 않을까요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
너무 좋은 것 같습니다! 모두 수정하도록 하겠습니다. 감사합니다!