mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 22:16:40 +00:00
integrating avatar and time into tweet list
This commit is contained in:
1 parent
3d5aadc46d
commit
619f75544c
8 files changed
+134
-52
No files matched your search
@@ -1,24 +1,34 @@
|
||||
import React from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { makeStyles } from "@material-ui/core/styles";
|
||||
import ListItemText from "@material-ui/core/ListItemText";
|
||||
import { Button } from "@material-ui/core";
|
||||
import ListItemAvatar from "@material-ui/core/ListItemAvatar";
|
||||
import MuiAvatar from "@material-ui/core/Avatar";
|
||||
import Button from "@material-ui/core/Button";
|
||||
import Typography from "@material-ui/core/Typography";
|
||||
import FavoriteBorderIcon from "@material-ui/icons/FavoriteBorder";
|
||||
import ReplyIcon from "@material-ui/icons/Reply";
|
||||
import QuoteIcon from "@material-ui/icons/FormatQuote";
|
||||
|
||||
import { ListItem } from "../../../ui/components/ListItem";
|
||||
import { secondsToHumanReadable } from "../utils/time";
|
||||
import ImageDisplay from "./ImageDisplay";
|
||||
import Avatar from "./Avatar";
|
||||
|
||||
const useStyles = makeStyles(() => ({
|
||||
root: {
|
||||
overflowX: "hidden",
|
||||
display: "flex",
|
||||
flexFlow: "column nowrap",
|
||||
flexFlow: "row nowrap",
|
||||
alignItems: "flex-start",
|
||||
width: "100%",
|
||||
},
|
||||
text: {
|
||||
width: "100%",
|
||||
content: {
|
||||
display: "flex",
|
||||
flexFlow: "column nowrap",
|
||||
},
|
||||
date: {
|
||||
marginLeft: "10px",
|
||||
},
|
||||
buttonContainer: {
|
||||
display: "flex",
|
||||
@@ -28,23 +38,57 @@ const useStyles = makeStyles(() => ({
|
||||
}));
|
||||
|
||||
export const Tweet = (tweet) => {
|
||||
const { message, images } = tweet;
|
||||
const {
|
||||
message,
|
||||
images,
|
||||
avatar_url,
|
||||
profile_name,
|
||||
seconds_since_tweet,
|
||||
} = tweet;
|
||||
const classes = useStyles();
|
||||
const { t } = useTranslation();
|
||||
|
||||
const Message = () => (
|
||||
<>
|
||||
<div>{message}</div>
|
||||
<ImageDisplay visible images={images} small />
|
||||
</>
|
||||
);
|
||||
|
||||
const Primary = () => (
|
||||
<>
|
||||
<strong>{`@${profile_name}`}</strong>
|
||||
<Typography
|
||||
className={classes.date}
|
||||
component="span"
|
||||
variant="body2"
|
||||
color="textSecondary"
|
||||
>
|
||||
{secondsToHumanReadable(t, seconds_since_tweet)}
|
||||
</Typography>
|
||||
</>
|
||||
);
|
||||
|
||||
return (
|
||||
<ListItem className={classes.root} divider>
|
||||
<ListItemText className={classes.text} primary={message} />
|
||||
<ImageDisplay visible images={images} small />
|
||||
<div className={classes.buttonContainer}>
|
||||
<Button>
|
||||
<FavoriteBorderIcon />
|
||||
</Button>
|
||||
<Button>
|
||||
<ReplyIcon />
|
||||
</Button>
|
||||
<Button>
|
||||
<QuoteIcon />
|
||||
</Button>
|
||||
<ListItemAvatar>
|
||||
<MuiAvatar>
|
||||
<Avatar avatarUrl={avatar_url} height="45px" width="45px" />
|
||||
</MuiAvatar>
|
||||
</ListItemAvatar>
|
||||
<div className={classes.content}>
|
||||
<ListItemText primary={<Primary />} secondary={<Message />} />
|
||||
<div className={classes.buttonContainer}>
|
||||
<Button>
|
||||
<FavoriteBorderIcon />
|
||||
</Button>
|
||||
<Button>
|
||||
<ReplyIcon />
|
||||
</Button>
|
||||
<Button>
|
||||
<QuoteIcon />
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</ListItem>
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user