feat: some shit

This commit is contained in:
2023-08-08 21:50:23 +02:00
parent 6123956f08
commit c7d0e97ac0
18 changed files with 482 additions and 73 deletions

34
components/Rating.tsx Normal file
View File

@@ -0,0 +1,34 @@
import { IconStar, IconStarFilled } from "@components/icons.tsx";
import { useSignal } from "@preact/signals";
import { useState } from "preact/hooks";
export const Rating = (
props: { max?: number; rating: number },
) => {
const [rating, setRating] = useState(props.rating);
const [hover, setHover] = useState(0);
const max = useSignal(props.max || 5);
return (
<div
class="flex gap-2 px-5 rounded-2xl bg-gray-200 z-10"
style={{ color: "var(--foreground)", background: "var(--background)" }}
>
{Array.from({ length: max.value }).map((_, i) => {
return (
<span
class={`my-5 cursor-pointer opacity-${
(i + 1) <= rating ? 100 : (i + 1) <= hover ? 20 : 100
}`}
onMouseOver={() => setHover(i + 1)}
onClick={() => setRating(i + 1)}
>
{(i + 1) <= rating || (i + 1) <= hover
? <IconStarFilled class="w-4 h-4" />
: <IconStar class="w-4 h-4" />}
</span>
);
})}
</div>
);
};