TootActionGroup: added share button (closes #18)
All checks were successful
/ depoly (push) Successful in 1m2s

This commit is contained in:
thislight 2024-09-28 17:51:37 +08:00
parent 5eda17d958
commit 591a930bb6
No known key found for this signature in database
GPG key ID: A50F9451AC56A63E
3 changed files with 129 additions and 6 deletions

View file

@ -27,16 +27,18 @@ import {
StarOutline,
Bookmark,
Reply,
Share,
} from "@suid/icons-material";
import { useTimeSource } from "../platform/timesrc.js";
import { resolveCustomEmoji } from "../masto/toot.js";
import { Divider } from "@suid/material";
import { Divider, IconButton } from "@suid/material";
import cardStyle from "../material/cards.module.css";
import Button from "../material/Button.js";
import MediaAttachmentGrid from "./MediaAttachmentGrid.js";
import { FastAverageColor } from "fast-average-color";
import Color from "colorjs.io";
import { useDateFnLocale } from "../platform/i18n";
import { canShare, share } from "../platform/share";
type TootContentViewProps = {
source?: string;
@ -165,13 +167,26 @@ function TootActionGroup<T extends mastodon.v1.Status>(
>
{toot().bookmarked ? <Bookmark /> : <BookmarkAddOutlined />}
</Button>
<Show when={canShare({ url: toot().url ?? undefined })}>
<Button
class={tootStyle.tootAction}
aria-label="Share"
onClick={async () => {
await share({
url: toot().url ?? undefined,
});
}}
>
<Share />
</Button>
</Show>
</div>
);
}
function TootAuthorGroup(props: { status: mastodon.v1.Status; now: Date }) {
const toot = () => props.status;
const dateFnLocale = useDateFnLocale()
const dateFnLocale = useDateFnLocale();
return (
<div class={tootStyle.tootAuthorGrp}>
@ -189,7 +204,9 @@ function TootAuthorGroup(props: { status: mastodon.v1.Status; now: Date }) {
}}
/>
<time datetime={toot().createdAt}>
{formatRelative(toot().createdAt, props.now, {locale: dateFnLocale()})}
{formatRelative(toot().createdAt, props.now, {
locale: dateFnLocale(),
})}
</time>
<span>
@{toot().account.username}@{new URL(toot().account.url).hostname}