import { useGSAP } from "@gsap/react";import * as React from "react" import { useRef } from "react"; import { useGsapContext } from "~/app/_providers/GsapProvicer"; import gsap from 'gsap' import { cn } from "~/lib/utils" function Card({ className, size = "default", ...props }: React.ComponentProps<"div"> & { size?: "default" | "sm" }) { return (
img:first-child]:pt-0 data-[size=sm]:gap-3 data-[size=sm]:py-3 data-[size=sm]:has-data-[slot=card-footer]:pb-0 *:[img:first-child]:rounded-t-xl *:[img:last-child]:rounded-b-xl bg-opacity-60 backdrop-blur-sm", className )} {...props} /> ) } function AnimatedCard({ className, position = 0, size = "default", ...props }: React.ComponentProps<"div"> & { size?: "default" | "sm", position: gsap.Position }) { const gsapContext = useGsapContext() const ref = useRef(null) useGSAP(() => { const rect = ref.current?.getBoundingClientRect() const isInView = rect && rect.top < window.innerHeight const fromVars = { x: -100, opacity: 0, duration: 0.5 } if (isInView) { gsapContext?.addAnimation(gsap.from(ref.current, fromVars), position) } else { const scroller = gsapContext?.getScroller() console.log('scroller:', scroller) gsap.from(ref.current, { ...fromVars, scrollTrigger: { trigger: ref.current, start: 'top 85%', scroller, markers: true } }) } }, { dependencies: [] }) return (
img:first-child]:pt-0 data-[size=sm]:gap-3 data-[size=sm]:py-3 data-[size=sm]:has-data-[slot=card-footer]:pb-0 *:[img:first-child]:rounded-t-xl *:[img:last-child]:rounded-b-xl bg-opacity-60 backdrop-blur-sm", className )} {...props} /> ) } function CardHeader({ className, ...props }: React.ComponentProps<"div">) { return (
) } function CardTitle({ className, ...props }: React.ComponentProps<"div">) { return (
) } function CardDescription({ className, ...props }: React.ComponentProps<"div">) { return (
) } function CardAction({ className, ...props }: React.ComponentProps<"div">) { return (
) } function CardContent({ className, ...props }: React.ComponentProps<"div">) { return (
) } function CardFooter({ className, ...props }: React.ComponentProps<"div">) { return (
) } export { Card, CardHeader, CardFooter, CardTitle, CardAction, CardDescription, CardContent, AnimatedCard }