-
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.
Merge pull request #29 from Dium-dev/25-reviews
Add reviews section
- Loading branch information
Showing
17 changed files
with
505 additions
and
202 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,17 @@ | ||
{ | ||
"$schema": "https://ui.shadcn.com/schema.json", | ||
"style": "new-york", | ||
"rsc": true, | ||
"tsx": true, | ||
"tailwind": { | ||
"config": "tailwind.config.ts", | ||
"css": "src/app/globals.css", | ||
"baseColor": "slate", | ||
"cssVariables": true, | ||
"prefix": "" | ||
}, | ||
"aliases": { | ||
"components": "@/components", | ||
"utils": "@/lib/utils" | ||
} | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
"use server"; | ||
|
||
export const getReviews = async () => { | ||
try { | ||
const response = await fetch("http://localhost:3005/reviews"); | ||
const { data } = await response.json(); | ||
return data; | ||
} catch (_) { | ||
return []; | ||
} | ||
}; |
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
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
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,35 @@ | ||
"use client"; | ||
import StarRatings from "react-star-ratings"; | ||
import { ImQuotesLeft } from "react-icons/im"; | ||
import { IoPersonCircleSharp } from "react-icons/io5"; | ||
import { Review } from "@/types"; | ||
|
||
interface ReviewCardProps { | ||
review: Review; | ||
} | ||
|
||
export const ReviewCard = ({ review }: ReviewCardProps) => { | ||
return ( | ||
<article className="w-60 ms:w-96 p-4 space-y-3 shadow-lg mx-4 my-6 rounded-lg border border-black border-opacity-15 bg-white dark:bg-primary-dm"> | ||
<div className="h-32"> | ||
<ImQuotesLeft size={30} color="red" /> | ||
<div className="h-24 overflow-y-scroll"> | ||
<p>{review.review}</p> | ||
</div> | ||
</div> | ||
<hr /> | ||
<div className="flex flex-col ms:flex-row items-center gap-x-3"> | ||
<IoPersonCircleSharp size={50} /> | ||
<div className="flex flex-col justify-center items-center ms:items-start"> | ||
<p className="text-lg">{review.user}</p> | ||
<StarRatings | ||
rating={3} | ||
numberOfStars={5} | ||
starRatedColor="orange" | ||
starDimension="30px" | ||
/> | ||
</div> | ||
</div> | ||
</article> | ||
); | ||
}; |
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,17 @@ | ||
import Marquee from "react-fast-marquee"; | ||
import { ReviewCard } from "./ReviewCard"; | ||
import { Review } from "@/types"; | ||
|
||
interface ReviewsMarqueeProps { | ||
reviews: Review[]; | ||
} | ||
|
||
export const ReviewsMarquee = ({ reviews }: ReviewsMarqueeProps) => { | ||
return ( | ||
<Marquee pauseOnHover speed={20}> | ||
{reviews.map((review) => ( | ||
<ReviewCard review={review} key={review.id} /> | ||
))} | ||
</Marquee> | ||
); | ||
}; |
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,68 @@ | ||
"use client"; | ||
|
||
import { Skeleton } from "../ui/skeleton"; | ||
import StarRatings from "react-star-ratings"; | ||
|
||
export const ReviewsSkeleton = () => { | ||
return ( | ||
<div className="flex justify-evenly items-center p-4"> | ||
<div> | ||
<Skeleton className="w-96 h-56 p-4 flex flex-col justify-between gap-y-3"> | ||
<Skeleton className="h-10 w-10" /> | ||
<Skeleton className="w-full h-4" /> | ||
<Skeleton className="w-full h-4" /> | ||
<div className="flex items-center gap-x-4"> | ||
<Skeleton className="rounded-full h-14 w-14" /> | ||
<div className="flex flex-col gap-y-2"> | ||
<Skeleton className="w-28 h-4" /> | ||
<StarRatings | ||
rating={0} | ||
numberOfStars={5} | ||
starRatedColor="orange" | ||
starDimension="35px" | ||
/> | ||
</div> | ||
</div> | ||
</Skeleton> | ||
</div> | ||
<div> | ||
<Skeleton className="w-96 h-56 p-4 flex flex-col justify-between gap-y-3"> | ||
<Skeleton className="h-10 w-10" /> | ||
<Skeleton className="w-full h-4" /> | ||
<Skeleton className="w-full h-4" /> | ||
<div className="flex items-center gap-x-4"> | ||
<Skeleton className="rounded-full h-14 w-14" /> | ||
<div className="flex flex-col gap-y-2"> | ||
<Skeleton className="w-28 h-4" /> | ||
<StarRatings | ||
rating={0} | ||
numberOfStars={5} | ||
starRatedColor="orange" | ||
starDimension="35px" | ||
/> | ||
</div> | ||
</div> | ||
</Skeleton> | ||
</div> | ||
<div> | ||
<Skeleton className="w-96 h-56 p-4 flex flex-col justify-between gap-y-3"> | ||
<Skeleton className="h-10 w-10" /> | ||
<Skeleton className="w-full h-4" /> | ||
<Skeleton className="w-full h-4" /> | ||
<div className="flex items-center gap-x-4"> | ||
<Skeleton className="rounded-full h-14 w-14" /> | ||
<div className="flex flex-col gap-y-2"> | ||
<Skeleton className="w-28 h-4" /> | ||
<StarRatings | ||
rating={0} | ||
numberOfStars={5} | ||
starRatedColor="orange" | ||
starDimension="35px" | ||
/> | ||
</div> | ||
</div> | ||
</Skeleton> | ||
</div> | ||
</div> | ||
); | ||
}; |
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,20 @@ | ||
import { Review } from "@/types"; | ||
import { ReviewsMarquee } from "./ReviewsMarquee"; | ||
import { getReviews } from "@/actions/reviews"; | ||
|
||
export const Reviews = async () => { | ||
const reviews: Review[] = await getReviews(); | ||
|
||
if(!reviews.length) return null | ||
|
||
return ( | ||
<section | ||
className="w-full" | ||
style={{ background: "linear-gradient(red 50%, transparent 50%)" }} | ||
> | ||
<div className="max-w-[1920px] mx-auto"> | ||
<ReviewsMarquee reviews={reviews} /> | ||
</div> | ||
</section> | ||
); | ||
}; |
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,15 @@ | ||
import { cn } from "@/lib/utils" | ||
|
||
function Skeleton({ | ||
className, | ||
...props | ||
}: React.HTMLAttributes<HTMLDivElement>) { | ||
return ( | ||
<div | ||
className={cn("animate-pulse rounded-md bg-primary/10", className)} | ||
{...props} | ||
/> | ||
) | ||
} | ||
|
||
export { Skeleton } |
File renamed without changes.
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,6 @@ | ||
import { type ClassValue, clsx } from "clsx" | ||
import { twMerge } from "tailwind-merge" | ||
|
||
export function cn(...inputs: ClassValue[]) { | ||
return twMerge(clsx(inputs)) | ||
} |
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 |
---|---|---|
@@ -1,4 +1,10 @@ | ||
export interface Brand { | ||
image: string; | ||
name: string; | ||
} | ||
} | ||
export interface Review { | ||
id: string; | ||
review: string; | ||
rating: number; | ||
user: string; | ||
} |
Oops, something went wrong.