-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCommitAuthorStack.tsx
More file actions
47 lines (42 loc) · 1.55 KB
/
CommitAuthorStack.tsx
File metadata and controls
47 lines (42 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import {AvatarStack} from '@primer/react'
import {GitHubAvatar} from '@github-ui/github-avatar'
import {userHovercardPath, orgHovercardPath} from '@github-ui/paths'
import type {Author} from '../commit-attribution-types'
import {isBotOrApp} from '../utils'
import {useAuthorSettings} from '../contexts/AuthorSettingsContext'
type CommitAuthorStackProps = {
authors: Author[]
onBehalfOf?: Author
}
const maxAvatarCount = 5
export function CommitAuthorStack({authors, onBehalfOf}: CommitAuthorStackProps) {
const authorSettings = useAuthorSettings()
return (
<AvatarStack>
{authors.slice(0, maxAvatarCount).map((author, index) => (
<GitHubAvatar
data-testid="commit-stack-avatar"
// eslint-disable-next-line @eslint-react/no-array-index-key
key={`${author.login}_${index}`}
src={author.avatarUrl}
alt={author.login ?? author.displayName}
data-hovercard-url={userHovercardPath({owner: author.login ?? ''})}
square={isBotOrApp(author)}
size={authorSettings.avatarSize}
/>
))}
{onBehalfOf && (
<GitHubAvatar
data-testid="commit-stack-avatar"
key={`${onBehalfOf.login}_on_behalf_of`}
src={onBehalfOf.avatarUrl}
alt={onBehalfOf.login ?? onBehalfOf.displayName}
data-hovercard-url={orgHovercardPath({owner: onBehalfOf.login ?? ''})}
square
size={authorSettings.avatarSize}
/>
)}
</AvatarStack>
)
}
try{ CommitAuthorStack.displayName ||= 'CommitAuthorStack' } catch {}