-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathCard.tsx
More file actions
70 lines (65 loc) · 2.02 KB
/
Card.tsx
File metadata and controls
70 lines (65 loc) · 2.02 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
import { text2color } from 'idea-react';
import { GitRepository } from 'mobx-github';
import { observer } from 'mobx-react';
import { FC, useContext } from 'react';
import { Badge, Button, Card, Col, Row } from 'react-bootstrap';
import { I18nContext } from '../../models/Translation';
import { GitLogo } from './Logo';
export interface GitCardProps
extends Pick<GitRepository, 'full_name' | 'html_url' | 'languages'>,
Partial<Pick<GitRepository, 'topics' | 'description' | 'homepage'>> {
className?: string;
}
export const GitCard: FC<GitCardProps> = observer(
({
className = 'shadow-sm',
full_name,
html_url,
languages = [],
topics = [],
description,
homepage,
}) => {
const { t } = useContext(I18nContext);
return (
<Card className={className}>
<Card.Body className="d-flex flex-column gap-3">
<Card.Title as="h3" className="h5">
<a target="_blank" href={html_url} rel="noreferrer">
{full_name}
</a>
</Card.Title>
<nav className="flex-fill">
{topics.map(topic => (
<Badge
key={topic}
className="me-1"
bg={text2color(topic, ['light'])}
as="a"
target="_blank"
href={`https://github.com/topics/${topic}`}
>
{topic}
</Badge>
))}
</nav>
<Row as="ul" className="list-unstyled g-4" xs={4}>
{languages.map(language => (
<Col key={language} as="li">
<GitLogo name={language} />
</Col>
))}
</Row>
<Card.Text>{description}</Card.Text>
</Card.Body>
<Card.Footer className="d-flex justify-content-between align-items-center">
{homepage && (
<Button variant="success" target="_blank" href={homepage}>
{t('home_page')}
</Button>
)}
</Card.Footer>
</Card>
);
},
);