forked from ant-design/ant-design
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into feat/form-md-getValueProps
- Loading branch information
Showing
6 changed files
with
424 additions
and
293 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import React, { useContext } from 'react'; | ||
import classNames from 'classnames'; | ||
import { useIntl } from 'dumi'; | ||
import { createStyles } from 'antd-style'; | ||
import ContributorsList from '@qixian.cs/github-contributors-list'; | ||
import ContributorAvatar from './ContributorAvatar'; | ||
import SiteContext from '../SiteContext'; | ||
|
||
const useStyle = createStyles(({ token, css }) => { | ||
const { antCls } = token; | ||
|
||
return { | ||
contributorsList: css` | ||
margin-top: 120px !important; | ||
`, | ||
listMobile: css` | ||
margin: 1em 0 !important; | ||
`, | ||
title: css` | ||
font-size: 12px; | ||
opacity: 0.45; | ||
`, | ||
list: css` | ||
display: flex; | ||
flex-wrap: wrap; | ||
clear: both; | ||
li { | ||
height: 24px; | ||
} | ||
li, | ||
${antCls}-avatar + ${antCls}-avatar { | ||
transition: all ${token.motionDurationSlow}; | ||
margin-inline-end: -8px; | ||
} | ||
&:hover { | ||
li, | ||
${antCls}-avatar { | ||
margin-inline-end: 0; | ||
} | ||
} | ||
`, | ||
}; | ||
}); | ||
|
||
interface ContributorsProps { | ||
filename?: string; | ||
} | ||
|
||
const Contributors: React.FC<ContributorsProps> = ({ filename }) => { | ||
const { formatMessage } = useIntl(); | ||
const { styles } = useStyle(); | ||
const { isMobile } = useContext(SiteContext); | ||
|
||
if (!filename) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<div className={classNames(styles.contributorsList, { [styles.listMobile]: isMobile })}> | ||
<div className={styles.title}>{formatMessage({ id: 'app.content.contributors' })}</div> | ||
<ContributorsList | ||
cache | ||
repo="ant-design" | ||
owner="ant-design" | ||
fileName={filename} | ||
className={styles.list} | ||
renderItem={(item, loading) => ( | ||
<ContributorAvatar | ||
key={item?.username} | ||
username={item?.username} | ||
url={item?.url} | ||
loading={loading} | ||
/> | ||
)} | ||
/> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Contributors; |
Oops, something went wrong.