diff --git a/packages/ui/src/card.tsx b/packages/ui/src/card.tsx index 4973f2e2..ed7a29de 100644 --- a/packages/ui/src/card.tsx +++ b/packages/ui/src/card.tsx @@ -1,4 +1,4 @@ -import { component$, useSignal, useVisibleTask$, $ } from "@builder.io/qwik"; +import { component$ } from "@builder.io/qwik"; type Props = { game: { @@ -9,87 +9,25 @@ type Props = { export const Card = component$(({ game }: Props) => { const imageUrl = `http://localhost:8787/image/cover/${game.id}.avif` - const backgroundColor = useSignal(undefined); - const imgRef = useSignal(); - - const extractColor = $((img: HTMLImageElement) => { - const canvas = document.createElement('canvas'); - const ctx = canvas.getContext('2d'); - if (!ctx) return "rgb(200,200,200)"; // Fallback light gray - - canvas.width = img.naturalWidth; - canvas.height = img.naturalHeight; - ctx.drawImage(img, 0, 0, img.naturalWidth, img.naturalHeight); - - const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height).data; - let r = 0, g = 0, b = 0, count = 0; - - for (let i = 0; i < imageData.length; i += 4) { - // Only consider brighter pixels - if (imageData[i] > 150 || imageData[i + 1] > 150 || imageData[i + 2] > 150) { - r += imageData[i]; - g += imageData[i + 1]; - b += imageData[i + 2]; - count++; - } - } - - if (count === 0) return "rgb(200,200,200)"; // Fallback if no bright pixels found - - r = Math.floor(r / count); - g = Math.floor(g / count); - b = Math.floor(b / count); - - - // For light mode, keep the existing logic - const minBrightness = 100; - r = Math.max(r, minBrightness); - g = Math.max(g, minBrightness); - b = Math.max(b, minBrightness); - - - return `rgb(${r},${g},${b})`; - }); - - useVisibleTask$(async ({ track }) => { - track(() => imgRef.value); - - const img = imgRef.value; - if (img) { - const processImage = async () => { - backgroundColor.value = await extractColor(img); - }; - - if (img.complete) { - await processImage(); - } else { - img.onload = processImage; - } - } - }); return ( -
-
+
+ ) }); \ No newline at end of file diff --git a/packages/ui/src/home-nav-bar.tsx b/packages/ui/src/home-nav-bar.tsx index 2e2d59da..3d9151e4 100644 --- a/packages/ui/src/home-nav-bar.tsx +++ b/packages/ui/src/home-nav-bar.tsx @@ -29,13 +29,13 @@ export const HomeNavBar = component$(() => {

-
-