-
Notifications
You must be signed in to change notification settings - Fork 5k
Expand file tree
/
Copy pathindex.jsx
More file actions
171 lines (157 loc) · 4.76 KB
/
Copy pathindex.jsx
File metadata and controls
171 lines (157 loc) · 4.76 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
/**
=========================================================
* Material Dashboard 2 React - v2.2.0
=========================================================
* Product Page: https://www.creative-tim.com/product/material-dashboard-react
* Copyright 2023 Creative Tim (https://www.creative-tim.com)
Coded by www.creative-tim.com
=========================================================
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*/
// react-router-dom components
import { Link } from "react-router-dom";
// prop-types is a library for typechecking of props
import PropTypes from "prop-types";
// @mui material components
import Card from "@mui/material/Card";
import CardMedia from "@mui/material/CardMedia";
import Tooltip from "@mui/material/Tooltip";
// Material Dashboard 2 React components
import MDBox from "components/MDBox";
import MDTypography from "components/MDTypography";
import MDButton from "components/MDButton";
import MDAvatar from "components/MDAvatar";
function DefaultProjectCard({ image, label, title, description, action, authors }) {
const renderAuthors = authors.map(({ image: media, name }) => (
<Tooltip key={name} title={name} placement="bottom">
<MDAvatar
src={media}
alt={name}
size="xs"
sx={({ borders: { borderWidth }, palette: { white } }) => ({
border: `${borderWidth[2]} solid ${white.main}`,
cursor: "pointer",
position: "relative",
ml: -1.25,
"&:hover, &:focus": {
zIndex: "10",
},
})}
/>
</Tooltip>
));
return (
<Card
sx={{
display: "flex",
flexDirection: "column",
backgroundColor: "transparent",
boxShadow: "none",
overflow: "visible",
}}
>
<MDBox position="relative" width="100.25%" shadow="xl" borderRadius="xl">
<CardMedia
src={image}
component="img"
title={title}
sx={{
maxWidth: "100%",
margin: 0,
boxShadow: ({ boxShadows: { md } }) => md,
objectFit: "cover",
objectPosition: "center",
}}
/>
</MDBox>
<MDBox mt={1} mx={0.5}>
<MDTypography variant="button" fontWeight="regular" color="text" textTransform="capitalize">
{label}
</MDTypography>
<MDBox mb={1}>
{action.type === "internal" ? (
<MDTypography
component={Link}
to={action.route}
variant="h5"
textTransform="capitalize"
>
{title}
</MDTypography>
) : (
<MDTypography
component="a"
href={action.route}
target="_blank"
rel="noreferrer"
variant="h5"
textTransform="capitalize"
>
{title}
</MDTypography>
)}
</MDBox>
<MDBox mb={3} lineHeight={0}>
<MDTypography variant="button" fontWeight="light" color="text">
{description}
</MDTypography>
</MDBox>
<MDBox display="flex" justifyContent="space-between" alignItems="center">
{action.type === "internal" ? (
<MDButton
component={Link}
to={action.route}
variant="outlined"
size="small"
color={action.color}
>
{action.label}
</MDButton>
) : (
<MDButton
component="a"
href={action.route}
target="_blank"
rel="noreferrer"
variant="outlined"
size="small"
color={action.color}
>
{action.label}
</MDButton>
)}
<MDBox display="flex">{renderAuthors}</MDBox>
</MDBox>
</MDBox>
</Card>
);
}
// Setting default values for the props of DefaultProjectCard
DefaultProjectCard.defaultProps = {
authors: [],
};
// Typechecking props for the DefaultProjectCard
DefaultProjectCard.propTypes = {
image: PropTypes.string.isRequired,
label: PropTypes.string.isRequired,
title: PropTypes.string.isRequired,
description: PropTypes.string.isRequired,
action: PropTypes.shape({
type: PropTypes.oneOf(["external", "internal"]),
route: PropTypes.string.isRequired,
color: PropTypes.oneOf([
"primary",
"secondary",
"info",
"success",
"warning",
"error",
"light",
"dark",
"white",
]).isRequired,
label: PropTypes.string.isRequired,
}).isRequired,
authors: PropTypes.arrayOf(PropTypes.object),
};
export default DefaultProjectCard;