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

41 lines
1.2 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-23 13:45:00 +00:00
import { faComment, faImage } 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
}
else {
icon = faComment
}
return (
<SummaryBase {...props}>
<SummaryLeft
icon={icon}
2021-05-20 09:39:40 +00:00
title={`@${tweet["poster"]}`}
subtitle={new Date(tweet["insert_time"]).toLocaleString()}
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>
)
}