memorium/components/Stars.tsx

21 lines
610 B
TypeScript
Raw Normal View History

2023-07-30 19:40:39 +02:00
import IconStar from "https://deno.land/x/tabler_icons_tsx@0.0.3/tsx/star.tsx";
import IconStarFilled from "https://deno.land/x/tabler_icons_tsx@0.0.3/tsx/star-filled.tsx";
export const Star = (
{ max = 5, rating = 3 }: { max?: number; rating: number },
) => {
return (
<div
class="flex gap-2 px-4 py-2 rounded-2xl bg-gray-200 z-10"
style={{ color: "#1F1F1F" }}
>
{Array.from({ length: max }).map((_, i) => {
2023-07-30 21:43:09 +02:00
if ((i + 1) <= rating) {
2023-07-30 19:40:39 +02:00
return <IconStarFilled class="w-4 h-4" />;
}
return <IconStar class="w-4 h-4" />;
})}
</div>
);
};