From f99f0992b837507897976c1354370c99edbab547 Mon Sep 17 00:00:00 2001 From: Leo dev Date: Sat, 22 Nov 2025 12:28:47 +0100 Subject: [PATCH] Improved background --- src/app/page.tsx | 4 +- src/components/Background.tsx | 74 ++++------------------------------- tailwind.config.ts | 2 +- 3 files changed, 11 insertions(+), 69 deletions(-) diff --git a/src/app/page.tsx b/src/app/page.tsx index b07f2c2..45268ac 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -32,7 +32,7 @@ export default function App() { }, []); return ( -
+

Hey, I'm Klesti! 👋🏻

@@ -77,7 +77,7 @@ export default function App() {

-
+
diff --git a/src/components/Background.tsx b/src/components/Background.tsx index 5d88653..c0b6210 100644 --- a/src/components/Background.tsx +++ b/src/components/Background.tsx @@ -1,79 +1,21 @@ "use client"; -import React, { useEffect, useRef, useState } from "react"; +import React from "react"; export default function Background({ children, -}: Readonly<{ - children: React.ReactNode; -}>) { - const [pos, setPos] = useState({ x: 30, y: 100 }); - const [vel, setVel] = useState({ x: 1, y: 1 }); - - useEffect(() => { - let frame: number; - let x = pos.x; - let y = pos.y; - let vx = vel.x; - let vy = vel.y; - - const speed = 0.5; - const size = 100; - - // helper for collision detection - const detectCollision = ( - nextX: number, - nextY: number, - w: number, - h: number - ) => { - let collidedX = false; - let collidedY = false; - - // Left or Right wall - if (nextX <= 0 || nextX + size >= w) collidedX = true; - - // Top or Bottom wall - if (nextY <= 0 || nextY + size >= h) collidedY = true; - - return { collidedX, collidedY }; - }; - - const animate = () => { - const w = window.innerWidth; - const h = window.innerHeight; - - const nextX = x + vx * speed; - const nextY = y + vy * speed; - - const { collidedX, collidedY } = detectCollision(nextX, nextY, w, h); - - if (collidedX) vx *= -1; - if (collidedY) vy *= -1; - - x += vx * speed; - y += vy * speed; - - setPos({ x, y }); - setVel({ x: vx, y: vy }); - - frame = requestAnimationFrame(animate); - }; - - frame = requestAnimationFrame(animate); - return () => cancelAnimationFrame(frame); - }, []); - +}: Readonly<{ children: React.ReactNode }>) { return (
- Logo +
{children}
); diff --git a/tailwind.config.ts b/tailwind.config.ts index 241e5f8..72ca559 100644 --- a/tailwind.config.ts +++ b/tailwind.config.ts @@ -14,7 +14,7 @@ export default { red: '#f5304c', 'red-400': '#fa5770', 'red-600': '#eb2642', - 'transparent-ish': '#0000006F', + 'transparent-ish': '#0000000A', }, animation: { fadeIn: "fadeIn 1s ease-in-out",