ant-design/.dumi/theme/slots/Content/ContributorAvatar.tsx
afc163 acbbbfebc2
refactor: import other components async in component doc (#46491)
* refactor: ContributorAvatar component

* refactor: import other components async in component doc

* chore: fix lint

* docs: add suspense fallback

* docs: add suspense fallback

* docs: add suspense fallback
2023-12-17 15:33:54 +08:00

39 lines
964 B
TypeScript

import React from 'react';
import { Avatar, Skeleton, Tooltip } from 'antd';
const AvatarPlaceholder: React.FC<{ num?: number }> = ({ num = 3 }) => (
<li>
{Array.from({ length: num }).map((_, i) => (
<Skeleton.Avatar size="small" active key={i} style={{ marginLeft: i === 0 ? 0 : -8 }} />
))}
</li>
);
interface ContributorAvatarProps {
username?: string;
url?: string;
loading?: boolean;
}
const ContributorAvatar: React.FC<ContributorAvatarProps> = ({ username, url, loading }) => {
if (loading) {
return <AvatarPlaceholder />;
}
if (username?.includes('github-actions')) {
return null;
}
return (
<Tooltip title={username}>
<li>
<a href={`https://github.com/${username}`} target="_blank" rel="noopener noreferrer">
<Avatar size="small" src={url} alt={username}>
{username}
</Avatar>
</a>
</li>
</Tooltip>
);
};
export default ContributorAvatar;