diff --git a/src/hooks/useSliderPaging.jsx b/src/hooks/useSliderPaging.jsx index 3856c7b..706fddc 100644 --- a/src/hooks/useSliderPaging.jsx +++ b/src/hooks/useSliderPaging.jsx @@ -1,14 +1,11 @@ // src/hooks/useSliderPaging.js -import { useState, useEffect, useMemo, useCallback } from 'react'; +import { useState, useMemo, useCallback } from 'react'; +import { useDeviceType } from '@/hooks/useDeviceType'; -export function useSliderPaging({ totalItems, pageSize, breakpoint = 1200 }) { - // 1) 뷰포트 모드(데스크톱/모바일) 감지 - const [isDesktop, setIsDesktop] = useState(window.innerWidth >= breakpoint); - useEffect(() => { - const handler = () => setIsDesktop(window.innerWidth >= breakpoint); - window.addEventListener('resize', handler); - return () => window.removeEventListener('resize', handler); - }, [breakpoint]); +export function useSliderPaging({ totalItems, pageSize }) { + // deviceType을 통한 데스크톱 여부 감지 + const deviceType = useDeviceType(); + const isDesktop = deviceType === 'desktop'; // 2) 페이지 인덱스 관리 const [pageIndex, setPageIndex] = useState(0); diff --git a/src/pages/ListPage/ListPage.jsx b/src/pages/ListPage/ListPage.jsx index 4d4f4e5..387301f 100644 --- a/src/pages/ListPage/ListPage.jsx +++ b/src/pages/ListPage/ListPage.jsx @@ -1,7 +1,7 @@ import { useEffect, useState } from 'react'; +import { useNavigate } from 'react-router-dom'; import Slider from './components/Slider'; import styles from './ListPage.module.scss'; -import { Link } from 'react-router-dom'; import Button from '@/components/Button/Button'; import { listRecipients } from '@/apis/recipientsApi'; @@ -9,6 +9,7 @@ import { useApi } from '@/hooks/useApi'; const ListPage = () => { // 인기/최신 각각 오프셋·hasNext 관리 + const navigate = useNavigate(); const [popularOffset, setPopularOffset] = useState(0); const [recentOffset, setRecentOffset] = useState(0); const [popularHasNext, setPopularHasNext] = useState(false); @@ -21,7 +22,7 @@ const ListPage = () => { refetch: getPopularList, } = useApi( listRecipients, - { limit: 20, offset: popularOffset, sortLike: true }, + { limit: 8, offset: popularOffset, sortLike: true }, { errorMessage: '인기 롤링페이퍼 목록을 불러오는 데 실패했습니다.', retry: 1, @@ -82,19 +83,19 @@ const ListPage = () => {
{/* 인기 롤링 페이퍼 🔥 */}
-

인기 롤링 페이퍼 🔥

- +

요즘 가장 사랑받는 롤링 페이퍼 Top 8 💌

+
{/* 최근에 만든 롤링 페이퍼 ⭐️ */}
-

최근에 만든 롤링 페이퍼 ⭐️

+

따끈따끈 신상 롤링 페이퍼 🍞

