-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCard.tsx
78 lines (74 loc) · 1.97 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
67
68
69
70
71
72
73
74
75
76
77
78
import {
Box,
Button,
Card,
CardActions,
CardContent,
CardHeader,
CardOwnProps,
Chip,
Typography
} from '@mui/material';
import Grid from '@mui/material/Grid2';
import { GitRepository } from 'mobx-github';
import { observer } from 'mobx-react';
import { FC } from 'react';
import { i18n } from '../../model/Translation';
import { GitLogo } from './Logo';
export type GitCardProps = Pick<GitRepository, 'full_name' | 'html_url' | 'languages'> &
Partial<Pick<GitRepository, 'topics' | 'description' | 'homepage'>> &
CardOwnProps;
export const GitCard: FC<GitCardProps> = observer(
({ full_name, html_url, languages = [], topics = [], description, homepage, sx, ...rest }) => (
<Card
sx={{
display: 'flex',
flexDirection: 'column',
justifyContent: 'space-between',
...sx
}}
{...rest}
>
<CardHeader
title={
<a target="_blank" href={html_url} rel="noreferrer">
{full_name}
</a>
}
/>
<CardContent
sx={{
display: 'flex',
flexDirection: 'column',
justifyContent: 'space-between',
gap: 2
}}
>
<Box component="ul" sx={{ m: 0, p: 0, display: 'flex', flexWrap: 'wrap', gap: 1 }}>
{topics.map(topic => (
<Chip
key={topic}
component="a"
target="_blank"
href={`https://github.com/topics/${topic}`}
label={topic}
size="small"
clickable
/>
))}
</Box>
<Grid component="ul" sx={{ m: 0, p: 0 }}>
{languages.map(language => (
<GitLogo name={language} />
))}
</Grid>
<Typography>{description}</Typography>
</CardContent>
<CardActions>
<Button color="success" target="_blank" href={homepage || html_url}>
{i18n.t('home_page')}
</Button>
</CardActions>
</Card>
)
);