-
Notifications
You must be signed in to change notification settings - Fork 292
Expand file tree
/
Copy pathGithubRepoCard.tsx
More file actions
100 lines (97 loc) · 3.31 KB
/
GithubRepoCard.tsx
File metadata and controls
100 lines (97 loc) · 3.31 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
import type { ReactElement } from 'react';
import React from 'react';
import type { GitHubUserRepository } from '../../../../graphql/github';
import {
Typography,
TypographyType,
TypographyColor,
} from '../../../../components/typography/Typography';
import { StarIcon } from '../../../../components/icons';
import { IconSize } from '../../../../components/Icon';
import { githubLanguageColors } from '../../../../lib/githubLanguageColors';
import { largeNumberFormat } from '../../../../lib/numberFormat';
interface GithubRepoCardProps {
repo: GitHubUserRepository;
}
export function GithubRepoCard({ repo }: GithubRepoCardProps): ReactElement {
const languageColor = repo.language
? githubLanguageColors[repo.language]
: undefined;
return (
<a
href={repo.url}
target="_blank"
rel="noopener noreferrer"
className="flex flex-col gap-2 rounded-16 border border-border-subtlest-tertiary p-4 transition-colors hover:border-border-subtlest-secondary"
>
<div className="flex items-center gap-1.5">
<Typography
type={TypographyType.Callout}
color={TypographyColor.Primary}
bold
className="truncate"
>
{repo.name}
</Typography>
</div>
{repo.description && (
<Typography
type={TypographyType.Footnote}
color={TypographyColor.Tertiary}
className="line-clamp-2"
>
{repo.description}
</Typography>
)}
<div className="mt-auto flex items-center gap-3">
{repo.language && (
<span className="flex items-center gap-1">
<span
className="inline-block size-3 rounded-full"
style={{
backgroundColor: languageColor ?? 'var(--text-quaternary)',
}}
/>
<Typography
type={TypographyType.Footnote}
color={TypographyColor.Quaternary}
>
{repo.language}
</Typography>
</span>
)}
{repo.stars > 0 && (
<span className="flex items-center gap-1">
<StarIcon
size={IconSize.XXSmall}
className="text-text-quaternary"
/>
<Typography
type={TypographyType.Footnote}
color={TypographyColor.Quaternary}
>
{largeNumberFormat(repo.stars)}
</Typography>
</span>
)}
{repo.forks > 0 && (
<span className="flex items-center gap-1">
<svg
className="size-3 text-text-quaternary"
viewBox="0 0 16 16"
fill="currentColor"
>
<path d="M5 5.372v.878c0 .414.336.75.75.75h4.5a.75.75 0 0 0 .75-.75v-.878a2.25 2.25 0 1 0-1.5 0v.878H6.75v-.878a2.25 2.25 0 1 0-1.5 0ZM7.25 8.75a.75.75 0 0 1 .75-.75h.01a.75.75 0 0 1 .75.75v2.5a2.25 2.25 0 1 1-1.51 0Zm.75 3.75a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5ZM5 3.25a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5Zm6 0a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5Z" />
</svg>
<Typography
type={TypographyType.Footnote}
color={TypographyColor.Quaternary}
>
{largeNumberFormat(repo.forks)}
</Typography>
</span>
)}
</div>
</a>
);
}