-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathEventsPageCauseCard.tsx
71 lines (63 loc) · 1.79 KB
/
EventsPageCauseCard.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
import React from "react";
import { makeStyles, createStyles, Theme } from "@material-ui/core/styles";
import CoreTypography from "@core/typography";
import FocusVisibleOnly from "components/FocusVisibleOnly";
import { CauseCardData } from "utils/types";
interface StyleProps {
imagePath: string;
isSmall: boolean;
}
const useStyles = makeStyles<Theme, StyleProps>(({ palette }) =>
createStyles({
card: {
backgroundColor: palette.background.paper,
width: props => (props.isSmall ? 250 : 360),
height: props => (props.isSmall ? 138 : 202),
borderRadius: 10,
overflow: "hidden",
outline: "none",
display: "flex",
flexDirection: "column",
alignItems: "center",
justifyContent: "center",
backgroundImage: props =>
// Add a black overlay on top of cause image
`linear-gradient(to right, rgba(0, 0, 0, 0.45), rgba(0, 0, 0, 0.45)), url(${props.imagePath})`,
backgroundPosition: "center",
backgroundSize: "cover"
},
causeText: {
color: palette.primary.contrastText,
display: "flex",
alignItems: "center",
textAlign: "center",
maxWidth: props => (props.isSmall ? 200 : 260)
}
})
);
interface Props {
causeCardData: CauseCardData;
onClick: () => void;
isSmall?: boolean;
}
const EventsPageCauseCard: React.FC<Props> = ({
causeCardData,
onClick,
isSmall = false
}) => {
const { imagePath, cause } = causeCardData;
const { card, causeText } = useStyles({
imagePath,
isSmall
});
return (
<FocusVisibleOnly onClick={onClick}>
<div className={card}>
<CoreTypography variant={isSmall ? "h4" : "h2"} className={causeText}>
{cause}
</CoreTypography>
</div>
</FocusVisibleOnly>
);
};
export default EventsPageCauseCard;