import { Fragment } from 'react'; import { AiOutlineFork, AiOutlineStar, AiOutlineGithub } from 'react-icons/ai'; import { MdInsertLink } from 'react-icons/md'; import { ga, getLanguageColor, skeleton } from '../../utils'; import { GithubProject } from '../../interfaces/github-project'; const GithubProjectCard = ({ header, githubProjects, loading, limit, googleAnalyticsId, }: { header: string; githubProjects: GithubProject[]; loading: boolean; limit: number; googleAnalyticsId?: string; }) => { if (!loading && githubProjects.length === 0) { return; } const renderSkeleton = () => { const array = []; for (let index = 0; index < limit; index++) { array.push(
{skeleton({ widthCls: 'w-32', heightCls: 'h-8', className: 'mb-1', })}
{skeleton({ widthCls: 'w-full', heightCls: 'h-4', className: 'mb-2', })} {skeleton({ widthCls: 'w-full', heightCls: 'h-4' })}
{skeleton({ widthCls: 'w-12', heightCls: 'h-4' })} {skeleton({ widthCls: 'w-12', heightCls: 'h-4' })}
{skeleton({ widthCls: 'w-12', heightCls: 'h-4' })}
, ); } return array; }; const renderProjects = () => { return githubProjects.map((item, index) => ( { e.preventDefault(); try { if (googleAnalyticsId) { ga.event('Click project', { project: item.name }); } } catch (error) { console.error(error); } window?.open(item.html_url, '_blank'); }} >
{item.name}

{item.description}

{item.stargazers_count} {item.forks_count}
{item.language}
)); }; return (
{/* Enhanced Header Section */}
{loading ? ( skeleton({ widthCls: 'w-12', heightCls: 'h-12', className: 'rounded-xl', }) ) : (
)}

{loading ? skeleton({ widthCls: 'w-48', heightCls: 'h-8' }) : header}

{loading ? skeleton({ widthCls: 'w-32', heightCls: 'h-4' }) : `Showcasing ${githubProjects.length} featured repositories`}
{/* Projects Grid */}
{loading ? renderSkeleton() : renderProjects()}
); }; export default GithubProjectCard;