Skip to content

Commit

Permalink
Feat: series arrow navigate 기능 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
dongree committed Oct 17, 2023
1 parent f3b697b commit bbeba55
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/assets/icons/arrow_icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 36 additions & 2 deletions src/components/series/SeriesDetailContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { useContext, useEffect, useRef, useState } from 'react';
import MemoViewer from '../memo/MemoViewer';
import MemoSideBar from '../memo/MemoSideBar';
import { getMemoById } from '@/service/memos';
import { getIsLike } from '@/service/like';
import { getCommentsByPostTypeAndPostId } from '@/service/comments';
import { getQuestionsByMemoId } from '@/service/questions';
import { Question } from '@/types/question';
Expand All @@ -19,6 +18,7 @@ import { useRouter } from 'next/navigation';
import { ModalContext } from '@/context/ModalProvider';
import { deleteSeries } from '@/service/series';
import { notifyToast } from '@/service/notification';
import arrowIcon from '@/assets/icons/arrow_icon.svg';

type Props = {
memo: Memo;
Expand Down Expand Up @@ -88,9 +88,19 @@ export default function SeriesDetailContainer({
});
};

const handleLeftBtnClick = () => {
if (currentIdx === 0) return;
setCurrentIdx((preIdx) => preIdx - 1);
};

const handleRightBtnClick = () => {
if (currentIdx === memoInfoList.length - 1) return;
setCurrentIdx((preIdx) => preIdx + 1);
};

return (
<div className="flex flex-col">
<div className="flex items-center justify-between bg-soma-grey-20 py-4 px-2 rounded-lg">
<div className="flex items-center justify-between bg-soma-grey-20 p-4 rounded-lg">
<h2 className="text-xl sm:text-3xl font-semibold">
<span className="text-soma-blue-50">Series </span>
{seriesTitle}
Expand Down Expand Up @@ -185,6 +195,30 @@ export default function SeriesDetailContainer({
authorFollowerNum={authorFollowerNum}
/>
</div>
<div className="flex justify-center items-center mt-5">
<button
className={`rounded-full border-2 p-1 border-soma-grey-30 rotate-180 ${
currentIdx === 0 ? 'opacity-40 pointer-events-none' : ''
}`}
onClick={handleLeftBtnClick}
>
<Image src={arrowIcon} alt="arrowIcon" />
</button>
<div className="text-soma-grey-48 mx-5">
<span className="text-soma-blue-50">Series {currentIdx + 1}</span> /{' '}
{memoInfoList.length}
</div>
<button
className={`rounded-full border-2 p-1 border-soma-grey-30 ${
currentIdx === memoInfoList.length - 1
? 'opacity-40 pointer-events-none'
: ''
}`}
onClick={handleRightBtnClick}
>
<Image src={arrowIcon} alt="arrowIcon" />
</button>
</div>
</div>
);
}

0 comments on commit bbeba55

Please sign in to comment.