- - - +
); }; diff --git a/src/pages/ListPage/ListPage.module.scss b/src/pages/ListPage/ListPage.module.scss index 2bd03f5..fa67dac 100644 --- a/src/pages/ListPage/ListPage.module.scss +++ b/src/pages/ListPage/ListPage.module.scss @@ -9,13 +9,13 @@ padding-top: 50px; overflow: visible; - @media screen and (min-width: 768px) and (max-width: 1199px) { + @include tablet { padding: 0 24px; width: 100%; min-height: 100dvh; } - @media screen and (max-width: 767px) { + @include mobile { padding: 0 20px; width: 100%; padding-top: 40px; @@ -57,7 +57,7 @@ display: block; // inline → block으로 바꿔서 margin:auto 적용 margin: 0 auto; - @media screen and (min-width: 355px) and (max-width: 1199px) { + @include tablet { width: 100%; margin-bottom: 20px; } diff --git a/src/pages/ListPage/components/ItemCard.jsx b/src/pages/ListPage/components/ItemCard.jsx index c2d3896..b438726 100644 --- a/src/pages/ListPage/components/ItemCard.jsx +++ b/src/pages/ListPage/components/ItemCard.jsx @@ -48,17 +48,21 @@ const ItemCard = ({
{/* 프로필 아바타 영역 (최대 3) */} - + {!messageCount ? ( +
✨ 첫 글을 기다리고 있어요!
+ ) : ( + + )}

{!messageCount ? ( - `아직 받은 메세지가 없어요🥲` +

따뜻한 한마디를 전해볼까요?
) : ( {messageCount}명이 작성했어요! @@ -69,6 +73,7 @@ const ItemCard = ({
{/* 반응 이모지 영역 (최대 3) */} +
diff --git a/src/pages/ListPage/components/ItemCard.module.scss b/src/pages/ListPage/components/ItemCard.module.scss index 3ed95e5..2d01867 100644 --- a/src/pages/ListPage/components/ItemCard.module.scss +++ b/src/pages/ListPage/components/ItemCard.module.scss @@ -17,29 +17,29 @@ transform: translateZ(0); &:hover { transform: scale(1.05); - } - - &__shinning { - position: absolute; - width: 90px; - height: 200px; - right: 20px; - top: 20px; - background-color: #ffffff; - filter: blur(60px); - z-index: -1; - } - - &__shadow { - position: absolute; - width: 10px; - height: 200px; - left: 20px; - top: 20px; - background-color: #222222; - filter: blur(55px); - z-index: -1; - } + } + + &__shinning { + position: absolute; + width: 90px; + height: 200px; + right: 20px; + top: 20px; + background-color: #ffffff; + filter: blur(60px); + z-index: -1; + } + + &__shadow { + position: absolute; + width: 10px; + height: 200px; + left: 20px; + top: 20px; + background-color: #222222; + filter: blur(55px); + z-index: -1; + } &__content { display: flex; @@ -60,26 +60,40 @@ margin: 0; font-size: var(--font-size-24); font-weight: var(--font-weight-bold); - line-height: 36px; - height:36px; + line-height: 36px; + height: 36px; + } + + &__avatars-area { + height: 29px; } - &__avatars-area { - height: 29px; - } - &__meta { font-size: var(--font-size-16); - line-height: 26px; - height: 26px; - flex-grow: 1; + line-height: 26px; + height: 26px; + flex-grow: 1; } + &__write { + width: 100%; + height: 40px; - &__emojis-area { - height: 36px; - display: flex; - align-items: center; - } + background-color: var(--color-purple-500); + border: none; + border-radius: 12px; + font-weight: 700; + font-size: 15px; + line-height: 28px; + color: var(--color-white); + align-self: center; + display: block; // inline → block으로 바꿔서 margin:auto 적용 + margin: 0 auto; + } + &__emojis-area { + height: 36px; + display: flex; + align-items: center; + } &__top-reactions { display: flex; @@ -100,27 +114,27 @@ width: 100%; margin: 1% 0; border-bottom: 1px solid rgba(0, 0, 0, 0.12); - &.card-dark { - border: 1px solid rgba(255, 255, 255, 0.4); - } - &.card-light { - border: 1px solid rgba(0, 0, 0, 0.12); - } + &.card-dark { + border: 1px solid rgba(255, 255, 255, 0.4); + } + &.card-light { + border: 1px solid rgba(0, 0, 0, 0.12); + } } } .skeleton-card { - position: relative; - width: 275px; - height: 260px; - overflow: hidden; - box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08); - border-radius: 16px; - border: 1px solid rgba(0, 0, 0, 0.1); - transform: scale(1); - transition: transform 0.5s; - will-change: transform; - transform: translateZ(0); + position: relative; + width: 275px; + height: 260px; + overflow: hidden; + box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08); + border-radius: 16px; + border: 1px solid rgba(0, 0, 0, 0.1); + transform: scale(1); + transition: transform 0.5s; + will-change: transform; + transform: translateZ(0); &__content { display: flex; @@ -128,44 +142,44 @@ gap: 12px; height: 100%; padding: 30px 24px 20px; - } - - &__title { - @include skeleton-style; - width: 100%; - height:36px; - } - - &__profile { - @include skeleton-style; - width: 30%; - height: 30px; - border-radius: 16px; - } - - &__meta { - @include skeleton-style; - height: 26px; - flex-grow: 1; - } - - &__emojis-area { + } + + &__title { + @include skeleton-style; + width: 100%; + height: 36px; + } + + &__profile { + @include skeleton-style; + width: 30%; + height: 30px; + border-radius: 16px; + } + + &__meta { + @include skeleton-style; + height: 26px; + flex-grow: 1; + } + + &__emojis-area { display: flex; align-items: center; gap: 8px; - height: 36px; - } + height: 36px; + } - &__emoji { - @include skeleton-style; - width: 64px; - height: 32px; - border-radius: 16px; - } + &__emoji { + @include skeleton-style; + width: 64px; + height: 32px; + border-radius: 16px; + } &__myDiv { width: 100%; margin: 1% 0; - border: 1px solid rgba(0, 0, 0, 0.12); + border: 1px solid rgba(0, 0, 0, 0.12); } -} \ No newline at end of file +} diff --git a/src/pages/ListPage/components/Slider.jsx b/src/pages/ListPage/components/Slider.jsx index 515f913..5280da1 100644 --- a/src/pages/ListPage/components/Slider.jsx +++ b/src/pages/ListPage/components/Slider.jsx @@ -12,7 +12,7 @@ const Slider = ({ cards, hasNext, loadMore }) => { const { isDesktop, pageIndex, canPrev, canNext, goPrev, goNext } = useSliderPaging({ totalItems: cards.length, pageSize: PAGE_SIZE, - breakpoint: 1200, + breakpoint: 1248, }); // 데스크탑: 현재 페이지*4 ~ 페이지*4+4 슬라이스 @@ -32,7 +32,7 @@ const Slider = ({ cards, hasNext, loadMore }) => { return (
- {isDesktop && ( + {isDesktop && canPrev && (
diff --git a/src/pages/ListPage/components/Slider.module.scss b/src/pages/ListPage/components/Slider.module.scss index e94e2b5..dd93230 100644 --- a/src/pages/ListPage/components/Slider.module.scss +++ b/src/pages/ListPage/components/Slider.module.scss @@ -17,7 +17,7 @@ z-index: 2; // 데스크톱에서만 보이도록 - @media (min-width: 1200px) { + @include desktop { display: flex; } } @@ -34,7 +34,12 @@ &__container { width: 100%; overflow: visible; - @media (max-width: 1199px) { + @include mobile { + overflow-x: auto; + overflow-y: hidden; + -webkit-overflow-scrolling: touch; + } + @include tablet { overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch;