-
-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathSourceListItem.tsx
More file actions
64 lines (58 loc) · 2.27 KB
/
SourceListItem.tsx
File metadata and controls
64 lines (58 loc) · 2.27 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
import React, { useMemo } from "react";
import { Grid, Typography } from "@mui/material";
import CardBase from "../CardBase";
import AletheiaButton from "../Button";
import { useTranslation } from "next-i18next";
import SourceListItemStyled from "./SourceListItem.style";
import ReviewClassification from "../ClaimReview/ReviewClassification";
const DOMAIN_PROTOCOL_REGEX = /^(https?:\/\/)?(www\.)?/;
const SourceListItem = ({ source }) => {
const { t } = useTranslation();
const title = useMemo(() => {
const domainWithoutProtocol = source.href.replace(
DOMAIN_PROTOCOL_REGEX,
""
);
const domainParts = domainWithoutProtocol.split(".");
return domainParts[0].charAt(0).toUpperCase() + domainParts[0].slice(1);
}, [source.href]);
return (
<CardBase style={{ padding: "32px" }}>
<SourceListItemStyled container item
xs={12}
classification={source.props.classification}
>
<h4 className="title">{title}</h4>
<Typography
variant="body1"
sx={{
display: "-webkit-box",
overflow: "hidden",
WebkitBoxOrient: "vertical",
WebkitLineClamp: 4,
textOverflow: "ellipsis",
}}
>
<cite style={{ fontStyle: "normal" }}>
<p className="summary">{source.props.summary}</p>
</cite>
</Typography>
<Grid item className="footer">
<ReviewClassification
label={t("sources:sourceReview")}
classification={source.props.classification}
/>
<AletheiaButton
href={source.href}
target="_blank"
rel="noopener noreferrer"
style={{ width: "fit-content" }}
>
{t("sources:sourceCardButton")}
</AletheiaButton>
</Grid>
</SourceListItemStyled>
</CardBase>
);
};
export default SourceListItem;