- Introduced multiple new components including AnimatedLink, Button, Calendar, Card, ColorSwatch, Divider, Filmstrip, FormContainer, FormField, GalleryCard, Heading, HeroOverlay, IdentitySection, ImmersionSection, NewArtistsSection, NewContactSection, NewHero, NewNavigation, Reveal, SectionLabel, StickySplit, and Toast. - Each component is designed with responsive layouts and customizable styles to improve the overall UI consistency and interactivity. - Implemented accessibility features and animations to enhance user engagement. This commit significantly expands the component library, providing a robust foundation for building a cohesive user interface.
57 lines
1.4 KiB
TypeScript
57 lines
1.4 KiB
TypeScript
"use client"
|
|
|
|
import * as React from "react"
|
|
import { cn } from "@/lib/utils"
|
|
import { useEffect, useRef, useState } from "react"
|
|
|
|
export interface RevealProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
delay?: number
|
|
}
|
|
|
|
const Reveal = React.forwardRef<HTMLDivElement, RevealProps>(({ className, delay = 0, children, ...props }, ref) => {
|
|
const elementRef = useRef<HTMLDivElement>(null)
|
|
const [isVisible, setIsVisible] = useState(false)
|
|
|
|
useEffect(() => {
|
|
const observer = new IntersectionObserver(
|
|
(entries) => {
|
|
entries.forEach((entry) => {
|
|
if (entry.isIntersecting) {
|
|
setTimeout(() => setIsVisible(true), delay)
|
|
observer.unobserve(entry.target)
|
|
}
|
|
})
|
|
},
|
|
{ threshold: 0.15, rootMargin: "0px 0px -50px 0px" },
|
|
)
|
|
|
|
if (elementRef.current) {
|
|
observer.observe(elementRef.current)
|
|
}
|
|
|
|
return () => observer.disconnect()
|
|
}, [delay])
|
|
|
|
return (
|
|
<div
|
|
ref={(node) => {
|
|
elementRef.current = node
|
|
if (typeof ref === "function") ref(node)
|
|
else if (ref) ref.current = node
|
|
}}
|
|
className={cn(
|
|
"transition-all duration-[0.8s] ease-out",
|
|
isVisible ? "opacity-100 translate-y-0" : "opacity-0 translate-y-[60px]",
|
|
className,
|
|
)}
|
|
style={{ transitionDelay: `${delay}ms` }}
|
|
{...props}
|
|
>
|
|
{children}
|
|
</div>
|
|
)
|
|
})
|
|
Reveal.displayName = "Reveal"
|
|
|
|
export { Reveal }
|