Skip to content

Commit 7862922

Browse files
authored
Refactor/리스트페이지 레이아웃 (#64)
* 💄 style : 리스트 로딩 시 스피너 위치와 배경 크기 조정 * 💄 style : '답변하러가기'버튼 스타일 조정 및 화살표 이미지 변경 * 💄 style : '답변하러가기' 버튼 클릭 시 토스트 기능 추가 * 💄 style : 메인페이지 '질문하러가기' 버튼과 CSS통일 및 이미지 CLS 수정
1 parent be57144 commit 7862922

2 files changed

Lines changed: 30 additions & 6 deletions

File tree

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import PropTypes from 'prop-types';
2+
3+
const ToastMovePage = ({ toastMessage }) =>
4+
toastMessage ? (
5+
<div className='fixed bottom-[100px] md:bottom-[60px] left-1/2 px-5 py-3 bg-black rounded-lg text-sm/[18px] font-medium text-white -translate-x-1/2 shadow-2pt animate-slide-up-fade-delete'>
6+
{toastMessage}
7+
</div>
8+
) : null;
9+
10+
ToastMovePage.propTypes = {
11+
toastMessage: PropTypes.string.isRequired,
12+
};
13+
14+
export default ToastMovePage;

src/pages/QuestionList/index.jsx

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import SortDropDown from 'components/SortDropDown';
66
import { getSubject } from 'api/subjects';
77
import Logo from 'assets/images/img_Logo.svg';
88
import useViewport from 'hooks/useViewport';
9+
import ToastMovePage from 'components/ToastMovePage';
10+
import { ReactComponent as IcArrowDashRight } from 'assets/images/icons/ic_Arrow-dash-right.svg';
911

1012
const QuestionList = () => {
1113
const navigate = useNavigate();
@@ -16,6 +18,7 @@ const QuestionList = () => {
1618
const [count, setCount] = useState();
1719
const [cards, setCards] = useState([]);
1820
const [loading, setLoading] = useState(false);
21+
const [toastMessage, setToastMessage] = useState('');
1922

2023
const readSubject = useCallback(async () => {
2124
setLoading(true);
@@ -38,10 +41,16 @@ const QuestionList = () => {
3841

3942
const onClickPageMove = () => {
4043
const storedId = localStorage.getItem('id');
41-
if (storedId) {
42-
navigate(`/post/${storedId}/answer`);
44+
if (!storedId) {
45+
setToastMessage('로그인 후 이용 가능한 페이지입니다.');
46+
setTimeout(() => {
47+
navigate('/');
48+
}, 2000);
4349
} else {
44-
navigate('/');
50+
setToastMessage('답변페이지로 이동합니다.');
51+
setTimeout(() => {
52+
navigate(`/post/${storedId}/answer`);
53+
}, 2000);
4554
}
4655
};
4756

@@ -54,12 +63,12 @@ const QuestionList = () => {
5463
</Link>
5564

5665
<button
57-
className='flex flex-row justify-between gap-[4px] bg-brown-10 border-brown-40 border rounded-lg px-3 py-2 text-sm text-brown-40 font-normal whitespace-nowrap transition-colors duration-300 hover:bg-brown-20'
66+
className='flex flex-row items-center justify-center gap-[4px] bg-brown-10 border-brown-40 border rounded-lg px-3 py-2 text-sm text-brown-40 font-normal whitespace-nowrap w-[127px] h-[34px] md:w-[166px] md:h-[46px] md:gap-[8px] md:text-base transition-colors duration-300 hover:bg-brown-20'
5867
type='button'
5968
onClick={onClickPageMove}
6069
>
6170
<div>답변하러 가기</div>
62-
<div></div>
71+
<IcArrowDashRight alt='답변하러가기_화살표' className='fill-brown-40 w-[18px] h-[18px]' />
6372
</button>
6473
</div>
6574
</header>
@@ -70,7 +79,7 @@ const QuestionList = () => {
7079
</div>
7180

7281
<div className='mx-6 md:mx-8'>
73-
<div className='relative'>
82+
<div className='relative w-full h-full min-h-[539px] md:min-h-[358px]'>
7483
{loading && (
7584
<div className='absolute inset-0 border rounded-2xl flex justify-center items-center bg-gray-20 z-10'>
7685
<div className='w-10 h-10 border-4 border-t-transparent border-brown-30 rounded-full animate-spin' />
@@ -81,6 +90,7 @@ const QuestionList = () => {
8190
</div>
8291

8392
<Pagination data={{ limit, sort, count, pageWidth: width, setLimit, setOffset }} />
93+
{ToastMovePage && <ToastMovePage toastMessage={toastMessage} />}
8494
</>
8595
);
8696
};

0 commit comments

Comments
 (0)