2024-07-14 20:28:44 +08:00
|
|
|
import type { mastodon } from "masto";
|
|
|
|
import { type Component } from "solid-js";
|
|
|
|
import tootStyle from "./toot.module.css";
|
|
|
|
import { formatRelative } from "date-fns";
|
|
|
|
import Img from "../material/Img";
|
|
|
|
import { Body2 } from "../material/typography";
|
|
|
|
import { css } from "solid-styled";
|
|
|
|
import { appliedCustomEmoji } from "../masto/toot";
|
|
|
|
import cardStyle from "../material/cards.module.css";
|
|
|
|
|
|
|
|
type CompactTootProps = {
|
|
|
|
status: mastodon.v1.Status;
|
|
|
|
now: Date;
|
|
|
|
class?: string;
|
|
|
|
};
|
|
|
|
|
|
|
|
const CompactToot: Component<CompactTootProps> = (props) => {
|
|
|
|
const toot = () => props.status;
|
|
|
|
return (
|
|
|
|
<section
|
2024-08-05 15:33:00 +08:00
|
|
|
class={[tootStyle.compact, props.class || ""].join(" ")}
|
2024-07-14 20:28:44 +08:00
|
|
|
lang={toot().language || undefined}
|
|
|
|
>
|
|
|
|
<Img
|
|
|
|
src={toot().account.avatar}
|
2024-08-05 15:33:00 +08:00
|
|
|
class={[tootStyle.tootAvatar].join(" ")}
|
2024-07-14 20:28:44 +08:00
|
|
|
/>
|
2024-08-05 15:33:00 +08:00
|
|
|
<div class={[tootStyle.compactAuthorGroup].join(" ")}>
|
2024-07-14 20:28:44 +08:00
|
|
|
<Body2
|
|
|
|
ref={(e: { innerHTML: string }) => {
|
|
|
|
appliedCustomEmoji(
|
|
|
|
e,
|
|
|
|
toot().account.displayName,
|
|
|
|
toot().account.emojis,
|
|
|
|
);
|
|
|
|
}}
|
|
|
|
></Body2>
|
|
|
|
<span class={tootStyle.compactAuthorUsername}>
|
|
|
|
@{toot().account.username}@{new URL(toot().account.url).hostname}
|
|
|
|
</span>
|
|
|
|
<time datetime={toot().createdAt}>
|
2024-08-13 14:06:55 +08:00
|
|
|
{formatRelative(props.now, toot().createdAt)}
|
2024-07-14 20:28:44 +08:00
|
|
|
</time>
|
|
|
|
</div>
|
|
|
|
<div
|
|
|
|
ref={(e: { innerHTML: string }) => {
|
|
|
|
appliedCustomEmoji(e, toot().content, toot().emojis);
|
|
|
|
}}
|
2024-08-05 15:33:00 +08:00
|
|
|
class={[tootStyle.compactTootContent].join(" ")}
|
2024-07-14 20:28:44 +08:00
|
|
|
></div>
|
|
|
|
</section>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default CompactToot;
|