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

Refactor/1270 헤어 콘텐츠 깨짐 현상 수정 및 모바일 버전 로고 변경 #1283

Merged
merged 6 commits into from
May 18, 2023
Merged
Changes from 5 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
23 changes: 20 additions & 3 deletions frontend/src/components/NavBar/NavBar.js
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';
Expand All @@ -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 = [
{
Expand All @@ -40,6 +41,8 @@ const navigationConfig = [
},
];

const MOBILE_SCREEN_SIZE = "420px";
Copy link
Contributor

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라면 좀더 공통적인 파일 위치에 선언되어 있음 좋지 않을까요?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

너무 좋은 것 같습니다! 모두 수정하도록 하겠습니다. 감사합니다!


const NavBar = () => {
const history = useHistory();
const logoTag = isProd ? 'BETA' : APP_MODE;
Expand All @@ -50,6 +53,9 @@ const NavBar = () => {

const [isDropdownToggled, setDropdownToggled] = useState(false);
const [isWritingDropdownToggled, setWritingDropdownToggled] = useState(false);
const [isMobile, setIsMobile] = useState(false);
Copy link
Contributor

Choose a reason for hiding this comment

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

useState끼리 모아두면 요 컴포넌트가 어떤 state를 포함하는지 좀 더 쉽게 알 수 있을 것 같네요 ㅎㅎ 참고만 해주세요~

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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);
Expand Down Expand Up @@ -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}
Expand All @@ -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}
Expand Down