From 5ae6cde14ed05937bbb3ca1bf518a254edc5bc53 Mon Sep 17 00:00:00 2001 From: Julien Froidefond Date: Tue, 9 Dec 2025 14:40:02 +0100 Subject: [PATCH] Enhance HeroSection component: Implement mouse-following gradient effect for the game title, improving visual interactivity. Update CSS for better font formatting and add a new title animation class for enhanced text styling. --- app/globals.css | 15 ++++++--- components/HeroSection.tsx | 62 ++++++++++++++++++++++++++++++++++++-- 2 files changed, 70 insertions(+), 7 deletions(-) diff --git a/app/globals.css b/app/globals.css index eb0523a..a9ba1f9 100644 --- a/app/globals.css +++ b/app/globals.css @@ -5,7 +5,9 @@ @layer base { body { @apply bg-black text-white; - font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif; + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", + "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", + "Helvetica Neue", sans-serif; } } @@ -16,11 +18,16 @@ image-rendering: -moz-crisp-edges; image-rendering: crisp-edges; } - + .text-pixel { - font-family: 'Courier New', monospace; + font-family: "Courier New", monospace; text-shadow: 2px 2px 0px rgba(0, 0, 0, 0.8); letter-spacing: 1px; } -} + .title-animated { + background-clip: text; + -webkit-background-clip: text; + -webkit-text-fill-color: transparent; + } +} diff --git a/components/HeroSection.tsx b/components/HeroSection.tsx index 2810408..8fa3a7e 100644 --- a/components/HeroSection.tsx +++ b/components/HeroSection.tsx @@ -2,9 +2,34 @@ import { useBackgroundImage } from "@/hooks/usePreferences"; import Link from "next/link"; +import { useState, useEffect, useRef } from "react"; export default function HeroSection() { const backgroundImage = useBackgroundImage("home", "/got-2.jpg"); + const titleRef = useRef(null); + const [mousePosition, setMousePosition] = useState({ x: 50, y: 50 }); + + useEffect(() => { + const handleMouseMove = (e: MouseEvent) => { + if (titleRef.current) { + const rect = titleRef.current.getBoundingClientRect(); + const x = ((e.clientX - rect.left) / rect.width) * 100; + const y = ((e.clientY - rect.top) / rect.height) * 100; + setMousePosition({ + x: Math.max(0, Math.min(100, x)), + y: Math.max(0, Math.min(100, y)), + }); + } + }; + + window.addEventListener("mousemove", handleMouseMove); + return () => window.removeEventListener("mousemove", handleMouseMove); + }, []); + + // Calculer la position du gradient basée sur la souris avec plus d'amplitude + const gradientPosition = mousePosition.x; + const glowIntensity = 12 + mousePosition.x / 5; + const glowOpacity = 0.4 + mousePosition.y / 250; return (
@@ -23,15 +48,46 @@ export default function HeroSection() {
{/* Game Title */}
-

+

GAME.OF.TECH + {/* Glow effect qui suit la souris */} +