-
Notifications
You must be signed in to change notification settings - Fork 0
/
Card.tsx
66 lines (62 loc) · 2.3 KB
/
Card.tsx
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
import { text2color } from 'idea-react';
import { GitRepository } from 'mobx-github';
import { observer } from 'mobx-react';
import { FC } from 'react';
import { Badge, Button, Card, Col, Row } from 'react-bootstrap';
import { i18n } from '../../model/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
}) => (
<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="text-decoration-none 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}>
{i18n.t('home_page')}
</Button>
)}
</Card.Footer>
</Card>
)
);