TootActionGroup: added share button (closes #18)
All checks were successful
/ depoly (push) Successful in 1m2s
All checks were successful
/ depoly (push) Successful in 1m2s
This commit is contained in:
parent
5eda17d958
commit
591a930bb6
3 changed files with 129 additions and 6 deletions
|
@ -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}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue