import type { mastodon } from "masto"; import { splitProps, type Component, type JSX, Show, createRenderEffect, } from "solid-js"; import tootStyle from "./toot.module.css"; import { formatRelative } from "date-fns"; import Img from "../material/Img.js"; import { Body2 } from "../material/typography.js"; import { css } from "solid-styled"; import { BookmarkAddOutlined, Repeat, ReplyAll, Star, StarOutline, Bookmark, Reply, } from "@suid/icons-material"; import { useTimeSource } from "../platform/timesrc.js"; import { resolveCustomEmoji } from "../masto/toot.js"; import { Divider } from "@suid/material"; import cardStyle from "../material/cards.module.css"; import Button from "../material/Button.js"; import MediaAttachmentGrid from "./MediaAttachmentGrid.js"; type TootContentViewProps = { source?: string; emojis?: mastodon.v1.CustomEmoji[]; } & JSX.HTMLAttributes; const TootContentView: Component = (props) => { const [managed, rest] = splitProps(props, ["source", "emojis"]); return (
{ createRenderEffect(() => { ref.innerHTML = managed.source ? managed.emojis ? resolveCustomEmoji(managed.source, managed.emojis) : managed.source : ""; }); }} {...rest} >
); }; const RetootIcon: Component = (props) => { const [managed, rest] = splitProps(props, ["class"]); css` .retoot-icon { padding: 0; display: inline-block; border-radius: 2px; > :global(svg) { color: green; font-size: 1rem; vertical-align: middle; } } `; return ( ); }; const ReplyIcon: Component = (props) => { const [managed, rest] = splitProps(props, ["class"]); css` .retoot-icon { padding: 0; display: inline-block; border-radius: 2px; > :global(svg) { color: var(--tutu-color-primary); font-size: 1rem; vertical-align: middle; } } `; return ( ); }; type TootActionGroupProps = { onRetoot?: (value: T) => void; onFavourite?: (value: T) => void; onBookmark?: (value: T) => void; onReply?: (value: T) => void; }; type TootCardProps = { status: mastodon.v1.Status; actionable?: boolean; evaluated?: boolean; } & TootActionGroupProps & JSX.HTMLElementTags["article"]; function isolatedCallback(e: MouseEvent) { e.stopPropagation(); } function TootActionGroup( props: TootActionGroupProps & { value: T }, ) { const toot = () => props.value; return (
); } function TootAuthorGroup(props: { status: mastodon.v1.Status; now: Date }) { const toot = () => props.status; return (
{ createRenderEffect(() => { e.innerHTML = resolveCustomEmoji( toot().account.displayName, toot().account.emojis, ); }); }} /> @{toot().account.username}@{new URL(toot().account.url).hostname}
); } const RegularToot: Component = (props) => { let rootRef: HTMLElement; const [managed, managedActionGroup, rest] = splitProps( props, ["status", "lang", "class", "actionable", "evaluated"], ["onRetoot", "onFavourite", "onBookmark", "onReply"], ); const now = useTimeSource(); const status = () => managed.status; const toot = () => status().reblog ?? status(); css` .reply-sep { margin-left: calc(var(--toot-avatar-size) + var(--card-pad) + 8px); margin-block: 8px; } `; return ( <>
{ createRenderEffect(() => { e.innerHTML = resolveCustomEmoji( status().account.displayName, toot().emojis, ); }); }} >{" "} boosted
0}>
); }; export default RegularToot;