Skip to content

Commit 78d294f

Browse files
authored
Added subdle micro interaction animation (#1203)
1 parent 179bb65 commit 78d294f

File tree

2 files changed

+19
-10
lines changed

2 files changed

+19
-10
lines changed

landing/src/components/sections/complexity.tsx

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
11
"use client"
22

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"
46
import { Icon } from "../icons"
5-
import { motion } from "framer-motion"
67
import { Code } from "../layout/code"
7-
import { Logo } from "../atoms/logo"
88

99
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+
})
1116

1217
return (
13-
<section className="relative">
18+
<section ref={sectionRef} className="relative">
1419
<div className="w-full max-w-screen-xl mx-auto px-4 sm:px-8 lg:px-16 pt-24">
1520
<h2 className="font-display mb-6 text-2xl sm:text-3xl lg:text-4xl text-white text-center">
1621
{content.heading}
@@ -123,17 +128,17 @@ export const Complexity = () => {
123128
)}
124129
<button
125130
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}
127134
>
128-
{currentIndex >= index && (
129135
<>
130136
<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"
132138
style={{ backgroundColor: color }}
133-
/>
139+
/>
134140
<div className="absolute -left-2 w-9 h-9 rounded-xl border border-white/10" />
135141
</>
136-
)}
137142
<div className="relative bg-gradient-to-br from-zinc-100 to-zinc-500 h-5 w-5 rounded-md p-px">
138143
<div
139144
className={`rounded-[5px] h-full w-full flex items-center justify-center ${

landing/tailwind.config.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ const config: Config = {
1515
animation: {
1616
"accordion-down": "accordion-down 0.2s ease-out",
1717
"accordion-up": "accordion-up 0.2s ease-out",
18+
"subtle-ping": "subtle-ping 3s cubic-bezier(0, 0, 0.2, 1) infinite",
1819
},
1920
borderRadius: {
2021
lg: `var(--radius)`,
@@ -69,6 +70,9 @@ const config: Config = {
6970
from: { height: "var(--radix-accordion-content-height)" },
7071
to: { height: "0" },
7172
},
73+
"subtle-ping": {
74+
"75%, 100%": { opacity: "0", transform: "scale(1.5)" },
75+
},
7276
},
7377
minWidth: {
7478
"1/2": "50%"

0 commit comments

Comments
 (0)