fix: make search usable again

This commit is contained in:
Max Richter
2025-11-05 00:42:53 +01:00
parent 7664abe089
commit 581f1c1926
9 changed files with 120 additions and 62 deletions

View File

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