From 5898dc9a18f674c3e3f6e97280ee2524ca017ba5 Mon Sep 17 00:00:00 2001 From: "gpt-engineer-app[bot]" <159125892+gpt-engineer-app[bot]@users.noreply.github.com> Date: Sat, 7 Mar 2026 21:34:12 +0000 Subject: [PATCH] Changes --- src/pages/Index.tsx | 242 ++++++++++++++++++++++++++++++-------------- 1 file changed, 164 insertions(+), 78 deletions(-) diff --git a/src/pages/Index.tsx b/src/pages/Index.tsx index 4632c1a..3cbe607 100644 --- a/src/pages/Index.tsx +++ b/src/pages/Index.tsx @@ -1,112 +1,198 @@ -import { useRef } from 'react'; +import { useRef, useState, useEffect, useCallback } from 'react'; import { GlassCard } from '@/components/GlassCard'; -import { useMousePosition } from '@/hooks/useMousePosition'; import avatar from '@/assets/avatar.png'; import { Home, MessageCircle, Rss, GitBranch, Search, ExternalLink } from 'lucide-react'; -const links = [ +const items = [ { icon: Home, label: 'Home', href: 'https://damaj.tech/', desc: 'Main page' }, { icon: MessageCircle, label: 'Who Am I?', href: 'https://damaj.tech/site/whoami', desc: 'About me' }, { icon: Rss, label: 'Blog', href: 'https://damaj.tech/site/blog', desc: 'My writings' }, -]; - -const services = [ { icon: GitBranch, label: 'Git Server', href: 'https://git.damaj.tech/', desc: 'Self-hosted Forgejo' }, - { icon: Search, label: 'SearXNG', href: 'https://searxng.damaj.tech/', desc: 'Private search engine' }, + { icon: Search, label: 'SearXNG', href: 'https://searxng.damaj.tech/', desc: 'Private search' }, ]; const Index = () => { const containerRef = useRef(null); - const mouse = useMousePosition(containerRef); + const avatarRef = useRef(null); + const cardRefs = useRef<(HTMLAnchorElement | null)[]>([]); + const [lines, setLines] = useState<{ x1: number; y1: number; x2: number; y2: number }[]>([]); + const [mousePos, setMousePos] = useState({ x: 0, y: 0 }); + const [mounted, setMounted] = useState(false); + + const updateLines = useCallback(() => { + if (!containerRef.current || !avatarRef.current) return; + const containerRect = containerRef.current.getBoundingClientRect(); + const avatarRect = avatarRef.current.getBoundingClientRect(); + const cx = avatarRect.left + avatarRect.width / 2 - containerRect.left; + const cy = avatarRect.top + avatarRect.height / 2 - containerRect.top; + + const newLines = cardRefs.current.map((card) => { + if (!card) return { x1: cx, y1: cy, x2: cx, y2: cy }; + const cardRect = card.getBoundingClientRect(); + const cardCx = cardRect.left + cardRect.width / 2 - containerRect.left; + const cardCy = cardRect.top + cardRect.height / 2 - containerRect.top; + return { x1: cx, y1: cy, x2: cardCx, y2: cardCy }; + }); + setLines(newLines); + }, []); + + useEffect(() => { + updateLines(); + const timer = setTimeout(() => setMounted(true), 100); + window.addEventListener('resize', updateLines); + return () => { + window.removeEventListener('resize', updateLines); + clearTimeout(timer); + }; + }, [updateLines]); + + useEffect(() => { + // Re-calc after fonts/images load + const timer = setTimeout(updateLines, 500); + return () => clearTimeout(timer); + }, [updateLines]); + + const handleMouseMove = useCallback((e: React.MouseEvent) => { + if (!containerRef.current) return; + const rect = containerRef.current.getBoundingClientRect(); + setMousePos({ x: e.clientX - rect.left, y: e.clientY - rect.top }); + }, []); return (
{/* Global mouse glow */}
-
- {/* Avatar + Intro */} - -
- Mohamad's avatar + + + + + + + + + + + + + + {lines.map((line, i) => ( + + {/* Glow line */} + -
-

- 👋 Hey There! -

-

- My name is Mohamad -

-

- Welcome to my space. Feel free to look around. -

-
-
-
+ {/* Main line */} + + {/* End dot on card */} + + + ))} + {/* Center dot */} + {lines.length > 0 && ( + + )} + - {/* Website Content */} -
-

- Website Content -

-
- {links.map((link) => ( - - -
- - -
-

{link.label}

-

{link.desc}

-
-
- ))} -
+ {/* Center Avatar Hub */} +
+
+ Mohamad
- - {/* Self-hosted Services */} -
-

- Self-hosted Services -

-
- {services.map((svc) => ( - - -
- - -
-

{svc.label}

-

{svc.desc}

-
-
- ))} -
+
+

+ 👋 Hey There! +

+

+ I'm Mohamad — welcome to my space. +

- - {/* Footer */} -

- damaj.tech -

+ + {/* Cards arranged around */} + + + {/* Footer */} +

+ damaj.tech +

); };