diff --git a/features/home/actions/getRecommenationAnime.ts b/features/home/actions/getRecommenationAnime.ts index a05b646..c69cee6 100644 --- a/features/home/actions/getRecommenationAnime.ts +++ b/features/home/actions/getRecommenationAnime.ts @@ -13,7 +13,7 @@ export type RecommendationAnime = { export const getRecommendationAnimeAction = async (): Promise< RecommendationAnime[] > => { - // await new Promise((resolve) => setTimeout(resolve, 2000)); + await new Promise((resolve) => setTimeout(resolve, 2000)); return [ { diff --git a/features/home/sections/Recommendation/components/ScrollingButton.tsx b/features/home/sections/Recommendation/components/ScrollingButton.tsx index 05c8725..ad30a98 100644 --- a/features/home/sections/Recommendation/components/ScrollingButton.tsx +++ b/features/home/sections/Recommendation/components/ScrollingButton.tsx @@ -1,16 +1,21 @@ import { Button } from "@/shared/libs/shadcn/ui/button"; import { ButtonGroup } from "@/shared/libs/shadcn/ui/button-group"; import { ArrowLeft, ArrowRight } from "lucide-react"; -import React from "react"; -const ScrollingButton = () => { +const ScrollingButton = ({ + scrollLeft, + scrollRight, +}: { + scrollLeft: () => void; + scrollRight: () => void; +}) => { return (
- - diff --git a/features/home/sections/Recommendation/main.client.tsx b/features/home/sections/Recommendation/main.client.tsx new file mode 100644 index 0000000..5fe7faa --- /dev/null +++ b/features/home/sections/Recommendation/main.client.tsx @@ -0,0 +1,46 @@ +"use client"; + +import { useRef } from "react"; +import { RecommendationAnime } from "../../actions/getRecommenationAnime"; +import AnimeRecommendationCard from "./components/Card"; +import ScrollingButton from "./components/ScrollingButton"; +import { Skeleton } from "@/shared/libs/shadcn/ui/skeleton"; + +const RecommendationClient = ({ + result, +}: { + result: RecommendationAnime[]; +}) => { + const scrollingContainer = useRef(null); + + const scrollLeft = () => { + console.log("scroll left"); + if (scrollingContainer.current) { + scrollingContainer.current.scrollBy({ left: -788, behavior: "smooth" }); + } + }; + const scrollRight = () => { + console.log("scroll right"); + if (scrollingContainer.current) { + scrollingContainer.current.scrollBy({ left: 788, behavior: "smooth" }); + } + }; + + return ( +
+
+ +
+
+ {result.map((item, index) => ( + + ))} +
+
+ ); +}; + +export default RecommendationClient; diff --git a/features/home/sections/Recommendation/main.tsx b/features/home/sections/Recommendation/main.tsx index 430821c..e4d3229 100644 --- a/features/home/sections/Recommendation/main.tsx +++ b/features/home/sections/Recommendation/main.tsx @@ -1,16 +1,10 @@ import { getRecommendationAnimeAction } from "../../actions/getRecommenationAnime"; -import AnimeRecommendationCard from "./components/Card"; +import RecommendationClient from "./main.client"; const RecommendationMain = async () => { const data = async () => await getRecommendationAnimeAction(); const result = await data(); - return ( -
- {result.map((item, index) => ( - - ))} -
- ); + return ; }; export default RecommendationMain; diff --git a/features/home/sections/Recommendation/skeleton.tsx b/features/home/sections/Recommendation/skeleton.tsx index 4e69a90..ed77a66 100644 --- a/features/home/sections/Recommendation/skeleton.tsx +++ b/features/home/sections/Recommendation/skeleton.tsx @@ -1,5 +1,19 @@ +import { Skeleton } from "@/shared/libs/shadcn/ui/skeleton"; + const RecommendationSkeleton = () => { - return
loading...
; + const skeletonLenght = 6; + + return ( +
+ {[...Array(skeletonLenght)].map((_, index) => ( +
+ + + +
+ ))} +
+ ); }; export default RecommendationSkeleton; diff --git a/features/home/sections/Recommendation/wrapper.tsx b/features/home/sections/Recommendation/wrapper.tsx index c4d15aa..24baaed 100644 --- a/features/home/sections/Recommendation/wrapper.tsx +++ b/features/home/sections/Recommendation/wrapper.tsx @@ -5,14 +5,11 @@ import ScrollingButton from "./components/ScrollingButton"; const Recommendation = async () => { return ( -
+

Maybe You Like

-
- -
}>