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

✨ Feat: 로딩에러 컴포넌트 구현 #48

Merged
merged 4 commits into from
May 10, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
29 changes: 29 additions & 0 deletions src/components/LoadingError/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import React from 'react';
import CustomButton from '../CustomButton';
import Logo from '@/assets/icons/Logo';
import PropTypes from 'prop-types';
import style from './styles.module.scss';

/**
* @param {string} errorMessage 에러메시지 문구
*/
const LoadingError = ({ errorMessage }) => {
const handleRefresh = () => {
window.location.reload();
};

return (
<div className={style.error}>
{/* <Logo /> */}
<h3>문제가 발생했습니다</h3>
<p>{errorMessage}</p>
<CustomButton rounded btnText="페이지 새로고침" onClick={handleRefresh} />
</div>
);
};

LoadingError.propTypes = {
errorMessage: PropTypes.string.isRequired,
};

export default LoadingError;
24 changes: 24 additions & 0 deletions src/components/LoadingError/styles.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
@import '../../styles/';

.error {
text-align: center;

margin: 0 auto;
padding-block: 10px;

white-space: pre-wrap;

h3 {
// margin-top: 45px;
@include font-base($color-brand-orange, 600, 18px, 26px);
}

p {
margin-bottom: 15px;
@include font-base($color-white, 600, 14px, 26px);
}

button {
width: 120px;
}
}
2 changes: 1 addition & 1 deletion src/pages/ListPage/MonthlyChart/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const MonthlyChart = () => {
name: '추가 버튼 눌렀구나',
totalVotes: 1000,
profilePicture:
'https://sprint-fe-project.s3.ap-northeast-2.amazonaws.com/Fandom-K/idol/1714613892649/ive1.jpeg',
'https://sprint-fe-project.s3.ap-northeast-2.amazonaws.com/Fandom-K/idol/1714613892649/ive1.jpeg',
},
];
setIdolList(newArr);
Expand Down
10 changes: 8 additions & 2 deletions src/pages/TestPage/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import Modal from '@/components/Modal';
import ModalHeader from '@/components/Modal/components/ModalHeader';
// import ModalMobileHeader from '@/components/Modal/components/ModalMobileHeader';
import Profile from '@/components/Profile';
import LoadingError from '@/components/LoadingError';

const TestPage = () => {
const [isOpen, openModal, closeModal] = useModal();
Expand All @@ -18,8 +19,7 @@ const TestPage = () => {
<Header />
<div
style={{ display: 'flex', justifyContent: 'center', padding: '24px' }}
>
</div>
></div>
<div style={{ display: 'flex', alignItems: 'center' }}>
<Profile
clicked
Expand Down Expand Up @@ -105,6 +105,12 @@ const TestPage = () => {
)}
</Carousel>
</div>
<div>
<LoadingError errorMessage="후원 목록을 가져오지 못했습니다. 다시 시도해주세요" />
<LoadingError
errorMessage={`이렇게 작성하면 줄바꿈이 됩니다.\n다시 시도해주세요`}
/>
</div>
</div>
);
};
Expand Down