|
1 | 1 | "use client" |
2 | 2 |
|
3 | | -import { useState } from "react" |
| 3 | +import { motion, useInView } from "framer-motion" |
| 4 | +import { ElementRef, useRef, useState } from "react" |
| 5 | +import { Logo } from "../atoms/logo" |
4 | 6 | import { Icon } from "../icons" |
5 | | -import { motion } from "framer-motion" |
6 | 7 | import { Code } from "../layout/code" |
7 | | -import { Logo } from "../atoms/logo" |
8 | 8 |
|
9 | 9 | export const Complexity = () => { |
10 | | - const [currentIndex, setCurrentIndex] = useState<number>(0) |
| 10 | + const [currentIndex, setCurrentIndex] = useState(0) |
| 11 | + |
| 12 | + const sectionRef = useRef<ElementRef<"section">>(null) |
| 13 | + const isInView = useInView(sectionRef, { |
| 14 | + amount: 0.6 |
| 15 | + }) |
11 | 16 |
|
12 | 17 | return ( |
13 | | - <section className="relative"> |
| 18 | + <section ref={sectionRef} className="relative"> |
14 | 19 | <div className="w-full max-w-screen-xl mx-auto px-4 sm:px-8 lg:px-16 pt-24"> |
15 | 20 | <h2 className="font-display mb-6 text-2xl sm:text-3xl lg:text-4xl text-white text-center"> |
16 | 21 | {content.heading} |
@@ -123,17 +128,17 @@ export const Complexity = () => { |
123 | 128 | )} |
124 | 129 | <button |
125 | 130 | onClick={() => setCurrentIndex(index)} |
126 | | - className="text-white flex gap-4 items-center text-left relative" |
| 131 | + className="text-white flex gap-4 items-center text-left relative group" |
| 132 | + data-highlight={isInView && (currentIndex + 1) === index} |
| 133 | + data-active={currentIndex >= index} |
127 | 134 | > |
128 | | - {currentIndex >= index && ( |
129 | 135 | <> |
130 | 136 | <div |
131 | | - className="absolute -left-2 w-9 h-9 rounded-xl" |
| 137 | + className="absolute -left-2 size-9 rounded-xl animate-none group-data-[highlight=true]:animate-subtle-ping group-data-[highlight=true]:visible invisible group-data-[active=true]:visible" |
132 | 138 | style={{ backgroundColor: color }} |
133 | | - /> |
| 139 | + /> |
134 | 140 | <div className="absolute -left-2 w-9 h-9 rounded-xl border border-white/10" /> |
135 | 141 | </> |
136 | | - )} |
137 | 142 | <div className="relative bg-gradient-to-br from-zinc-100 to-zinc-500 h-5 w-5 rounded-md p-px"> |
138 | 143 | <div |
139 | 144 | className={`rounded-[5px] h-full w-full flex items-center justify-center ${ |
|
0 commit comments