diff --git a/src/components/sections/Reviews.tsx b/src/components/sections/Reviews.tsx index 120b488..82e69f3 100644 --- a/src/components/sections/Reviews.tsx +++ b/src/components/sections/Reviews.tsx @@ -3,9 +3,9 @@ import { useRef, useState } from 'react' import { useAutoScroll } from '@/hooks/useAutoScroll' +import StarRating from '@/components/ui/StarRating' import type { ReviewCMS, Media } from '@/types/globals' -const IMG_RATE = '/images/figma/rate-stars.svg' const IMG_AVATAR_DEFAULT = '/images/figma/review-avatar-bg.webp' function getMediaUrl(img: Media | string | null | undefined): string | null { @@ -137,11 +137,7 @@ export function Reviews({ data, title }: ReviewsProps) { > {review.ago} - {`${review.rating + diff --git a/src/components/ui/StarRating.tsx b/src/components/ui/StarRating.tsx new file mode 100644 index 0000000..0f9d755 --- /dev/null +++ b/src/components/ui/StarRating.tsx @@ -0,0 +1,23 @@ +type Props = { value: number; max?: number; size?: number; className?: string } + +export default function StarRating({ value, max = 5, size = 16, className }: Props) { + const v = Math.max(0, Math.min(max, Math.round(value))) + return ( +
+ {Array.from({ length: max }).map((_, i) => ( + + + + ))} +
+ ) +}