1
Fork 0
mirror of https://github.com/pds-nest/nest.git synced 2024-11-25 06:24:19 +00:00
pds-2021-g2-nest/nest_frontend/components/interactive/SummaryTweet.js

44 lines
1.3 KiB
JavaScript
Raw Normal View History

2021-05-18 17:15:53 +00:00
import React from "react"
import SummaryBase from "../base/summary/SummaryBase"
import SummaryLeft from "../base/summary/SummaryLeft"
2021-05-24 12:23:11 +00:00
import { faComment, faImage, faRetweet } from "@fortawesome/free-solid-svg-icons"
2021-05-18 17:15:53 +00:00
import SummaryText from "../base/summary/SummaryText"
import SummaryRight from "../base/summary/SummaryRight"
2021-05-23 03:03:41 +00:00
/**
* A {@link SummaryBase} representing a tweet.
*
* @param tweet - The tweet to represent.
* @param props - Additional props to pass to the summary.
* @returns {JSX.Element}
* @constructor
*/
2021-05-18 17:15:53 +00:00
export default function SummaryTweet({ tweet, ...props }) {
let icon
2021-05-23 13:45:00 +00:00
if(tweet["image_url"]) {
icon = faImage
2021-05-18 17:15:53 +00:00
}
2021-05-24 12:23:11 +00:00
else if(tweet["content"].startsWith("RT")) {
icon = faRetweet
}
2021-05-18 17:15:53 +00:00
else {
icon = faComment
}
return (
<SummaryBase {...props}>
<SummaryLeft
icon={icon}
2021-05-20 09:39:40 +00:00
title={`@${tweet["poster"]}`}
2021-05-26 20:54:15 +00:00
subtitle={tweet["post_time"] ? new Date(tweet["post_time"]).toLocaleString() : null}
2021-05-20 09:39:40 +00:00
onClick={() => window.open(`https://twitter.com/${tweet["poster"]}/status/${tweet["snowflake"]}`)}
2021-05-18 17:15:53 +00:00
/>
<SummaryText>
{tweet.content}
</SummaryText>
<SummaryRight/>
</SummaryBase>
)
}