Skip to content

Commit

Permalink
fix: 함수 적용 시 잘못 적용된 부분 해결 및 reload 로직 삭제 (#474)
Browse files Browse the repository at this point in the history
* fix: getTextColor의 파라미터가 undefined일 때 오류 처리 로직 추가 및 Chip.styles에 잘못적용된 부분 수정

* fix: NavBar 로고 클릭 시 reload 삭제
  • Loading branch information
sunhpark42 authored Oct 9, 2021
1 parent b9cdac6 commit 26b4513
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
3 changes: 2 additions & 1 deletion frontend/src/components/Chip/Chip.styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ const Container = styled.div`
width: ${({ width }) => (width ? width : 'fit-content')};
max-width: ${({ maxWidth }) => maxWidth};
background-color: ${({ backgroundColor }) => backgroundColor ?? COLOR.LIGHT_GRAY_200};
color: ${({ backgroundColor }) => getTextColor(backgroundColor) ?? COLOR.BLACK_900};
color: ${({ backgroundColor }) =>
backgroundColor ? getTextColor(backgroundColor) : COLOR.BLACK_900};
padding: 0.2rem 0.8rem;
border-radius: 5rem;
margin-right: 1rem;
Expand Down
5 changes: 2 additions & 3 deletions frontend/src/components/NavBar/NavBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,8 @@ const NavBar = () => {
}
}, [user]);

const goMainWithReload = () => {
const goMain = () => {
history.push(PATH.ROOT);
window.location.reload();
};

const goNewPost = async () => {
Expand Down Expand Up @@ -124,7 +123,7 @@ const NavBar = () => {
return (
<Container isDropdownToggled={isDropdownToggled} onClick={hideDropdownMenu}>
<Wrapper>
<Logo onClick={goMainWithReload} role="link">
<Logo onClick={goMain} role="link">
<img src={LogoImage} alt="PROLOG 로고" />
<span>{process.env.REACT_APP_MODE === 'PROD' ? 'BETA' : process.env.REACT_APP_MODE}</span>
</Logo>
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/utils/textColorPicker.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { COLOR } from '../constants';

function getTextColor(hexColor) {
if (!hexColor) {
return `${COLOR.BLACK_900}`;
}

const rgb = parseInt(hexColor.substring(1), 16);

const r = (rgb >> 16) & 0xff;
Expand Down

0 comments on commit 26b4513

Please sign in to comment.