"use client" import { useEffect, useMemo, useRef, useState } from "react" import Link from "next/link" import { useFeatureFlag } from "@/components/feature-flags-provider" import { Button } from "@/components/ui/button" import { artists } from "@/data/artists" export function ArtistsSection() { const [visibleCards, setVisibleCards] = useState([]) const [scrollY, setScrollY] = useState(0) const sectionRef = useRef(null) const leftColumnRef = useRef(null) const centerColumnRef = useRef(null) const rightColumnRef = useRef(null) const advancedNavAnimations = useFeatureFlag("ADVANCED_NAV_SCROLL_ANIMATIONS_ENABLED") const allArtistIndices = useMemo(() => Array.from({ length: artists.length }, (_, idx) => idx), []) useEffect(() => { if (!advancedNavAnimations) { setVisibleCards(allArtistIndices) setScrollY(0) const columns = [leftColumnRef.current, centerColumnRef.current, rightColumnRef.current] columns.forEach((column) => { if (!column) return column.style.transform = "" column.querySelectorAll(".artist-image").forEach((img) => { ;(img as HTMLElement).style.transform = "" }) }) return } setVisibleCards([]) }, [advancedNavAnimations, allArtistIndices]) useEffect(() => { if (!advancedNavAnimations) return const observer = new IntersectionObserver( (entries) => { entries.forEach((entry) => { if (entry.isIntersecting) { const cardIndex = Number.parseInt(entry.target.getAttribute("data-index") || "0") setVisibleCards((prev) => [...new Set([...prev, cardIndex])]) } }) }, { threshold: 0.2, rootMargin: "0px 0px 0px 0px" }, ) const cards = sectionRef.current?.querySelectorAll("[data-index]") cards?.forEach((card) => observer.observe(card)) return () => observer.disconnect() }, [advancedNavAnimations]) useEffect(() => { if (!advancedNavAnimations) return let ticking = false const handleScroll = () => { if (!ticking) { requestAnimationFrame(() => { const scrollTop = window.pageYOffset setScrollY(scrollTop) ticking = false }) ticking = true } } window.addEventListener("scroll", handleScroll, { passive: true }) return () => window.removeEventListener("scroll", handleScroll) }, [advancedNavAnimations]) useEffect(() => { if (!advancedNavAnimations) return if (leftColumnRef.current && centerColumnRef.current && rightColumnRef.current) { const sectionTop = sectionRef.current?.offsetTop || 0 const relativeScroll = scrollY - sectionTop leftColumnRef.current.style.transform = `translateY(${relativeScroll * -0.025}px)` centerColumnRef.current.style.transform = `translateY(0px)` rightColumnRef.current.style.transform = `translateY(${relativeScroll * 0.025}px)` const leftImages = leftColumnRef.current.querySelectorAll(".artist-image") const centerImages = centerColumnRef.current.querySelectorAll(".artist-image") const rightImages = rightColumnRef.current.querySelectorAll(".artist-image") leftImages.forEach((img) => { ;(img as HTMLElement).style.transform = `translateY(${relativeScroll * -0.01}px)` }) centerImages.forEach((img) => { ;(img as HTMLElement).style.transform = `translateY(${relativeScroll * -0.0075}px)` }) rightImages.forEach((img) => { ;(img as HTMLElement).style.transform = `translateY(${relativeScroll * -0.005}px)` }) } }, [advancedNavAnimations, scrollY]) const cardVisibilityClass = (index: number) => { if (!advancedNavAnimations) { return "opacity-100 translate-y-0" } return visibleCards.includes(index) ? "opacity-100 translate-y-0" : "opacity-0 translate-y-8" } const cardTransitionDelay = (index: number) => { if (!advancedNavAnimations) { return undefined } return `${index * 50}ms` } // Better distribution for visual balance const leftColumn = [artists[0], artists[3], artists[6]] // Christy, Donovan, John const centerColumn = [artists[1], artists[4], artists[7]] // Angel, EJ, Pako const rightColumn = [artists[2], artists[5], artists[8]] // Amari, Heather, Sole return (

ARTISTS

Our exceptional team of tattoo artists, each bringing unique expertise and artistic vision to create your perfect tattoo.

{leftColumn.map((artist) => { const globalIndex = artists.indexOf(artist) const transitionDelay = cardTransitionDelay(globalIndex) return (
{/* Portfolio background - full width */}
{`${artist.name} {/* Darkening overlay to push background further back */}
{/* Artist portrait - with proper feathered mask */}
{`${artist.name}
{artist.experience}

{artist.name}

{artist.specialty}

{artist.bio}

) })}
{centerColumn.map((artist) => { const globalIndex = artists.indexOf(artist) const transitionDelay = cardTransitionDelay(globalIndex) return (
{/* Portfolio background - full width */}
{`${artist.name} {/* Darkening overlay to push background further back */}
{/* Artist portrait - with proper feathered mask */}
{`${artist.name}
{artist.experience}

{artist.name}

{artist.specialty}

{artist.bio}

) })}
{rightColumn.map((artist) => { const globalIndex = artists.indexOf(artist) const transitionDelay = cardTransitionDelay(globalIndex) return (
{/* Portfolio background - full width */}
{`${artist.name} {/* Darkening overlay to push background further back */}
{/* Artist portrait - with proper feathered mask */}
{`${artist.name}
{artist.experience}

{artist.name}

{artist.specialty}

{artist.bio}

) })}

READY?

Choose your artist and start your tattoo journey with United Tattoo.

) }