Skip to content

Commit

Permalink
me image fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
tgxn committed Nov 1, 2023
1 parent 334f810 commit 3ddd464
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 27 deletions.
9 changes: 6 additions & 3 deletions src/components/Image.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,21 @@ function RenderImage({ imageSrc, imageAlt = "" }) {
height={"100%"}
width={"100%"}
loading="lazy"
style={{ visible: imageLoaded ? "visible" : "hidden" }}
style={{
visible: imageLoaded ? "visible" : "hidden",
// fit image to container
}}
onLoad={() => setImageLoaded(true)}
onError={() => setImageError(true)}
/>
);
}

export default function LazyImage({ width = 175, imageSrc, imageAlt = "" }) {
export default function LazyImage({ width = 200, imageSrc, imageAlt = "" }) {
const isImage = imageSrc.match(/\.(jpeg|jpg|gif|png)$/) != null;

return (
<AspectRatio sx={{ width: width }}>
<AspectRatio sx={{ width: width }} ratio="1/1">
<SanitizedLink underline={"none"} href={imageSrc} target="_new">
{isImage ? (
<RenderImage imageSrc={imageSrc} imageAlt={imageAlt} />
Expand Down
6 changes: 3 additions & 3 deletions src/components/ListItem/Comment.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@ import React from "react";
import Box from "@mui/joy/Box";
import Typography from "@mui/joy/Typography";
import Alert from "@mui/joy/Alert";
import Divider from "@mui/joy/Divider";

import ThumbsUpDownIcon from "@mui/icons-material/ThumbsUpDown";
import ThumbDownIcon from "@mui/icons-material/ThumbDown";
import DoneAllIcon from "@mui/icons-material/DoneAll";
import DeleteOutlineIcon from "@mui/icons-material/DeleteOutline";
import ForumIcon from "@mui/icons-material/Forum";
import DraftsIcon from "@mui/icons-material/Drafts";
import FormatQuoteIcon from "@mui/icons-material/FormatQuote";

import { SquareChip } from "../Display.jsx";
Expand Down Expand Up @@ -159,6 +157,8 @@ export default function CommentListItem({ report }) {
{/* <DeletePostButton report={report} /> */}
<RemoveCommentButton report={report} />

<Divider orientation="vertical" flexItem />

<BanUserCommunityButton person={report.comment_creator} community={report.community} />
<BanUserSiteButton person={report.comment_creator} />
<PurgeUserSiteButton person={report.comment_creator} />
Expand Down
48 changes: 34 additions & 14 deletions src/components/ListItem/Common.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import React from "react";

import Alert from "@mui/joy/Alert";
import Card from "@mui/joy/Card";

import Avatar from "@mui/joy/Avatar";
import Box from "@mui/joy/Box";
import Typography from "@mui/joy/Typography";
import Badge from "@mui/joy/Badge";
Expand All @@ -25,6 +27,22 @@ import { parseActorId } from "../../utils.js";

import { getSiteData } from "../../hooks/getSiteData";

export function UserAvatar({ source, ...props }) {
return (
<Avatar
component="span"
size="sm"
src={source}
sx={{
display: "inline-flex",
alignItems: "center",
justifyContent: "center",
}}
{...props}
/>
);
}

export function ReportListItem({ itemType, report, children }) {
let itemColor;
let itemIcon;
Expand Down Expand Up @@ -130,7 +148,7 @@ export function PersonMetaLine({ creator, by = false, sx }) {
const actorInstanceBaseUrl = creator.actor_id.split("/")[2];
const fediverseUserLink = creator.actor_id;

// console.log("creator", actorInstanceBaseUrl, fediverseUserLink);
// console.log("creator", creator);

let localUserLink = `https://${baseUrl}/u/${creator.name}`;
if (baseUrl != actorInstanceBaseUrl) localUserLink = `${localUserLink}@${actorInstanceBaseUrl}`;
Expand All @@ -144,16 +162,20 @@ export function PersonMetaLine({ creator, by = false, sx }) {
...sx,
}}
>
<Typography
variant="body3"
component="p"
<Box
sx={{
fontSize: "14px",
overflow: "hidden",
display: "flex",
flexDirection: "row",
alignItems: "center",
}}
>
{by && "by "}
{creator.display_name && `${creator.display_name} `}
{by && <Typography sx={{ pr: 1 }}>by</Typography>}
<UserAvatar source={creator.avatar} />
{creator.display_name && (
<Typography sx={{ fontSize: "15px", px: 1 }}>{creator.display_name}</Typography>
)}
<Tooltip
placement="top-start"
variant="outlined"
Expand All @@ -162,18 +184,16 @@ export function PersonMetaLine({ creator, by = false, sx }) {
disableInteractive
>
<Link href={creator.actor_id} target="_blank" rel="noopener noreferrer" sx={{ pb: 0.7, pl: 1 }}>
<Typography component="span" sx={{ fontSize: "16px", mr: 0.25 }}>
<Typography component="span" sx={{ mr: 0.25 }}>
{creator.name}
</Typography>
<Typography component="span" sx={{ fontSize: "12px" }}>
@{creator.actor_id.split("/")[2]}
</Typography>
<Typography component="span">@{creator.actor_id.split("/")[2]}</Typography>
</Link>
</Tooltip>
</Typography>
</Box>

{/* Post Author Meta */}
<Typography variant="h6" component="h2" sx={{ display: "flex", gap: 1 }}>
<Box sx={{ display: "flex", gap: 1 }}>
{baseUrl != actorInstanceBaseUrl && <FediverseChipLink href={fediverseUserLink} size="sm" />}

{creator.admin && (
Expand All @@ -199,7 +219,7 @@ export function PersonMetaLine({ creator, by = false, sx }) {
{creator.deleted && (
<SquareChip color={"danger"} tooltip="User is deleted" iconOnly={<DeleteIcon fontSize="small" />} />
)}
</Typography>
</Box>
</Box>
);
}
Expand Down Expand Up @@ -279,7 +299,7 @@ export function ReportDetails({ report, creator }) {
variant={"soft"}
color="warning"
sx={{
mt: 2,
mt: 1,
mb: 1,
p: 2,
}}
Expand Down
1 change: 1 addition & 0 deletions src/components/ListItem/PM.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import React from "react";
import Box from "@mui/joy/Box";
import Typography from "@mui/joy/Typography";
import Alert from "@mui/joy/Alert";
import Divider from "@mui/joy/Divider";

import DoneAllIcon from "@mui/icons-material/DoneAll";
import DeleteOutlineIcon from "@mui/icons-material/DeleteOutline";
Expand Down
18 changes: 11 additions & 7 deletions src/components/ListItem/Post.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import React from "react";
import Box from "@mui/joy/Box";
import Typography from "@mui/joy/Typography";
import Alert from "@mui/joy/Alert";
import Divider from "@mui/joy/Divider";

import DoneAllIcon from "@mui/icons-material/DoneAll";
import BlockIcon from "@mui/icons-material/Block";
Expand Down Expand Up @@ -175,19 +176,20 @@ export default function PostListItem({ report }) {
>
<PostContentDetail report={report} />
</Box>

{/* Show External Link or Image for URLs */}
{report.post.url && (
<Box
sx={{
flexGrow: 0,
flexShrink: 0,
flexBasis: "auto",
// flexGrow: 0,
// flexShrink: 0,
// flexBasis: "auto",
// width: "175px",
// height: "200px",
pr: 2,
// height: "500px",
pl: 2,
// flexAlign: "center",
justifyContent: "center",
display: "flex",
// justifyContent: "center",
// display: "flex",
// flexDirection: "column",
}}
>
Expand Down Expand Up @@ -223,6 +225,8 @@ export default function PostListItem({ report }) {
{/* @TODO Maybe only show purge is post is deleted?? */}
<PurgePostButton report={report} />

<Divider orientation="vertical" flexItem />

<BanUserCommunityButton person={report.post_creator} community={report.community} />
<BanUserSiteButton person={report.post_creator} />
<PurgeUserSiteButton person={report.post_creator} />
Expand Down

0 comments on commit 3ddd464

Please sign in to comment.