mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-30 12:28:33 +08:00
10f88d197c
* chore(deps): update dependency @qixian.cs/github-contributors-list to v2 * fix: fix import --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: lijianan <574980606@qq.com>
48 lines
1.1 KiB
TypeScript
48 lines
1.1 KiB
TypeScript
import React from 'react';
|
|
import type { AvatarListItem } from '@qixian.cs/github-contributors-list/dist/AvatarList';
|
|
import { Avatar, Skeleton, Tooltip } from 'antd';
|
|
|
|
const AvatarPlaceholder: React.FC<{ num?: number }> = ({ num = 3 }) => (
|
|
<li>
|
|
{Array.from({ length: num }).map<React.ReactNode>((_, i) => (
|
|
<Skeleton.Avatar
|
|
size="small"
|
|
active
|
|
key={i}
|
|
style={{ marginInlineStart: i === 0 ? 0 : -8 }}
|
|
/>
|
|
))}
|
|
</li>
|
|
);
|
|
|
|
interface ContributorAvatarProps {
|
|
loading?: boolean;
|
|
item?: AvatarListItem;
|
|
}
|
|
|
|
const ContributorAvatar: React.FC<ContributorAvatarProps> = (props) => {
|
|
const {
|
|
item: { username, url } = {},
|
|
loading,
|
|
} = props;
|
|
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;
|