"use client" import React, { useEffect, useState } from "react" import { Lightbulb, PenTool, Code2, Rocket, Wrench, MessageSquare, LifeBuoy, } from "lucide-react" const STATION_COLORS: Record< string, { border: string; bg: string; text: string; label: string } > = { idea: { border: "border-amber-400", bg: "bg-amber-50", text: "text-amber-600", label: "text-amber-700" }, concept: { border: "border-emerald-400", bg: "bg-emerald-50", text: "text-emerald-600", label: "text-emerald-700" }, consulting: { border: "border-sky-400", bg: "bg-sky-50", text: "text-sky-600", label: "text-sky-700" }, development: { border: "border-fuchsia-400", bg: "bg-fuchsia-100", text: "text-fuchsia-600", label: "text-fuchsia-700" }, deployment: { border: "border-sky-400", bg: "bg-sky-50", text: "text-sky-600", label: "text-sky-700" }, maintenance: { border: "border-slate-400", bg: "bg-slate-100", text: "text-slate-600", label: "text-slate-700" }, support: { border: "border-rose-400", bg: "bg-rose-50", text: "text-rose-600", label: "text-rose-700" }, } const STATIONS = [ { id: "idea", icon: Lightbulb, label: "Idea", lineThreshold: 0 }, { id: "concept", icon: PenTool, label: "Concept", lineThreshold: 15 }, { id: "deployment", icon: Rocket, label: "Deployment", lineThreshold: 45 }, { id: "maintenance", icon: Wrench, label: "Maintenance", lineThreshold: 80 }, ] as const const RIGHT_STATIONS = [ { id: "consulting", icon: MessageSquare, label: "Consulting", lineThreshold: 0 }, { id: "development", icon: Code2, label: "Development", lineThreshold: 25 }, { id: "support", icon: LifeBuoy, label: "Support", lineThreshold: 60 }, ] as const export function HomeJourneyBackground({ children }: { children: React.ReactNode }) { const childArray = React.Children.toArray(children) const heroContent = childArray[0] const mainContent = childArray.slice(1) const [visibleStations, setVisibleStations] = useState>(new Set()) const [visibleRightStations, setVisibleRightStations] = useState>( new Set() ) useEffect(() => { const handleScroll = () => { const y = window.scrollY const docHeight = document.documentElement.scrollHeight - window.innerHeight const scrollProgress = docHeight > 0 ? Math.min(y / docHeight, 1) : 0 const ideaThreshold = 0.02 const linePercent = scrollProgress >= ideaThreshold ? Math.min( 100, ((scrollProgress - ideaThreshold) / (1 - ideaThreshold)) * 100 ) : 0 const newVisible = new Set() if (scrollProgress >= ideaThreshold) { newVisible.add("idea") } STATIONS.forEach((station) => { if (station.id !== "idea" && linePercent >= station.lineThreshold) { newVisible.add(station.id) } }) setVisibleStations(newVisible) const newVisibleRight = new Set() if (scrollProgress >= ideaThreshold) { newVisibleRight.add("consulting") } RIGHT_STATIONS.forEach((station) => { if ( station.id !== "consulting" && linePercent >= station.lineThreshold ) { newVisibleRight.add(station.id) } }) setVisibleRightStations(newVisibleRight) } handleScroll() window.addEventListener("scroll", handleScroll, { passive: true }) return () => window.removeEventListener("scroll", handleScroll) }, []) return (
{heroContent}
{mainContent}
) }