Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 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 | 3x 3x 3x 13x 3x 29x 13x 13x | import { styled } from "@mui/material";
import RelativeTime from "components/RelativeTime";
import { Timestamp } from "google-protobuf/google/protobuf/timestamp_pb";
import React from "react";
const StyledRow = styled("span")(({ theme }) => ({
display: "flex",
alignItems: "baseline",
gap: theme.spacing(1),
// lets the title truncate instead of pushing the time off the row
"& > :first-of-type": {
minWidth: 0,
},
}));
const StyledRelativeTime = styled(RelativeTime, {
shouldForwardProp: (prop) => prop !== "isUnread",
})<{ isUnread: boolean }>(({ theme, isUnread }) => ({
...theme.typography.caption,
flexShrink: 0,
marginInlineStart: "auto",
whiteSpace: "nowrap",
color: isUnread ? "var(--mui-palette-text-primary)" : "var(--mui-palette-text-secondary)",
fontWeight: isUnread ? "bold" : "normal",
}));
interface ThreadTitleRowProps {
children: React.ReactNode;
latestMessageTime?: Timestamp.AsObject;
isUnread: boolean;
}
/** A message list row's title, with the time of its latest message (which the list is ordered by). */
export default function ThreadTitleRow({ children, latestMessageTime, isUnread }: ThreadTitleRowProps) {
return (
<StyledRow>
{children}
{latestMessageTime && <StyledRelativeTime instant={latestMessageTime} isUnread={isUnread} />}
</StyledRow>
);
}
|