aboutsummaryrefslogtreecommitdiff
path: root/src/frontend/components/MastodonShareButton.tsx
diff options
context:
space:
mode:
authorXe Iaso <me@xeiaso.net>2023-04-29 13:26:09 -0400
committerXe Iaso <me@xeiaso.net>2023-04-29 13:26:09 -0400
commit042d4fa9523edb9b0613902d67452df10078c836 (patch)
tree377a856295cdefa79ff5f807b1370c975e899e7a /src/frontend/components/MastodonShareButton.tsx
parent9d9614ad8a4a1d00f7df1b0e37ec32d324151335 (diff)
downloadxesite-yarn.tar.xz
xesite-yarn.zip
fucking horrible typescript garbageyarn
Signed-off-by: Xe Iaso <me@xeiaso.net>
Diffstat (limited to 'src/frontend/components/MastodonShareButton.tsx')
-rw-r--r--src/frontend/components/MastodonShareButton.tsx32
1 files changed, 18 insertions, 14 deletions
diff --git a/src/frontend/components/MastodonShareButton.tsx b/src/frontend/components/MastodonShareButton.tsx
index d809ee9..a0d56f0 100644
--- a/src/frontend/components/MastodonShareButton.tsx
+++ b/src/frontend/components/MastodonShareButton.tsx
@@ -1,17 +1,15 @@
-// @jsxImportSource xeact
-// @jsxRuntime automatic
-
-import { u, useState } from "xeact";
+import { u } from "@xeserv/xeact";
+import { useState } from 'preact/hooks';
export interface MastodonShareButtonProps {
title: string;
url: string;
series?: string;
- tags: string;
+ tags: string[];
}
export default function MastodonShareButton(
- { title, url = u(), series, tags }: MastodonShareButtonProps,
+ { title, url = u("", {}), series, tags }: MastodonShareButtonProps,
) {
let defaultURL = localStorage["mastodon_instance"];
@@ -27,8 +25,8 @@ ${series ? "#" + series + " " : ""}${
tags ? tags.map((x) => "#" + x).join(" ") : ""
} @cadey@pony.social`;
- const [getURL, setURL] = useState(defaultURL);
- const [getToot, setToot] = useState(tootTemplate);
+ const [theURL, setURL] = useState(defaultURL);
+ const [toot, setToot] = useState(tootTemplate);
return (
<div>
@@ -40,27 +38,33 @@ ${series ? "#" + series + " " : ""}${
type="text"
placeholder="https://pony.social"
value={defaultURL}
- oninput={(e) => setURL(e.target.value)}
+ onInput={(e) => {
+ const target = e.target as HTMLInputElement;
+ setURL(target.value);
+ }}
/>
<br />
<textarea
rows={6}
cols={40}
- oninput={(e) => setToot(e.target.value)}
+ onInput={(e) => {
+ const target = e.target as HTMLTextAreaElement;
+ setToot(target.value)
+ }}
>
- {getToot()}
+ {toot}
</textarea>
<br />
<button
- onclick={() => {
- let instanceURL = getURL();
+ onClick={() => {
+ let instanceURL = theURL;
if (!instanceURL.startsWith("https://")) {
instanceURL = `https://${instanceURL}`;
}
localStorage["mastodon_instance"] = instanceURL;
- const text = getToot();
+ const text = toot;
const mastodonURL = u(instanceURL + "/share", {
text,
visibility: "public",