-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: 한국농수산식품유통공사의 전통주 정보를 가져오는 로직 추가 * feat: 오늘의 우리술 추천을 보여주는 슬라이더 구현 * feat: 배너 텍스트 추가 * feat: 이전 다음 아이콘 추가 * fix: 키값 추가 * fix: 훅의 규칙을 위반하지 않도록 수정 * feat: 캐러셀 버튼을 클릭하여 조작할 수 있도록 구현 * fix: undefined 처리되어 에러나던 것 null 처리
- Loading branch information
Showing
14 changed files
with
435 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import styled, { css } from "styled-components"; | ||
import Image from "next/image"; | ||
import { MainBannerImage } from "public/images"; | ||
|
||
function Banner() { | ||
return ( | ||
<Container> | ||
<Image alt="배너" src={MainBannerImage} fill style={{ borderRadius: "16px" }} /> | ||
<BannerText> | ||
<MainText>여행의 즐거움을 우리술과 함께 레벨업!</MainText> | ||
<SubText> | ||
여행지에서 우리술이 고민된다면 <br /> 주루마블에서 해결해보세요 | ||
</SubText> | ||
</BannerText> | ||
</Container> | ||
); | ||
} | ||
|
||
const Container = styled.div` | ||
position: relative; | ||
margin-top: 12px; | ||
aspect-ratio: 16 / 9; | ||
`; | ||
|
||
const BannerText = styled.div` | ||
position: relative; | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
height: 100%; | ||
padding: 20px; | ||
`; | ||
|
||
const MainText = styled.div` | ||
${({ theme }) => css` | ||
${theme.typography.headline03} | ||
`}; | ||
`; | ||
|
||
const SubText = styled.div` | ||
${({ theme }) => css` | ||
${theme.typography.body_long03} | ||
margin-top: 8px; | ||
`}; | ||
`; | ||
export default Banner; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
101 changes: 101 additions & 0 deletions
101
apps/jurumarble/src/app/main/components/TodayDrinkRecommendation.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
import { useEffect, useRef, useState } from "react"; | ||
import { SvgStamp } from "src/assets/icons/components"; | ||
import styled, { css, useTheme } from "styled-components"; | ||
import useGetDrinkRecommendationListService from "../services/useGetDrinkRecommendationListService"; | ||
|
||
const SLIDE_MOVE_COUNT = 1; | ||
const ORIGINAL_IMAGE_LENGTH = 10; | ||
const MOVE_DISTANCE = 20; | ||
|
||
function TodayDrinkRecommendation() { | ||
const theme = useTheme(); | ||
const slideRef = useRef<HTMLDivElement>(null); | ||
const [currentSlide, setCurrentSlide] = useState(1); | ||
const [isAnimation, setIsAnimation] = useState(true); | ||
const [isFlowing, setIsFlowing] = useState(true); | ||
|
||
const date = new Date(); | ||
const drinkRecommendationList = useGetDrinkRecommendationListService({ | ||
page: date.getDate(), | ||
perPage: 10, | ||
}); | ||
|
||
useEffect(() => { | ||
if (!slideRef.current) return; | ||
|
||
if (currentSlide === ORIGINAL_IMAGE_LENGTH + 1) { | ||
setTimeout(() => { | ||
setIsAnimation(false); | ||
slideRef.current!.style.transform = `translateY(-${ | ||
MOVE_DISTANCE * ORIGINAL_IMAGE_LENGTH | ||
}px)`; | ||
setCurrentSlide(1); | ||
}, 500); | ||
|
||
setTimeout(() => { | ||
setIsAnimation(true); | ||
}, 600); | ||
} | ||
slideRef.current.style.transform = `translateY(-${MOVE_DISTANCE * (currentSlide - 1)}px)`; | ||
}, [currentSlide]); | ||
|
||
useEffect(() => { | ||
let intervalId: NodeJS.Timeout; | ||
if (isFlowing) { | ||
intervalId = setInterval(() => { | ||
setCurrentSlide((prev) => prev + SLIDE_MOVE_COUNT); | ||
}, 3500); | ||
} | ||
return () => clearTimeout(intervalId); | ||
}, [isFlowing, currentSlide]); | ||
|
||
return ( | ||
<Container> | ||
<H3> | ||
<SvgStamp width={24} height={24} fill={theme.colors.main_01} /> | ||
오늘의 우리술 추천 | ||
</H3> | ||
<Slider ref={slideRef} isAnimation={isAnimation}> | ||
{drinkRecommendationList?.map(({ 전통주명 }) => ( | ||
<DrinkName key={전통주명}>{전통주명}</DrinkName> | ||
))} | ||
</Slider> | ||
</Container> | ||
); | ||
} | ||
|
||
const Container = styled.div` | ||
display: flex; | ||
align-items: center; | ||
padding: 0 20px; | ||
margin-top: 8px; | ||
gap: 8px; | ||
overflow: hidden; | ||
`; | ||
|
||
const Slider = styled.div<{ isAnimation: boolean }>` | ||
display: flex; | ||
flex-direction: column; | ||
height: 18px; | ||
transition: transform 0.5s ease-in-out; | ||
gap: 2px; | ||
${({ isAnimation }) => isAnimation && `transform: translateY(-${MOVE_DISTANCE}px);`} | ||
`; | ||
|
||
const H3 = styled.h3` | ||
${({ theme }) => css` | ||
${theme.typography.body01}; | ||
color: ${theme.colors.main_01}; | ||
display: flex; | ||
align-items: center; | ||
gap: 2px; | ||
overflow: hidden; | ||
white-space: nowrap; | ||
`}; | ||
`; | ||
|
||
const DrinkName = styled.span` | ||
${({ theme }) => theme.typography.body03}; | ||
`; | ||
|
||
export default TodayDrinkRecommendation; |
22 changes: 22 additions & 0 deletions
22
apps/jurumarble/src/app/main/services/useGetDrinkRecommendationListService.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { useQuery } from "@tanstack/react-query"; | ||
import { getDrinkRecommendationListAPI } from "lib/apis/drink"; | ||
import { queryKeys } from "lib/queryKeys"; | ||
|
||
type GetDrinkRecommendationListProps = Exclude< | ||
Parameters<typeof getDrinkRecommendationListAPI>[0], | ||
undefined | ||
>; | ||
|
||
const getDrinkRecommendationListQueryKey = (params: GetDrinkRecommendationListProps) => [ | ||
queryKeys.TODAY_DRINK_RECOMMENDATION, | ||
{ ...params }, | ||
]; | ||
|
||
export default function useGetDrinkRecommendationListService( | ||
params: GetDrinkRecommendationListProps, | ||
) { | ||
const { data } = useQuery(getDrinkRecommendationListQueryKey(params), () => | ||
getDrinkRecommendationListAPI(params), | ||
); | ||
return data?.data; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.