add suspense for project cards

This commit is contained in:
Carl-Gerhard Lindesvärd
2024-05-08 10:32:45 +02:00
parent 63c30caa7a
commit 4936ba1d40
3 changed files with 93 additions and 47 deletions

View File

@@ -0,0 +1,27 @@
'use client';
import { useEffect, useRef } from 'react';
import { cn } from '@/utils/cn';
type Props = {
className?: string;
children: React.ReactNode;
};
export function FadeIn({ className, children }: Props) {
const ref = useRef<HTMLDivElement>(null);
useEffect(() => {
if (ref.current) {
ref.current.classList.remove('opacity-0');
ref.current.classList.add('opacity-100');
}
}, []);
return (
<div
className={cn('opacity-0 transition-opacity duration-500', className)}
ref={ref}
>
{children}
</div>
);
}