MCPcopy Create free account
hub / github.com/code100x/daily-code / TrackCard2

Function TrackCard2

apps/web/components/TrackCard-2.tsx:18–99  ·  view source on GitHub ↗
({ track }: { track: TrackCardProps })

Source from the content-addressed store, hash-verified

16}
17
18export function TrackCard2({ track }: { track: TrackCardProps }) {
19 const router = useRouter();
20 const controls = useAnimation();
21 const ref = useRef<HTMLDivElement | null>(null);
22 const [showPreview, setShowPreview] = useState<boolean>(false);
23
24 const handleTrackClick = () => {
25 if (track.trackType === "CANVA") {
26 const searchParams = new URLSearchParams();
27 if (track.canvaLink) {
28 searchParams.set("canvaLink", track.canvaLink);
29 searchParams.set("title", track.title);
30 }
31 router.push(`/canva-track/${track.id}?${searchParams.toString()}`);
32 } else {
33 setShowPreview(true);
34 }
35 };
36
37 useEffect(() => {
38 const observer = new IntersectionObserver(
39 ([entry]) => {
40 if (entry && entry.isIntersecting) {
41 controls.start("visible");
42 }
43 },
44 { threshold: 0.3 }
45 );
46
47 if (ref.current) {
48 observer.observe(ref.current);
49 }
50
51 return () => {
52 if (ref.current) {
53 observer.unobserve(ref.current);
54 }
55 };
56 }, [controls]);
57
58 const variants = {
59 hidden: { opacity: 0 },
60 visible: { opacity: 1, transition: { duration: 0.1, ease: "easeOut" } },
61 };
62
63 return (
64 <>
65 <motion.div
66 ref={ref}
67 initial="hidden"
68 animate={controls}
69 variants={variants}
70 className="bg-primary/5 flex cursor-pointer flex-row items-start justify-between gap-4 rounded-xl p-4 backdrop-blur-xl transition-all duration-300 hover:-translate-y-1 md:items-center"
71 onClick={handleTrackClick}
72 >
73 <img src={track.image} alt={track.title} className="size-20 aspect-square object-cover rounded-xl" />
74 <div className="flex flex-col md:flex-row gap-4 w-full md:items-center justify-between">
75 <div className="flex flex-col gap-2">

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected